public uint Execute(PacketDistributed ipacket)
        {
            GC_CREATEROLE_RET packet = (GC_CREATEROLE_RET)ipacket;

            if (null == packet)
            {
                return((uint)PACKET_EXE.PACKET_EXE_ERROR);
            }
            if (packet.Result == (int)GC_CREATEROLE_RET.CREATEROLE_RESULT.CREATEROLE_SUCCESS)
            {
                LoginData.loginRoleList.Add(new LoginData.PlayerRoleData(packet.PlayerGuid, packet.Profession, packet.PlayerName, 1, -1, -1, -1));
                PlatformHelper.OnRoleCreate(packet.PlayerName, "1");
                UserConfigData.AddRoleInfo();
                LoginData.UpdateLoginRoleInfo(packet.PlayerGuid);
                // LoginData.UpdateLoginRoleInfo中会重置职业,在此重新赋值(过场动画会根据职业进行设置)
                GameManager.gameManager.PlayerDataPool.EnterSceneCache.Profession = packet.Profession;
                //第一次创建角色新手关默认启用一个特殊技能
                Utils.SetPVXSkillIndexByProfession(packet.Profession);
            }
            else
            {
                if (null != retCreateRoleFail)
                {
                    retCreateRoleFail((GC_CREATEROLE_RET.CREATEROLE_RESULT)packet.Result);
                }
            }

            return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
        }
