Exemple #1
0
    //----------------------------Public Functions-----------------------------

    public void Init()
    {
        GenerateRandomSeed();

        float totalProbability = 0f;

        foreach (var card in ReinforcementCards)
        {
            totalProbability += card.Probability;
        }

        float probabilityValue = Random.Range(0f, totalProbability);

        float probabilitySum = 0f;

        foreach (var card in ReinforcementCards)
        {
            if (probabilityValue <= probabilitySum + card.Probability)
            {
                InitialCardsInDeck.Add(card.Card);
                break;
            }
            else
            {
                probabilitySum += card.Probability;
            }
        }

        SpawnInitialCards();
    }
Exemple #2
0
    //----------------------------Public Functions-----------------------------

    public void Init()
    {
        GenerateRandomSeed();

        foreach (var tank in FindObjectsOfType <Tank>())
        {
            if (tank.Faction == Faction.Player)
            {
                InitialCardsInDeck.Add(tank.Card);
            }
        }

        SpawnInitialCards();
    }
Exemple #3
0
    //-----------------------------Unity Functions-----------------------------

    protected override void Start()
    {
        base.Start();

        InitialCardsInDeck.Clear();

        // Load deck.
        for (int i = 0; i < 4; i++)
        {
            string cardString = PlayerPrefs.GetString("Card" + i);
            if (cardString != "")
            {
                var obj = Resources.Load(cardString) as GameObject;
                InitialCardsInDeck.Add(obj.GetComponent <UI_Card>());
            }
        }

        SpawnInitialCards();
    }