public static void GetNormalCard(Transform parent, int cardId, int count, Vector3 eulerAngles, Vector3 scale, Vector3 pos, Action <UINormalCard> callback) { ItemTableSetting cardData = ItemTableSettings.Get(cardId); if (cardData == null) { Debug.LogError("非法ID:" + cardId); return; } UIItemTableSetting uiItem = UIItemTableSettings.Get(1); ResourceManager.LoadGameObject(uiItem.Path, (p, u, go) => { go.transform.parent = parent; go.transform.localEulerAngles = eulerAngles; go.transform.localScale = scale; go.transform.position = pos; go.SetActive(true); UINormalCard normalCard = go.GetComponent <UINormalCard>(); normalCard.SetCard(cardId, count); if (callback != null) { callback(normalCard); } }, (p, u) => { Debug.LogError("加载失败!"); }); }
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); }
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); }