コード例 #1
0
    //if (SceneManager.GetActiveScene().name != GameLibrary.UI_Major
    //    && SceneManager.GetActiveScene().name != GameLibrary.LGhuangyuan
    //    && SceneManager.GetActiveScene().name != GameLibrary.PVP_1V1)
    //    return false;



    //其他玩家行走消息
    public bool OtherPlayerWalkHandle(CReadPacket packet)
    {
        //if (SceneManager.GetActiveScene().name != GameLibrary.UI_Major
        //    && SceneManager.GetActiveScene().name != GameLibrary.LGhuangyuan
        //    && SceneManager.GetActiveScene().name != GameLibrary.PVP_1V1)
        //    return false;
        Dictionary <string, object> data = packet.data;
        long     fg       = long.Parse(data["fg"].ToString());
        long     ky       = long.Parse(data["ky"].ToString());
        int      si       = int.Parse(data["si"].ToString());
        RoleInfo roleInfo = null;

        if (playerData.GetInstance().NearRIarr.ContainsKey(ky))//其他玩家
        {
            roleInfo = playerData.GetInstance().NearRIarr[ky];
        }


        if ((fg & (long)(UpdatePlayerInfoType.Position)) > 0)
        {
            if (roleInfo != null)
            {
                roleInfo.posX = float.Parse(data["px"].ToString());
                roleInfo.posY = float.Parse(data["py"].ToString());
                roleInfo.posZ = float.Parse(data["pz"].ToString());
                if (roleInfo.accID != 0)
                {
                    Debug.Log("其他玩家同步消息" + roleInfo);
                }


                if (FSDataNodeTable <MapInfoNode> .GetSingleton().DataNodeList.ContainsKey(si))
                {
                    MapInfoNode tempMN = FSDataNodeTable <MapInfoNode> .GetSingleton().DataNodeList[si];

                    if (tempMN != null)
                    {
                        roleInfo.posX = float.Parse(data["px"].ToString()) + tempMN.Xmin;
                        roleInfo.posZ = float.Parse(data["pz"].ToString()) + tempMN.Zmin;
                    }
                }
                if (ky != playerData.GetInstance().selfData.keyId)
                {
                    CreatePeople.GetInstance().MoveOtherObject(ky,
                                                               roleInfo.posX, roleInfo.posY, roleInfo.posZ,
                                                               // packet.GetInt("rc"));
                                                               int.Parse(data["tp"].ToString()));
                }
            }
        }
        //朝向
        if ((fg & (long)(UpdatePlayerInfoType.Orientation)) > 0)
        {
            if (data.ContainsKey("hp"))
            {
                //    //  MapInfoNode tempMN = FSDataNodeTable<MapInfoNode>.GetSingleton().DataNodeList[int.Parse(data["si"].ToString())];
                CreatePeople.GetInstance().ChangeOtherHp(ky, int.Parse(data["hp"].ToString()));
            }
            else
            {
                if (roleInfo != null)
                {
                    roleInfo.orientX = float.Parse(data["ox"].ToString());
                    roleInfo.orientY = float.Parse(data["oy"].ToString());
                    roleInfo.orientZ = float.Parse(data["oz"].ToString());
                    if (ky != playerData.GetInstance().selfData.keyId)
                    {
                        CreatePeople.GetInstance().SetOtherPlayerOrientation(ky,
                                                                             roleInfo.posX, roleInfo.posY, roleInfo.posZ
                                                                             );
                        int.Parse(data["tp"].ToString());
                    }
                }
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.heroId)) > 0)
        {
            if (roleInfo != null)//其他玩家
            {
                if (roleInfo.roleID != packet.GetUint32("ri"))
                {
                    roleInfo.roleID = packet.GetUint32("ri");
                    GameObject.Destroy(roleInfo.RoleObj);
                    // if(roleInfo)
                    CreatePeople.GetInstance().CreateOtherPlayer(ref roleInfo, false);
                }
            }
            else//玩家自己
            {
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.UnionId)) > 0)//公会id
        {
            if (playerData.GetInstance().NearRIarr.ContainsKey(ky))
            {
                playerData.GetInstance().NearRIarr[ky].unionId = packet.GetUint32("unId");
            }

            // playerData.GetInstance().NearRIarr[ky].unionName = packet.GetString("unNm");
            // playerData.GetInstance().NearRIarr[ky].RoleObj.
        }
        if ((fg & (long)(UpdatePlayerInfoType.UnionName)) > 0)//公会id
        {
            if (playerData.GetInstance().NearRIarr.ContainsKey(ky))
            {
                playerData.GetInstance().NearRIarr[ky].unionName = packet.GetString("unNm");
            }
            if (playerData.GetInstance().NearRIarr.ContainsKey(ky))
            {
                playerData.GetInstance().NearRIarr[ky].unionName = packet.GetString("unNm");

                if (playerData.GetInstance().NearRIarr.ContainsKey(ky))
                {
                    RoleInfo   ri      = playerData.GetInstance().NearRIarr[ky];
                    GameObject tempObj = ri.RoleObj;
                    if (ri.accID != 0)//刷新其他玩家的公会名称
                    {
                        OtherPlayer otherPlayer = tempObj.GetComponent <OtherPlayer>();
                        if (otherPlayer != null)
                        {
                            if (Singleton <SceneManage> .Instance.Current == EnumSceneID.UI_MajorCity01)
                            {
                                otherPlayer.RefreshSocietyName(packet.GetString("unNm"));
                            }
                        }
                    }
                    ri = null;
                }
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.Pet)) > 0)//宠物状态更新
        {
            if (playerData.GetInstance().NearRIarr.ContainsKey(ky))
            {
                playerData.GetInstance().NearRIarr[ky].petid = packet.GetLong("pt");
                CreatePeople.GetInstance().UpdateOtherPlayerInfo(ky, UpdatePlayerInfoType.Pet);
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.Mount)) > 0)//宠物状态更新
        {
            if (playerData.GetInstance().NearRIarr.ContainsKey(ky))
            {
                playerData.GetInstance().NearRIarr[ky].mount = packet.GetLong("mt");
                CreatePeople.GetInstance().UpdateOtherPlayerInfo(ky, UpdatePlayerInfoType.Mount);
            }
        }

        //血量更新
        if ((fg & (long)(UpdatePlayerInfoType.Hp)) > 0)
        {
            if (playerData.GetInstance().NearRIarr.ContainsKey(ky))
            {
                MapInfoNode tempMN = FSDataNodeTable <MapInfoNode> .GetSingleton().DataNodeList[int.Parse(data["si"].ToString())];

                CreatePeople.GetInstance().ChangeOtherHp(ky, packet.GetInt("hp"));
            }
            else
            {
                //自己的血量同步
                if (ky == playerData.GetInstance().selfData.keyId)
                {
                    int count = packet.GetInt("hp");
                    if (CharacterManager.playerCS != null)
                    {
                        CharacterManager.playerCS.ChangeHp(count);
                    }
                    if (playerData.GetInstance().selfData.hp < count)
                    {
                        playerData.GetInstance().selfData.hp = count;
                    }
                }
            }
        }

        if ((fg & (long)(UpdatePlayerInfoType.Title)) > 0) //称号更新
        {
            if (data.ContainsKey("tl"))                    //称号更新
            {
                //if(playerData.GetInstance().NearRIarr.ContainsKey(ky))
                //{
                //    playerData.GetInstance().NearRIarr[ky].title = int.Parse(data["tl"].ToString());

                //    if (playerData.GetInstance().NearRIarr.ContainsKey(ky))
                //    {
                //        RoleInfo ri = playerData.GetInstance().NearRIarr[ky];
                //        GameObject tempObj = ri.RoleObj;
                //        if (ri.accID != 0)//刷新其他玩家的称号
                //        {
                //            OtherPlayer otherPlayer = tempObj.GetComponent<OtherPlayer>();
                //            if (otherPlayer!=null)
                //            {
                //                if (FSDataNodeTable<TitleNode>.GetSingleton().DataNodeList.ContainsKey(int.Parse(data["tl"].ToString())))
                //                {
                //                    string playerTitleName = FSDataNodeTable<TitleNode>.GetSingleton().DataNodeList[int.Parse(data["tl"].ToString())].titlename;
                //                    if (Singleton<SceneManage>.Instance.Current == EnumSceneID.UI_MajorCity01)
                //                    {
                //                        otherPlayer.RefreshTitleName(playerTitleName);
                //                    }
                //                }
                //            }
                //        }
                //        ri = null;

                //    }

                //}
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.Vitality)) > 0)//体力更新
        {
            if (ky == playerData.GetInstance().selfData.keyId)
            {
                if (data.ContainsKey("vt"))//体力更新
                {
                    playerData.GetInstance().baginfo.strength = int.Parse(data["vt"].ToString());
                    if (data.ContainsKey("mtwt"))
                    {
                        playerData.GetInstance().actionData.energyRecoverEndTime = long.Parse(data["mtwt"].ToString());
                    }
                    playerData.GetInstance().InitActionData();
                    playerData.GetInstance().ActionPointHandler(ActionPointType.Energy, playerData.GetInstance().baginfo.strength);
                }
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.RedPoint)) > 0) //红点更新
        {
            if (data.ContainsKey("rd"))                       //红点更新
            {
                if (data.ContainsKey("rd"))
                {
                    Dictionary <string, object> redData = data["rd"] as Dictionary <string, object>;
                    if (redData != null)
                    {
                        foreach (KeyValuePair <string, object> keyValuePair in redData)
                        {
                            int[]      arr     = keyValuePair.Value as int[];
                            List <int> temList = null;
                            if (arr != null && arr.Length > 0)
                            {
                                temList = new List <int>();
                                temList.AddRange(arr);
                                //for (int i = 0; i < arr.Length; i++)
                                //{
                                //    temList.Add(arr[i]);
                                //}
                            }
                            Singleton <RedPointManager> .Instance.Add((EnumRedPoint)(int.Parse(keyValuePair.Key)), temList);
                        }
                        Singleton <RedPointManager> .Instance.NotifyChange();
                    }
                }
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.Gold)) > 0)//金币更新
        {
            if (ky == playerData.GetInstance().selfData.keyId)
            {
                if (data.ContainsKey("gd"))//金币更新
                {
                    long a = long.Parse(data["gd"].ToString());
                    playerData.GetInstance().RoleMoneyHadler(MoneyType.Gold, a);
                }
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.Diamond)) > 0)//钻石更新
        {
            if (ky == playerData.GetInstance().selfData.keyId)
            {
                if (data.ContainsKey("dd"))//钻石更新
                {
                    long a = long.Parse(data["dd"].ToString());
                    playerData.GetInstance().RoleMoneyHadler(MoneyType.Diamond, a);
                }
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.PvpCoin)) > 0)//角斗场币更新
        {
            if (ky == playerData.GetInstance().selfData.keyId)
            {
                if (data.ContainsKey("ppc"))//角斗场更新
                {
                    long a = long.Parse(data["ppc"].ToString());
                    playerData.GetInstance().RoleMoneyHadler(MoneyType.PVPcoin, a);
                }
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.ArenaCoin)) > 0)//竞技场币更新
        {
            if (ky == playerData.GetInstance().selfData.keyId)
            {
                if (data.ContainsKey("ac"))//竞技场币更新
                {
                    long a = long.Parse(data["ac"].ToString());
                    playerData.GetInstance().RoleMoneyHadler(MoneyType.AreanCoin, a);
                }
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.PveCoin)) > 0)//远征币更新
        {
            if (ky == playerData.GetInstance().selfData.keyId)
            {
                if (data.ContainsKey("pec"))//远征币更新
                {
                    long a = long.Parse(data["pec"].ToString());
                    playerData.GetInstance().RoleMoneyHadler(MoneyType.PVEcion, a);
                }
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.Exp)) > 0)//人物经验更新
        {
            if (ky == playerData.GetInstance().selfData.keyId)
            {
                long a = 0; long b = 0;
                if (data.ContainsKey("ep"))                 //战斗经验
                {
                    a = long.Parse(data["ep"].ToString());  //当前经验
                }
                if (data.ContainsKey("plv"))                //战队等级
                {
                    b = long.Parse(data["plv"].ToString()); //当前等级
                }
                playerData.GetInstance().RoleLvAndExpHandler((int)b, (int)a);
            }
        }
        if ((fg & (long)(UpdatePlayerInfoType.RewardCoin)) > 0)//悬赏币更新
        {
            if (ky == playerData.GetInstance().selfData.keyId)
            {
                if (data.ContainsKey("rc"))//悬赏币更新
                {
                    long a = long.Parse(data["rc"].ToString());
                    playerData.GetInstance().RoleMoneyHadler(MoneyType.RewardCoin, a);
                }
            }
        }
        return(true);
    }