Exemple #2
0
    public static void UpdateLoginData(GC_LOGIN_RET data)
    {
        if (data.Result == (int)GC_LOGIN_RET.LOGINRESULT.SUCCESS)
        {
            LoginData.accountData.SetAccountInfo(data.Userid, data.Oid, data.Accesstoken, data.Rapidvalidatecode);
            LoginData.loginRoleList.Clear();
            for (int i = 0; i < data.roleGUIDListCount; i++)
            {
                LoginData.loginRoleList.Add(new LoginData.PlayerRoleData(
                                                data.roleGUIDListList[i],
                                                data.roleTypeListList[i],
                                                data.playerNameListList[i],
                                                data.roleLevelListList[i] > 0 ? data.roleLevelListList[i] : 1,
                                                data.ModelVisualIDList[i],
                                                data.WeaponIDList[i],
                                                data.WeaponEffectGemList[i]));
            }
            LoginData.loginRoleList.Sort();
            UserConfigData.AddRoleInfo();
        }

        if (retLogin != null)
        {
            retLogin((GC_LOGIN_RET.LOGINRESULT)data.Result, data.Validateresult);
        }
    }
        public uint Execute(PacketDistributed ipacket)
        {
            GC_SYN_ATTR packet = (GC_SYN_ATTR)ipacket;

            if (null == packet)
            {
                return((uint)PACKET_EXE.PACKET_EXE_ERROR);
            }
            //enter your logic
            //判断是MainPlayer还是其他Obj
            Obj_MainPlayer _mainPlayer = Singleton <ObjManager> .GetInstance().MainPlayer;

            PlayerData playerDataPool = GameManager.gameManager.PlayerDataPool;

            //血量
            bool isHpChange = false;

            if (packet.HasCurHp)
            {
                playerDataPool.MainPlayerBaseAttr.HP = packet.CurHp;
                isHpChange = true;
            }
            if (packet.HasMaxHP)
            {
                playerDataPool.MainPlayerBaseAttr.MaxHP = packet.MaxHP;
#if UNITY_ANDROID
                // 台湾安卓渠道特有,提交血量排行榜数据
                if (PlatformHelper.IsChannelTW())
                {
                    PlatformHelper.SubmitRankScore(Games.GlobeDefine.GameDefine_Globe.GOOGLEPLAY_RANK_TYPE.HP, playerDataPool.MainPlayerBaseAttr.MaxHP);
                }
#endif
                isHpChange = true;
            }
            if (isHpChange && _mainPlayer != null)
            {
                _mainPlayer.OptHPChange();
            }
            //法力
            bool isMpChange = false;
            if (packet.HasCurMp)
            {
                playerDataPool.MainPlayerBaseAttr.MP = packet.CurMp;
                isMpChange = true;
            }
            if (packet.HasMaxMP)
            {
                playerDataPool.MainPlayerBaseAttr.MaxMP = packet.MaxMP;
                isMpChange = true;
            }
            if (isMpChange && _mainPlayer != null)
            {
                _mainPlayer.OptMPChange();
            }

            //怒气
            bool isXpChange = false;
            if (packet.HasCurXp)
            {
                playerDataPool.MainPlayerBaseAttr.XP = packet.CurXp;
                isXpChange = true;
            }
            if (packet.HasMaxXP)
            {
                playerDataPool.MainPlayerBaseAttr.MaxXP = packet.MaxXP;
                isXpChange = true;
            }
            if (isXpChange && _mainPlayer != null)
            {
                _mainPlayer.OptXPChange();
            }

            //等级
            if (packet.HasCurLev)
            {
                // 更新配置文件

                playerDataPool.MainPlayerBaseAttr.Level = packet.CurLev;
                if (_mainPlayer)
                {
                    for (int i = 0; i < LoginData.loginRoleList.Count; i++)
                    {
                        if (LoginData.loginRoleList[i].guid == _mainPlayer.GUID)
                        {
                            LoginData.loginRoleList[i].level = packet.CurLev;
                            UserConfigData.AddRoleInfo();
                            break;
                        }
                    }

                    _mainPlayer.OptLevelChange();

                    if (LivingSkillLogic.Instance() != null)
                    {
                        LivingSkillLogic.Instance().UpdatePlayerStamina();
                    }
                    _mainPlayer.UpdateSelectDrug();
                }
            }
            // 经验
            if (packet.HasCurExp)
            {
                playerDataPool.MainPlayerBaseAttr.Exp = packet.CurExp;
                if (_mainPlayer)
                {
                    _mainPlayer.OnExpChange();
                }
                //神器强化界面
                if (EquipShenQiStrength.Instance() != null)
                {
                    EquipShenQiStrength.Instance().UpdateExpShow();
                }
            }
            if (packet.HasOffLineExp)
            {
                playerDataPool.MainPlayerBaseAttr.OffLineExp = packet.OffLineExp;
                if (null != _mainPlayer)
                {
                    _mainPlayer.OnOffLineExpChange();
                }
            }
            //体能
            if (packet.HasCurStamina)
            {
                playerDataPool.MainPlayerBaseAttr.CurStamina = packet.CurStamina;

                if (LivingSkillLogic.Instance() != null)
                {
                    LivingSkillLogic.Instance().UpdatePlayerStamina();
                }
            }
            //金钱
            if (packet.HasCurMoney)
            {
                playerDataPool.Money.SetMoney(MONEYTYPE.MONEYTYPE_COIN, packet.CurMoney);
#if UNITY_ANDROID
                // 台湾安卓渠道特有,提交金币排行榜数据
                if (PlatformHelper.IsChannelTW())
                {
                    PlatformHelper.SubmitRankScore(Games.GlobeDefine.GameDefine_Globe.GOOGLEPLAY_RANK_TYPE.GOLD_COINS, packet.CurMoney);
                }
#endif
                if (BackPackLogic.Instance())
                {
                    BackPackLogic.Instance().UpdateMoneyInfo();
                }

                if (FlyWingRoot.Instance())
                {
                    FlyWingRoot.Instance().UpdateMoneyInfo();
                }
//                if (SwordsManController.Instance() != null)
//                {
//                    SwordsManController.Instance().UpdateCoin();
//                }
                if (CangKuLogic.Instance())
                {
                    CangKuLogic.Instance().UpdateBackPack_Money();
                }
                //神器强化界面
                if (EquipShenQiStrength.Instance() != null)
                {
                    EquipShenQiStrength.Instance().UpdateMoneyShow();
                }
                if (GemLogic.Instance() != null)
                {
                    GemLogic.Instance().UpdateMoneyInfo();
                }
                if (null != GUIData.delMoneyChanged)
                {
                    GUIData.delMoneyChanged();
                }

                if (RestaurantController.Instance() != null)
                {
                    RestaurantController.Instance().UpdateMoneyInfo();
                }

                if (EquipStrengthenLogic.Instance() != null)
                {
                    EquipStrengthenLogic.Instance().UpdateMoneyInfo();
                }

                if (SkillLevelUpRoot.Instance() != null)
                {
                    SkillLevelUpRoot.Instance().UpdateSkillInfo();
                }
            }

            //元宝
            if (packet.HasCurYuanBao)
            {
                playerDataPool.Money.SetMoney(MONEYTYPE.MONEYTYPE_YUANBAO, packet.CurYuanBao);
                if (BackPackLogic.Instance())
                {
                    BackPackLogic.Instance().UpdateMoneyInfo();
                }
                if (YuanBaoShopLogic.Instance())
                {
                    YuanBaoShopLogic.Instance().UpdateYuanBaoInfo();
                }
                if (DailyLuckyDrawLogic.Instance())
                {
                    DailyLuckyDrawLogic.Instance().UpdateMoney();
                }
                if (CangKuLogic.Instance())
                {
                    CangKuLogic.Instance().UpdateBackPack_Money();
                }
                //神器强化界面
                if (EquipShenQiStrength.Instance() != null)
                {
                    EquipShenQiStrength.Instance().UpdateMoneyShow();
                }
                if (null != GUIData.delMoneyChanged)
                {
                    GUIData.delMoneyChanged();
                }
            }

            //绑定元宝
            if (packet.HasCurBDYuanBao)
            {
                playerDataPool.Money.SetMoney(MONEYTYPE.MONEYTYPE_YUANBAO_BIND, packet.CurBDYuanBao);
                if (FashionLogic.Instance() != null)
                {
                    FashionLogic.Instance().UpdateRuby();
                }
                if (BackPackLogic.Instance())
                {
                    BackPackLogic.Instance().UpdateMoneyInfo();
                }
                if (YuanBaoShopLogic.Instance())
                {
                    YuanBaoShopLogic.Instance().UpdateYuanBaoInfo();
                }
                if (DailyLuckyDrawLogic.Instance())
                {
                    DailyLuckyDrawLogic.Instance().UpdateMoney();
                }
                if (CangKuLogic.Instance())
                {
                    CangKuLogic.Instance().UpdateBackPack_Money();
                }
                if (RestaurantController.Instance() != null)
                {
                    RestaurantController.Instance().UpdateMoneyInfo();
                }
                if (null != GUIData.delMoneyChanged)
                {
                    GUIData.delMoneyChanged();
                }
            }
//            if (packet.HasSwordsManScore)
//            {
//                playerDataPool.SwordsManScore = packet.SwordsManScore;
//                if (SwordsManController.Instance() != null)
//                {
//                    SwordsManController.Instance().UpdateSwordsManScore();
//                }
//            }

            if (packet.HasReputation)
            {
                playerDataPool.Reputation = packet.Reputation;
            }

            //是否在战斗状态
            if (packet.HasIsInCombat && _mainPlayer != null)
            {
                bool oldCombat = _mainPlayer.InCombat;
                _mainPlayer.InCombat = (packet.IsInCombat == 1 ? true:false);
                if (!_mainPlayer.InCombat && oldCombat)
                {
                    _mainPlayer.LastLeaveCombatTime = Time.time;
                }
                else if (_mainPlayer.InCombat && !oldCombat)
                {
                    _mainPlayer.LastLeaveCombatTime = 0.0f;
                }
            }
            //经验 血 蓝 变化时 更新主角属性界面
            if (packet.HasCurHp || packet.HasCurMp || packet.HasCurExp)
            {
                if (RoleViewLogic.Instance() != null)
                {
                    RoleViewLogic.Instance().UpdateCurAttr();
                }
            }

            if (packet.HasGuildDKP)
            {
                playerDataPool.GuildDKP = packet.GuildDKP;
                if (GuildShopLogic.Instance() != null)
                {
                    GuildShopLogic.Instance().UpdateGuildDKP();
                }
            }
            return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
        }