protected void AddExp(PBPlayerData playerData, int exp) { LevelTableSetting levelTable = LevelTableSettings.Get(playerData.Level); if (levelTable == null) { return; } exp = exp + playerData.Exp; int maxExp = levelTable.Exp[ClassCharacterTableSettings.Get(playerData.CharacterId).ClassType]; while (exp >= maxExp) { //level Up! playerData.Level++; exp = exp - maxExp; levelTable = LevelTableSettings.Get(playerData.Level); if (levelTable == null) { break; } playerData.Hp = levelTable.HP[(int)MapMgr.Instance.MyMapPlayer.Data.ClassData.Type]; playerData.MaxHp = levelTable.HP[(int)MapMgr.Instance.MyMapPlayer.Data.ClassData.Type]; playerData.Mp = levelTable.MP[(int)MapMgr.Instance.MyMapPlayer.Data.ClassData.Type]; playerData.MaxMp = levelTable.MP[(int)MapMgr.Instance.MyMapPlayer.Data.ClassData.Type]; maxExp = levelTable.Exp[(int)MapMgr.Instance.MyMapPlayer.Data.ClassData.Type]; } playerData.Exp = exp; }
public void Update(PBPlayerData playerData) { ID = playerData.PlayerId; Level = playerData.Level; ClassData = new ClassData(playerData.CharacterId); LevelTableSetting levelData = LevelTableSettings.Get(Level); if (levelData == null) { return; } Name = playerData.Name; HP = playerData.Hp; MaxHP = playerData.MaxHp; MP = playerData.Mp; MaxMP = playerData.MaxMp; Food = playerData.Food; MaxFood = playerData.MaxFood; Gold = playerData.Gold; HeadIcon = playerData.HeadIcon; MapSkillID = playerData.MapSkillId; BattleSkillID = playerData.BattleSkillId; Exp = playerData.Exp; }
public void Update(PBMapPlayerData mapPlayerData) { if (Id != mapPlayerData.PlayerData.PlayerId) { Debug.LogError(Id + "不是一个玩家的数据!" + mapPlayerData.PlayerData.PlayerId); return; } PlayerData playerData = new PlayerData(); playerData.Update(mapPlayerData.PlayerData); if (playerData == null) { return; } Name = playerData.Name; Level = playerData.Level; Exp = playerData.Exp; LevelTableSetting levelTable = LevelTableSettings.Get(Level); if (levelTable != null) { MaxExp = levelTable.Exp[(int)playerData.ClassData.Type]; } HP = playerData.HP; MaxHP = playerData.MaxHP; MP = playerData.MP; MaxMP = playerData.MaxMP; HeadIcon = playerData.HeadIcon; MapSkillID = playerData.MapSkillID; BattleSkillID = playerData.BattleSkillID; UsingCharacter = playerData.UsingCharacter; Food = playerData.Food; MaxFood = playerData.MaxFood; Gold = playerData.Gold; for (int i = 0; i < mapPlayerData.Equips.Count; i++) { m_EquipList.Add(new NormalCard(mapPlayerData.Equips[i], false)); } for (int i = 0; i < mapPlayerData.Buffs.Count; i++) { m_BuffList.Add(new NormalCard(mapPlayerData.Buffs[i], false)); } m_Deck = new Deck(mapPlayerData.Deck); m_CardList = m_Deck.Cards; for (int i = 0; i < mapPlayerData.Items.Count; i++) { m_ItemList.Add(new ItemData(mapPlayerData.Items[i])); } ClassData = playerData.ClassData; }
public void AddExp(int exp) { LevelTableSetting levelTable = LevelTableSettings.Get(Data.Level); Data.Exp += exp; while (Data.Exp >= levelTable.Exp[(int)Data.ClassData.Type]) { Data.Level++; Data.Exp -= levelTable.Exp[(int)Data.ClassData.Type]; levelTable = LevelTableSettings.Get(Data.Level); } Data.MaxExp = levelTable.Exp[(int)Data.ClassData.Type]; Messenger.Broadcast(MessageId.MAP_UPDATE_PLAYER_EXP); }
public MapPlayerData(PlayerData playerData, PlayerDetailData playerDetailData) { if (playerData == null) { return; } this.playerData = playerData; Id = playerData.ID; Name = playerData.Name; Level = playerData.Level; Exp = playerData.Exp; LevelTableSetting levelTable = LevelTableSettings.Get(Level); if (levelTable != null) { MaxExp = levelTable.Exp[(int)playerData.ClassData.Type]; } HP = playerData.HP; MaxHP = playerData.MaxHP; MP = playerData.MP; MaxMP = playerData.MaxMP; HeadIcon = playerData.HeadIcon; MapSkillID = playerData.MapSkillID; BattleSkillID = playerData.BattleSkillID; UsingCharacter = playerData.UsingCharacter; Food = playerData.Food; MaxFood = playerData.MaxFood; Gold = playerData.Gold; if (playerDetailData != null) { m_EquipList = new List <NormalCard>(playerDetailData.EquipList); m_BuffList = new List <NormalCard>(playerDetailData.BuffList); m_CardList = new List <NormalCard>(playerDetailData.CardList); ClassData = playerData.ClassData; } }
public override void Handle(object sender, IMessage packet) { base.Handle(sender, packet); CGCreatePlayer data = packet as CGCreatePlayer; //处理完数据和逻辑后,发送消息通知客户端 GCSignIn userData = new GCSignIn(); userData.Uid = data.UserId; ClassCharacterTableSetting characterData = ClassCharacterTableSettings.Get(data.CharacterId); if (characterData == null) { return; } userData.AccountData = GetSavedData <PBAccountData>(ACCOUNT_DATA_KEY); if (userData.AccountData == null) { userData.AccountData = new PBAccountData(); userData.AccountData.Uid = data.UserId; userData.AccountData.Recharge = 0; userData.AccountData.Diamonds = 0; userData.AccountData.VipLevel = 0; SaveData(ACCOUNT_DATA_KEY, userData.AccountData); } userData.PlayerData = GetSavedData <PBPlayerData>(PLAYER_DATA_KEY); if (userData.PlayerData == null) { userData.PlayerData = new PBPlayerData(); userData.PlayerData.PlayerId = 1; userData.PlayerData.Level = 1; userData.PlayerData.CharacterId = data.CharacterId; ClassData classData = new ClassData(data.CharacterId); LevelTableSetting levelData = LevelTableSettings.Get(userData.PlayerData.Level); if (levelData == null) { return; } userData.PlayerData.Food = 10; userData.PlayerData.Gold = 0; //userData.PlayerData.Name = data.Name; userData.PlayerData.Name = I18N.Get(characterData.Name); userData.PlayerData.Hp = userData.PlayerData.MaxHp = levelData.HP[(int)classData.Type]; userData.PlayerData.Mp = userData.PlayerData.MaxMp = levelData.MP[(int)classData.Type]; userData.PlayerData.HeadIcon = characterData.IconID; SaveData(PLAYER_DATA_KEY, userData.PlayerData); } userData.PlayerDetailData = GetSavedData <PBPlayerDetailData>(PLAYER_DETAIL_DATA_KEY); if (userData.PlayerDetailData == null) { //PlayerDetailData = MyPlayer.DetailData; //PlayerDetailData.Deck = new Deck(); //for (int i = 0; i < characterData.DefaultCardList.Count; i++) //{ // NormalCard normalCard = new NormalCard(characterData.DefaultCardList[i], uidIndex++); // MyPlayer.Data.CardList.Add(normalCard); // PlayerDetailData.Kaku.Add(normalCard); // PlayerDetailData.Deck.AddCard(normalCard); //} userData.PlayerDetailData = new PBPlayerDetailData(); userData.PlayerDetailData.Cards.AddRange(characterData.DefaultCardList); PBDeck deck = new PBDeck(); deck.Cards.AddRange(characterData.DefaultCardList); userData.PlayerDetailData.UsingDeckIndex = deck.Index = 1; deck.MaxCount = 10; deck.Name = "默认卡组"; userData.PlayerDetailData.Decks.Add(deck); SaveData(PLAYER_DETAIL_DATA_KEY, userData.PlayerDetailData); } SendToClient(MessageId_Receive.GCSignIn, userData); }
private void LoadRewardList() { if (rewardData.AddedExp > 0) { goExp.SetActive(true); int maxExp = 0; int level = rewardData.OldLevel; int exp = rewardData.OldExp + rewardData.AddedExp; LevelTableSetting levelTable = LevelTableSettings.Get(level); if (levelTable == null) { return; } maxExp = levelTable.Exp[(int)MapMgr.Instance.MyMapPlayer.Data.ClassData.Type]; while (exp >= maxExp) { //level Up! level++; exp = exp - maxExp; levelTable = LevelTableSettings.Get(level); if (levelTable == null) { break; } maxExp = levelTable.Exp[(int)MapMgr.Instance.MyMapPlayer.Data.ClassData.Type]; } lblLevel.text = level.ToString(); lblExp.text = exp + " / " + maxExp; sliderExp.value = Mathf.Max(0.001f, (float)exp / (float)maxExp); } else { goExp.SetActive(false); } if (rewardData.Gold != 0) { goGold.SetActive(true); lblGold.text = rewardData.Gold.ToString(); } else { goGold.SetActive(false); } if (rewardData.Diamond != 0) { goDiamond.SetActive(true); lblDiamond.text = rewardData.Diamond.ToString(); } else { goDiamond.SetActive(false); } if (rewardData.Food != 0) { goFood.SetActive(true); lblFood.text = rewardData.Food.ToString(); } else { goFood.SetActive(false); } gridGold.Reposition(); foreach (var card in rewardData.Items) { if (card == 0) { continue; } UIUtility.GetNormalCard(gridItems.transform, card, 1); } gridItems.repositionNow = true; }