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 CreateModel(MapCardPos pos = null) { if (CurPos == null) { CurPos = pos; } ResourceManager.LoadGameObject(ModelTableSettings.Get(ClassCharacterTableSettings.Get(m_Data.ClassData.CharacterID).ModelID).Path, LoadPlayerSuccess, (str, obj) => { Debug.LogError("Load player Failed!"); } ); }
public void InitPlayer(PBPlayerData playerData, PBPlayerDetailData playerDetailData) { ClassCharacterTableSetting characterData = ClassCharacterTableSettings.Get(playerData.CharacterId); if (characterData == null) { return; } MyPlayer = new MyPlayer(); PlayerData = MyPlayer.Data; MyPlayer.Data.Update(playerData); MyPlayer.DetailData.Update(playerDetailData); PlayerDetailData = MyPlayer.DetailData; }
public ClassData(int characterID) { this.characterID = characterID; characterTable = ClassCharacterTableSettings.Get(characterID); if (characterTable == null) { Debug.LogError("character id = " + characterID + " is not exist!"); } type = (ClassType)characterTable.ClassType; classTable = ClassTableSettings.Get((int)type); if (classTable == null) { Debug.LogError("class type = [" + type.ToString() + "] is not exist!"); } }
public void UpdatePlayer(PBPlayerData playerData, PBPlayerDetailData playerDetailData) { ClassCharacterTableSetting characterData = ClassCharacterTableSettings.Get(playerData.CharacterId); if (characterData == null) { return; } if (playerData != null) { MyPlayer.Data.Update(playerData); } if (playerDetailData != null) { MyPlayer.DetailData.Update(playerDetailData); } }
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); }
public override void Handle(object sender, IMessage packet) { base.Handle(sender, packet); CGEnterInstance data = packet as CGEnterInstance; //处理完数据和逻辑后,发送消息通知客户端 GCEnterInstance response = new GCEnterInstance(); InstanceTableSetting instanceTable = InstanceTableSettings.Get(data.InstanceId); if (instanceTable == null) { response.Result = 1; SendToClient(MessageId_Receive.GCEnterInstance, response); return; } response.InstanceId = data.InstanceId; response.Result = 0; response.MapPlayerData = new PBMapPlayerData(); response.MapPlayerData.InstanceId = data.InstanceId; response.MapPlayerData.PlayerPosX = Random.Range(0, instanceTable.Width); response.MapPlayerData.PlayerPosY = Random.Range(0, instanceTable.Height); PBPlayerData playerData = GetSavedData <PBPlayerData>(PLAYER_DATA_KEY); response.MapPlayerData.PlayerData = new PBPlayerData(); response.MapPlayerData.PlayerData.PlayerId = playerData.PlayerId; response.MapPlayerData.PlayerData.Hp = playerData.Hp; response.MapPlayerData.PlayerData.MaxHp = playerData.MaxHp; response.MapPlayerData.PlayerData.Mp = playerData.Mp; response.MapPlayerData.PlayerData.MaxMp = playerData.MaxMp; response.MapPlayerData.PlayerData.Gold = 0; response.MapPlayerData.PlayerData.Exp = 0; response.MapPlayerData.PlayerData.Level = 1; response.MapPlayerData.PlayerData.CharacterId = playerData.CharacterId; response.MapPlayerData.PlayerData.HeadIcon = playerData.HeadIcon; response.MapPlayerData.PlayerData.MapSkillId = playerData.MapSkillId; response.MapPlayerData.PlayerData.BattleSkillId = playerData.BattleSkillId; //response.MapPlayerData.PlayerData.Equips if (playerData.Food > instanceTable.FoodMax) { response.MapPlayerData.PlayerData.Food = response.MapPlayerData.PlayerData.MaxFood = instanceTable.FoodMax; playerData.Food = playerData.Food - instanceTable.FoodMax; } else { response.MapPlayerData.PlayerData.Food = response.MapPlayerData.PlayerData.MaxFood = playerData.Food; playerData.Food = 0; } //response.MapPlayerData.PlayerData response.MapPlayerData.PlayerModelId = ClassCharacterTableSettings.Get(response.MapPlayerData.PlayerData.CharacterId).ModelID; PBPlayerDetailData playerDetailData = GetSavedData <PBPlayerDetailData>(PLAYER_DETAIL_DATA_KEY); bool exist = false; for (int i = 0; i < playerDetailData.Decks.Count; i++) { if (playerDetailData.Decks[i].Index == data.Deck.Index) { //更新已有的卡组 playerDetailData.Decks[i] = data.Deck; exist = true; break; } } //添加新卡组 if (exist == false) { playerDetailData.Decks.Add(data.Deck); } response.MapPlayerData.Deck = data.Deck; response.MapPlayerData.Items.Add(data.Items); response.MapPlayerData.Equips.AddRange(data.Equips); response.MapPlayerData.Buffs.AddRange(data.Buffs); for (int i = 0; i < data.Items.Count; i++) { playerDetailData.Items.Remove(data.Items[i]); } SaveData(PLAYER_DATA_KEY, playerData); SaveData(PLAYER_DETAIL_DATA_KEY, playerDetailData); SaveData(MAP_PLAYER_DATA_KEY, response.MapPlayerData); SendToClient(MessageId_Receive.GCEnterInstance, response); }