예제 #1
0
        protected GCMapGetReward GetRewardById(int rewardId)
        {
            GCMapGetReward  reward        = new GCMapGetReward();
            PBAccountData   accountData   = GetSavedData <PBAccountData>(ACCOUNT_DATA_KEY);
            PBMapPlayerData mapPlayerData = GetSavedData <PBMapPlayerData>(MAP_PLAYER_DATA_KEY);

            reward.AccountId = accountData.Uid;
            reward.PlayerId  = mapPlayerData.PlayerData.PlayerId;
            reward.OldExp    = mapPlayerData.PlayerData.Exp;
            reward.OldLevel  = mapPlayerData.PlayerData.Level;
            RewardTableSetting rewardTable = RewardTableSettings.Get(rewardId);

            reward.AddedExp = rewardTable.exp;
            reward.Diamonds = rewardTable.diamond;
            reward.Gold     = rewardTable.gold;
            reward.Food     = rewardTable.food;
            for (int i = 0; i < rewardTable.ItemList.Count; i++)
            {
                if (UnityEngine.Random.Range(0, 10000) < rewardTable.RewardProbability[i])
                {
                    ItemTableSetting itemTable = ItemTableSettings.Get(rewardTable.ItemList[i]);
                    if (itemTable == null)
                    {
                        continue;
                    }
                    switch ((ItemType)itemTable.Type)
                    {
                    case ItemType.Card:
                        reward.Cards.Add(rewardTable.ItemList[i]);
                        reward.CardTemps.Add(rewardTable.Permanent[i]);
                        break;

                    case ItemType.Equip:
                        reward.Equips.Add(rewardTable.ItemList[i]);
                        reward.EquipTemps.Add(rewardTable.Permanent[i]);
                        break;

                    case ItemType.Skill:
                        //要改
                        reward.Buffs.Add(rewardTable.ItemList[i]);
                        reward.BuffTemps.Add(rewardTable.Permanent[i]);
                        break;

                    case ItemType.Consumable:
                        reward.Items.Add(rewardTable.ItemList[i]);
                        reward.ItemTemps.Add(rewardTable.Permanent[i]);
                        break;

                    default:
                        break;
                    }
                }
            }
            return(reward);
        }
예제 #2
0
    public void AddReward(int rewardId)
    {
        RewardTableSetting rewardTable = RewardTableSettings.Get(rewardId);

        if (rewardTable != null)
        {
            AddExp(rewardTable.exp);
            Data.Gold    += rewardTable.gold;
            Data.Diamond += rewardTable.diamond;
            for (int i = 0; i < rewardTable.ItemList.Count; i++)
            {
                //卡牌类型(攻击0,装备1,法术2,消耗品3)
                ItemTableSetting itemTable = ItemTableSettings.Get(rewardTable.ItemList[i]);
                if (itemTable == null)
                {
                    Debug.LogError("物品不存在=" + rewardTable.ItemList[i]);
                    continue;
                }
                //TODO: 瞎jb写的
                switch ((ItemType)itemTable.Type)
                {
                case ItemType.Card:
                    Data.CardList.Add(new NormalCard(itemTable.Id));
                    break;

                case ItemType.Equip:
                    Data.EquipList.Add(new NormalCard(itemTable.Id));
                    break;

                case ItemType.Skill:
                    Data.BuffList.Add(new NormalCard(itemTable.Id));
                    break;

                case ItemType.Consumable:
                    Data.ItemList.Add(new ItemData(itemTable.Id));
                    break;

                default:
                    break;
                }
            }
        }
        Messenger.Broadcast(MessageId.MAP_UPDATE_PLAYER_INFO);
    }