53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PresetCards : MonoBehaviour
|
|
{
|
|
public int CardMax { get; private set; }
|
|
[SerializeField] private Sprite _backSprite = null;
|
|
[SerializeField] private List<Sprite> _allSprites = null;
|
|
|
|
public void SetCardMax(int max)
|
|
{
|
|
if (max > _allSprites.Count) max = _allSprites.Count; // Чтобы не превысить спрайты
|
|
CardMax = max;
|
|
}
|
|
|
|
public Sprite GetBackSprite()
|
|
{
|
|
return _backSprite;
|
|
}
|
|
|
|
public List<Sprite> GetPlayCardsSprites()
|
|
{
|
|
List<Sprite> sprites = new List<Sprite>(_allSprites);
|
|
while (CardMax < sprites.Count)
|
|
{
|
|
sprites.RemoveAt(Random.Range(0, sprites.Count));
|
|
}
|
|
|
|
return sprites;
|
|
}
|
|
|
|
public int[] GetCardIndex()
|
|
{
|
|
|
|
int[] cardIndex = new int[CardMax];
|
|
for (int i = 0; i < cardIndex.Length; i++)
|
|
{
|
|
cardIndex[i] = i;
|
|
}
|
|
|
|
for (int i = 0; i < cardIndex.Length; i++)
|
|
{
|
|
int temp = cardIndex[i];
|
|
int rnd = Random.Range(0, cardIndex.Length);
|
|
cardIndex[i] = cardIndex[rnd];
|
|
cardIndex[rnd] = temp;
|
|
}
|
|
return cardIndex;
|
|
|
|
}
|
|
}
|
|
|