Example #1
0
    public Reward getRandomReward()
    {
        int tong = 0;
        for (int i = 0; i < UuTien.Length; i++)
        {
            tong += UuTien[i];
        }
        int random = UnityEngine.Random.Range(1, tong + 1);
        TypeReward kq = TypeReward.WeaponCommon;
        for (int i = 0; i < NameOfRewards.Length; i++)
        {
            random -= UuTien[i];
            if (random <= 0)
            {
                kq = NameOfRewards[i];
                break;
            }
        }
        Debug.Log(kq.ToString());
        List<Reward> rewards = RewardManager.GetRewards(kq);
        if (rewards.Count == 0)
        {
            return null;
        }
        return rewards[UnityEngine.Random.Range(0, rewards.Count)];

    }