Esempio n. 1
0
    private Card RandomAttackCard()
    {
        int         value = Random.Range(0, 100);
        Card        card  = null;
        List <Temp> list  = new List <Temp>();

        for (int i = 0; i < TBL_ATTACK_CARD.CountEntities; i++)
        {
            TBL_ATTACK_CARD data = TBL_ATTACK_CARD.GetEntity(i);
            AttackCard      c    = new AttackCard(data);
            list.Add(new Temp(c.percent, CardType.AttackCard, c));
        }

        float cumulative = 0f;

        for (int i = 0; i < list.Count; i++)
        {
            cumulative += list[i].percent;
            if (value <= cumulative)
            {
                card = list[i].card;
                break;
            }
        }
        return(card);
    }
Esempio n. 2
0
    void SetCard()
    {
        int startCount = CardSetting.AttackCardStartCount;

        while (startCount > 0)
        {
            int        random = Random.Range(0, TBL_ATTACK_CARD.CountEntities);
            AttackCard card   = new AttackCard(TBL_ATTACK_CARD.GetEntity(random));
            if (!CheckDuplicate(card))
            {
                cardList.Add(card);
                startCount--;
            }
        }

        startCount = CardSetting.EnergyCardStartCount;
        while (startCount > 0)
        {
            int        random = Random.Range(0, TBL_ENERGY_CARD.CountEntities);
            EnergyCard card   = new EnergyCard(TBL_ENERGY_CARD.GetEntity(random));
            if (!CheckDuplicate(card))
            {
                cardList.Add(card);
                startCount--;
            }
        }

        startCount = CardSetting.GuardCardStartCount;
        while (startCount > 0)
        {
            int       random = Random.Range(0, TBL_GUARD_CARD.CountEntities);
            GuardCard card   = new GuardCard(TBL_GUARD_CARD.GetEntity(random));
            if (!CheckDuplicate(card))
            {
                cardList.Add(card);
                startCount--;
            }
        }

        startCount = CardSetting.HealCardStartCount;
        while (startCount > 0)
        {
            int      random = Random.Range(0, TBL_HEAL_CARD.CountEntities);
            HealCard card   = new HealCard(TBL_HEAL_CARD.GetEntity(random));
            if (!CheckDuplicate(card))
            {
                cardList.Add(card);
                startCount--;
            }
        }

        startCount = CardSetting.MoveCardStartCount;
        while (startCount > 0)
        {
            int      random = Random.Range(0, TBL_MOVE_CARD.CountEntities);
            MoveCard card   = new MoveCard(TBL_MOVE_CARD.GetEntity(random));
            if (!CheckDuplicate(card))
            {
                cardList.Add(card);
                startCount--;
            }
        }



        Shuffle(cardList);

        //for(int i=0; i<list.Count; i++)
        //{
        //    cardPos[i].GetComponent<CardComponent>().SetCard(list[i]);
        //}

        UpdateCardPos();
    }