public BattlePlayerData(int monsterId, BattlePlayer owner) : base(null, null) { BattleMonsterTableSetting monster = BattleMonsterTableSettings.Get(monsterId); if (monster == null) { Debug.LogError("怪物表格配置错误"); return; } m_CurrentCardList = new List <BattleCardData>(CardList); AP = 0; MaxAP = 0; HP = monster.HP; MaxHP = monster.MaxHp; MP = monster.MP; MaxMP = monster.MaxMP; AP = monster.AP; MaxAP = monster.MaxAP; Level = monster.Level; HeadIcon = monster.IconId; for (int i = 0; i < monster.BattleCards.Count; i++) { m_CardList.Add(new BattleCardData(monster.BattleCards[i], owner)); } }
public MapCardBase CreateMapCard() { ModelTableSetting model = null; switch (CardType) { case MapCardType.None: break; case MapCardType.Door: MapCard = new MapCardDoor(); MapCard.Position = Pos; MapCard.State = MapCardBase.CardState.Behind; ResourceManager.LoadGameObject("MapCard/" + typeof(MapCardDoor).ToString(), LoadAssetSuccessess, LoadAssetFailed, MapCard); break; case MapCardType.Monster: BattleMonsterTableSetting battleMonster = BattleMonsterTableSettings.Get(DataId); model = ModelTableSettings.Get(battleMonster.ModelId); MapCard = new MapCardDoor(); MapCard.Position = Pos; MapCard.State = MapCardBase.CardState.Behind; ResourceManager.LoadGameObject(model.Path, LoadAssetSuccessess, LoadAssetFailed, MapCard); break; case MapCardType.Shop: ShopTableSetting shopTable = ShopTableSettings.Get(DataId); model = ModelTableSettings.Get(shopTable.ModelId); MapCard = new MapCardDoor(); MapCard.Position = Pos; MapCard.State = MapCardBase.CardState.Behind; ResourceManager.LoadGameObject(model.Path, LoadAssetSuccessess, LoadAssetFailed, MapCard); break; case MapCardType.Box: BoxTableSetting boxTable = BoxTableSettings.Get(DataId); model = ModelTableSettings.Get(boxTable.ModelId); MapCard = new MapCardDoor(); MapCard.Position = Pos; MapCard.State = MapCardBase.CardState.Behind; ResourceManager.LoadGameObject(model.Path, LoadAssetSuccessess, LoadAssetFailed, MapCard); break; case MapCardType.NPC: NpcTableSetting npcTable = NpcTableSettings.Get(DataId); model = ModelTableSettings.Get(npcTable.ModelId); MapCard = new MapCardDoor(); MapCard.Position = Pos; MapCard.State = MapCardBase.CardState.Behind; ResourceManager.LoadGameObject(model.Path, LoadAssetSuccessess, LoadAssetFailed, MapCard); break; default: break; } return MapCard; }
public override void Handle(object sender, IMessage packet) { base.Handle(sender, packet); CGExitBattle data = packet as CGExitBattle; //处理完数据和逻辑后,发送消息通知客户端 PBAccountData accountData = GetSavedData <PBAccountData>(ACCOUNT_DATA_KEY); PBMapPlayerData mapPlayerData = GetSavedData <PBMapPlayerData>(MAP_PLAYER_DATA_KEY); //战斗结果 if (data.PlayerData != null) { mapPlayerData.PlayerData.Hp = data.PlayerData.Hp; mapPlayerData.PlayerData.MaxHp = data.PlayerData.MaxHp; mapPlayerData.PlayerData.Mp = data.PlayerData.Mp; mapPlayerData.PlayerData.MaxMp = data.PlayerData.MaxMp; mapPlayerData.Items.Clear(); mapPlayerData.Items.Add(data.Items); } GCMapGetReward reward = null; BattleMonsterTableSetting battleMonster = BattleMonsterTableSettings.Get(data.MonsterId); switch (data.Reason) { case 3: //对方放弃 case 0: //通关 reward = GetRewardById(battleMonster.RewardId); break; case 1: //失败 case 2: //逃跑,放弃 reward = GetRewardById(battleMonster.LoseReward); break; default: break; } if (reward != null) { //存奖励 mapPlayerData.AddedExp += reward.AddedExp; AddExp(mapPlayerData.PlayerData, reward.AddedExp); accountData.Diamonds += reward.Diamonds; mapPlayerData.PlayerData.Gold += reward.Gold; mapPlayerData.PlayerData.Food += reward.Food; if (reward.Cards.Count > 0) { mapPlayerData.Cards.Add(reward.Cards); } if (reward.Equips.Count > 0) { mapPlayerData.Equips.Add(reward.Equips); } if (reward.Items.Count > 0) { mapPlayerData.Items.Add(reward.Items); } if (reward.Buffs.Count > 0) { mapPlayerData.Buffs.Add(reward.Items); } for (int i = 0; i < reward.Cards.Count; i++) { if (reward.CardTemps[i] == 1) { mapPlayerData.RewardCards.Add(reward.Cards[i]); } } for (int i = 0; i < reward.Items.Count; i++) { if (reward.ItemTemps[i] == 1) { mapPlayerData.RewardItems.Add(reward.Items[i]); } } SaveData(ACCOUNT_DATA_KEY, accountData); SaveData(MAP_PLAYER_DATA_KEY, mapPlayerData); SendToClient(MessageId_Receive.GCMapGetReward, reward); } GCExitBattle exitBattle = new GCExitBattle(); exitBattle.MonsterId = data.MonsterId; exitBattle.Reason = data.Reason; SendToClient(MessageId_Receive.GCExitBattle, exitBattle); GCUpdateMapPlayerData updateMapPlayerData = new GCUpdateMapPlayerData(); updateMapPlayerData.MapPlayerData = mapPlayerData; updateMapPlayerData.PlayerId = mapPlayerData.PlayerData.PlayerId; SendToClient(MessageId_Receive.GCUpdateMapPlayerData, updateMapPlayerData); }
public static MapCardBase CreateMapCard(MapCardType mapCardType, int mapcardId, MapCardPos pos) { MapCardBase mapCard = null; MapCardTableSetting mapCardTable = MapCardTableSettings.Get(mapcardId); if (mapCardTable == null) { return(null); } ModelTableSetting model = ModelTableSettings.Get(mapCardTable.ModelId); if (model == null) { return(null); } switch (mapCardType) { case MapCardType.None: break; case MapCardType.Door: mapCard = new MapCardDoor(); mapCard.Position = pos; mapCard.State = MapCardBase.CardState.Behind; mapCard.CardType = mapCardType; mapCard.TableData = mapCardTable; ResourceManager.LoadGameObject("MapCard/" + typeof(MapCardDoor).ToString(), LoadAssetSuccessess, LoadAssetFailed, mapCard); break; case MapCardType.Monster: BattleMonsterTableSetting battleMonster = BattleMonsterTableSettings.Get(mapcardId); //model = ModelTableSettings.Get(battleMonster.ModelId); mapCard = new MapCardMonster(); mapCard.Position = pos; mapCard.State = MapCardBase.CardState.Behind; mapCard.CardType = mapCardType; mapCard.TableData = mapCardTable; ResourceManager.LoadGameObject(model.Path, LoadAssetSuccessess, LoadAssetFailed, mapCard); break; case MapCardType.Shop: ShopTableSetting shopTable = ShopTableSettings.Get(mapcardId); //model = ModelTableSettings.Get(shopTable.ModelId); mapCard = new MapCardShop(); mapCard.Position = pos; mapCard.State = MapCardBase.CardState.Behind; mapCard.CardType = mapCardType; mapCard.TableData = mapCardTable; ResourceManager.LoadGameObject(model.Path, LoadAssetSuccessess, LoadAssetFailed, mapCard); break; case MapCardType.Box: BoxTableSetting boxTable = BoxTableSettings.Get(mapcardId); //model = ModelTableSettings.Get(boxTable.ModelId); mapCard = new MapCardBox(); mapCard.Position = pos; mapCard.State = MapCardBase.CardState.Behind; mapCard.CardType = mapCardType; mapCard.TableData = mapCardTable; ResourceManager.LoadGameObject(model.Path, LoadAssetSuccessess, LoadAssetFailed, mapCard); break; case MapCardType.NPC: NpcTableSetting npcTable = NpcTableSettings.Get(mapcardId); //model = ModelTableSettings.Get(npcTable.ModelId); mapCard = new MapCardNpc(); mapCard.Position = pos; mapCard.State = MapCardBase.CardState.Behind; mapCard.CardType = mapCardType; mapCard.TableData = mapCardTable; ResourceManager.LoadGameObject(model.Path, LoadAssetSuccessess, LoadAssetFailed, mapCard); break; default: break; } return(mapCard); }