Beispiel #1
0
 void Awake()
 {
     GameLibrary.playerstate = 0;//重置为游戏状态
     instance = this;
     //获取当前场景名字
     mCurActiveSceneName = SceneManager.GetActiveScene().name;
     //创建人物后 添加任务自动寻路脚本
     if (transform.gameObject.GetComponent <TaskAutoTraceManager>() == null)
     {
         transform.gameObject.AddComponent <TaskAutoTraceManager>();
     }
     if (stateobj == null)
     {
         stateobj = Resources.Load <GameObject>("Prefab/UIPanel/" + "NpcTaskState") as GameObject;
     }
     if (headtipobj == null)
     {
         headtipobj = Resources.Load <GameObject>("Prefab/UIPanel/" + "NpcHeadTip") as GameObject;
     }
     if (GameLibrary.Instance().CheckSceneNeedSync(mCurActiveSceneName) && CreatePeople.GetInstance() != null &&
         transform.parent != null && CreatePeople.GetInstance().transform.localPosition != Vector3.zero)
     {
         CreatePeople.GetInstance().transform.localPosition = transform.parent.localPosition;
     }
 }
Beispiel #2
0
    //怪物打人
    public bool MonsterAttackHandle(CReadPacket packet)
    {
        Dictionary <string, object> data = packet.data;
        uint attackKeyId = uint.Parse(data["sk"].ToString());
        uint targetKeyId = uint.Parse(data["tk"].ToString());
        int  skillId     = int.Parse(data["sd"].ToString());

        CreatePeople.GetInstance().MonsterAttack(attackKeyId, targetKeyId, skillId);
        return(true);
    }
Beispiel #3
0
    public void SendAttack(uint targetKeyId, int skillIndex)
    {
        MapInfoNode tempMN;

        if (isSend(out tempMN))
        {
            CWritePacket packet = new CWritePacket(MessageID.s_player_attack_req);
            Dictionary <string, object> newpacket = new Dictionary <string, object>();
            newpacket.Add("msgid", ( ushort )MessageID.s_player_attack_req);
            newpacket.Add("tk", System.UInt32.Parse(targetKeyId.ToString()));
            newpacket.Add("sd", System.Int32.Parse(skillIndex.ToString()));
            GameObject playerobj = CharacterManager.player;
            if (playerobj != null)
            {
                newpacket.Add("sx", playerobj.transform.position.x);//自己的位置
                newpacket.Add("sy", playerobj.transform.position.y);
                newpacket.Add("sz", playerobj.transform.position.z);
                newpacket.Add("dx", playerobj.transform.rotation.x);//自己的朝向
                newpacket.Add("dy", playerobj.transform.rotation.y);
                newpacket.Add("dz", playerobj.transform.rotation.z);
            }
            else
            {
                newpacket.Add("sx", 0);//自己的位置
                newpacket.Add("sy", 0);
                newpacket.Add("sz", 0);
                newpacket.Add("dx", 0);//自己的朝向
                newpacket.Add("dy", 0);
                newpacket.Add("dz", 0);
            }
            GameObject obj = CreatePeople.GetInstance().GetTargert(targetKeyId);
            if (targetKeyId != 0)
            {
                if (obj != null)
                {
                    newpacket.Add("tx", obj.transform.position.x);//目标位置
                    newpacket.Add("ty", obj.transform.position.y);
                    newpacket.Add("tz", obj.transform.position.z);
                }
            }
            else
            {
                if (playerobj != null)
                {
                    newpacket.Add("tx", playerobj.transform.position.x);//目标位置
                    newpacket.Add("ty", playerobj.transform.position.y);
                    newpacket.Add("tz", playerobj.transform.position.z);
                }
            }

            Send(newpacket, packet);
        }
    }
Beispiel #4
0
    public void CreateNearElement()
    {
        RoleInfo ri;

        foreach (RoleInfo ritem in playerData.GetInstance().NearRIarr.Values)
        {
            ri = ritem;
            if (ri.RoleObj == null)
            {
                CreatePeople.GetInstance().CreatOtherObject(ref ri);
            }
        }
    }
Beispiel #5
0
    public bool HpHandle(CReadPacket packet)
    {
        Dictionary <string, object> data = packet.data;
        uint  attackKeyId = uint.Parse(data["sk"].ToString());
        uint  targetKeyId = uint.Parse(data["tk"].ToString());
        int   hp          = int.Parse(data["hp"].ToString());
        int   skillId     = int.Parse(data["sd"].ToString());
        float baseValue   = float.Parse(data["bv"].ToString());

        CreatePeople.GetInstance().OtherObjectDamage(attackKeyId, targetKeyId, hp, skillId, baseValue);

        return(true);
    }
Beispiel #6
0
 void DoConcludeRi(RoleInfo ri)
 {
     if (playerData.GetInstance().NearRIarr[ri.keyID].RoleObj != null)
     {
         // GameObject.Destroy(playerData.GetInstance().NearRIarr[ri.keyID].RoleObj);
         CreatePeople.GetInstance().DeleteOtherObject(ri.keyID);
     }
     else
     {
         //RoleInfo oldri = playerData.GetInstance().NearRIarr[ri.keyID];
         //oldri.name = ri.name;
         //oldri.
         playerData.GetInstance().NearRIarr.Remove(ri.keyID);
     }
 }
Beispiel #7
0
    //删除其他玩家
    public bool DeleteOtherPlayerHandle(CReadPacket packet)
    {
        Dictionary <string, object> data = packet.data;

        Int32[] str = data["dl"] as Int32[];
        if (str != null)
        {
            for (int i = 0; i < str.Length; i++)
            {
                CreatePeople.GetInstance().DeleteOtherObject(UInt32.Parse(str[i].ToString()));
            }
            return(true);
        }
        else
        {
            Int64[] strarr = data["dl"] as Int64[];
            if (strarr != null)
            {
                for (int i = 0; i < strarr.Length; i++)
                {
                    CreatePeople.GetInstance().DeleteOtherObject(UInt32.Parse(strarr[i].ToString()));
                }
                return(true);
            }
            else
            {
                object[] strobjarr = data["dl"] as object[];
                if (strobjarr != null)
                {
                    for (int i = 0; i < strobjarr.Length; i++)
                    {
                        CreatePeople.GetInstance().DeleteOtherObject(UInt32.Parse(strobjarr[i].ToString()));
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
    }
Beispiel #8
0
    //场景中其他物体行走消息
    public bool ScenceElementWalkHandle(CReadPacket packet)
    {
        Dictionary <string, object> data = packet.data;
        long fg = long.Parse(data["fg"].ToString());

        if ((fg & (long)(UpdateMapElementInfoType.Position)) > 0)
        {
            MapInfoNode tempMN = FSDataNodeTable <MapInfoNode> .GetSingleton().DataNodeList[int.Parse(data["si"].ToString())];

            CreatePeople.GetInstance().MoveOtherObject(uint.Parse(data["ky"].ToString()),
                                                       float.Parse(data["px"].ToString()) + tempMN.Xmin,
                                                       float.Parse(data["py"].ToString()),
                                                       float.Parse(data["pz"].ToString()) + tempMN.Zmin,
                                                       int.Parse(data["rc"].ToString())

                                                       );
            int.Parse(data["tp"].ToString());
        }


        return(true);
    }
Beispiel #9
0
    //人物攻击表现
    public bool AttackHandle(CReadPacket packet)
    {
        Dictionary <string, object> data = packet.data;
        uint    attackKeyId = uint.Parse(data["sk"].ToString());
        uint    targetKeyId = uint.Parse(data["tk"].ToString()); //目标id
        int     skillIndex  = int.Parse(data["sd"].ToString());  //技能索引
        Vector3 pos         = new Vector3(                       //玩家位置
            packet.GetFloat("px"),
            packet.GetFloat("py"),
            packet.GetFloat("pz"));
        Vector3 Rot = new Vector3(//玩家朝向
            packet.GetFloat("ox"),
            packet.GetFloat("oy"),
            packet.GetFloat("oz"));
        Vector3 tpos = new Vector3(//目标位置
            packet.GetFloat("tx"),
            packet.GetFloat("ty"),
            packet.GetFloat("tz"));

        AttackType attackType = AttackType.action;

        if (CreatePeople.GetInstance().MonsterDic.ContainsKey(targetKeyId))
        {
            attackType = AttackType.Monster;
        }

        if (CreatePeople.GetInstance().OtherplayerDic.ContainsKey(targetKeyId) || targetKeyId == 0)
        {
            attackType = AttackType.OtherPlayer;
        }
        if (playerData.GetInstance().selfData.keyId == targetKeyId)
        {
            attackType = AttackType.Player;
        }
        CreatePeople.GetInstance().OtherPlayerAttack(attackKeyId, targetKeyId, attackType, skillIndex, pos, Rot, tpos);
        return(true);
    }
Beispiel #10
0
    public bool DeadHandle(CReadPacket packet)
    {
        Dictionary <string, object> data = packet.data;
        uint attackKeyId = uint.Parse(data["sk"].ToString());
        uint targetKeyId = uint.Parse(data["tk"].ToString());
        int  rc          = int.Parse(data["rc"].ToString());

        if (targetKeyId == 0 || targetKeyId == playerData.GetInstance().selfData.keyId)//自己死亡
        {
            CharacterManager.player.GetComponent <CharacterState>().SetDead();
            if (Singleton <SceneManage> .Instance.Current == EnumSceneID.LGhuangyuan)
            {
                if (UIDeadToReborn.GetInstance() != null)
                {
                    UIDeadToReborn.GetInstance().show();
                }
            }
        }
        else//其他人死亡
        {
            CreatePeople.GetInstance().OtherObjectDead(targetKeyId);
        }
        return(true);
    }
Beispiel #11
0
    public void CreateTownPlayer()
    {
        if (player != null)
        {
            if (SceneManager.GetActiveScene().name == GameLibrary.UI_Major)
            {
                transform.localPosition = Vector3.zero;

                mPos = playerData.GetInstance().selfData.GetPos();
            }
            else if (SceneManager.GetActiveScene().name == GameLibrary.LGhuangyuan)
            {
                mPos = FSDataNodeTable <TransferTableNode> .GetSingleton().DataNodeList[4294713000].toPos;

                mRot = player.transform.localRotation;
            }
            else if (SceneManager.GetActiveScene().name == GameLibrary.PVP_1V1)
            {
                mPos = playerData.GetInstance().selfData.GetPos();
            }
            else
            {
                mPos = player.transform.localPosition;
            }

            mScale = player.transform.localScale;
            if (player != null)
            {
                mPos = player.transform.localPosition;
                Destroy(player);
            }
        }
        else
        {
            transform.localPosition = Vector3.zero;

            mPos = playerData.GetInstance().selfData.GetPos();
        }
        HeroData defaultHd = DefaultMainHeroData();

        GameObject     go = Resource.CreateCharacter(defaultHd.node.icon_name, gameObject);
        CharacterState cs = BattleUtil.AddMoveComponents(go, defaultHd.attrNode.modelNode);

        cs.pm.nav.obstacleAvoidanceType = UnityEngine.AI.ObstacleAvoidanceType.NoObstacleAvoidance;
        cs.InitData(defaultHd);
        SetMainHero(cs);

        player.GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = false;  // 防止生成的模型位置出错
        player.transform.localPosition = mPos;
        player.transform.localRotation = mRot;
        player.GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = true;
        if (mCurActiveSceneName == GameLibrary.UI_Major)
        {
            Debug.Log("Major init player");
            if (!isInit)
            {
                player.transform.parent        = CreatePeople.GetInstance().OhterPlayer.transform;
                player.transform.localPosition = playerData.GetInstance().selfData.GetPos();
                isInit = true;
            }
            //CreateNpc();
            //CreateCollect();
        }
        else if (mCurActiveSceneName == GameLibrary.LGhuangyuan || mCurActiveSceneName == GameLibrary.PVP_1V1)
        {
            Debug.Log(mCurActiveSceneName + " init player");
            if (!isInit)
            {
                player.transform.parent        = CreatePeople.GetInstance().OhterPlayer.transform;
                player.transform.localPosition = playerData.GetInstance().selfData.GetPos();
                isInit = true;
            }
            //是野外向服务器同步血量
            CharacterState csp = player.GetComponent <CharacterState>();
            if (csp != null)
            {
                csp.InitData(Globe.Heros()[0]);
                csp.keyId        = playerData.GetInstance().selfData.keyId;
                csp.isNetworking = true;
                ClientSendDataMgr.GetSingle().GetWalkSend().SendSetPlayerHp(csp.maxHp);
                playerData.GetInstance().selfData.hp = csp.maxHp;
            }
            UnityUtil.AddComponetIfNull <SummonHero>(csp.gameObject);
        }
        if (!GameLibrary.Instance().isLoadOtherPepole)
        {
            if (SceneManager.GetActiveScene().name == GameLibrary.UI_Major ||
                SceneManager.GetActiveScene().name == GameLibrary.LGhuangyuan ||
                SceneManager.GetActiveScene().name == GameLibrary.PVP_1V1
                )
            {
                Debug.Log(" =====>CreateOthers");
                CreateNearElement();
                GameLibrary.Instance().isLoadOtherPepole = true;
            }
        }
        if (player != null)
        {
            if (player.transform.GetComponent <SetMainHeroName>() == null)
            {
                player.transform.gameObject.AddComponent <SetMainHeroName>();
            }
        }
        GameLibrary.isSkipingScene = false;
        //if (MiniMap.instance != null)
        //    MiniMap.instance.CreateTargetPos(player, ShowType.player);
    }
Beispiel #12
0
    //玩家复活消息
    public bool ReVive(CReadPacket packet)
    {
        Dictionary <string, object> data = packet.data;
        int    hp         = packet.GetInt("hp");
        UInt32 sorkey     = packet.GetUint32("sk");
        UInt32 tarkey     = packet.GetUint32("tk");
        int    reviewtype = packet.GetInt("rt");

        if (tarkey == playerData.GetInstance().selfData.keyId)//目标是自己
        {
            //if ( CreatePeople.GetInstance().GetTargert( sorkey ) == null )//发起者是自己
            {
                CharacterState cs = null;
                if (CharacterManager.player != null)
                {
                    cs = CharacterManager.player.GetComponent <CharacterState>();
                    if (cs != null)
                    {
                        cs.SetBorn(hp);
                    }
                }
            }
        }
        else
        {
            if (CreatePeople.GetInstance().OtherplayerDic.ContainsKey(tarkey))
            {
                GameObject obj = CreatePeople.GetInstance().OtherplayerDic[tarkey];
                if (obj != null)
                {
                    CharacterState cs = obj.GetComponent <CharacterState>();
                    if (cs != null)
                    {
                        cs.SetBorn(hp);
                    }
                }
                //CreatePeople.GetInstance().OtherplayerDic.Remove(tarkey);
                //GameObject.Destroy(obj);
                //if (playerData.GetInstance().NearRIarr.ContainsKey(tarkey))
                //{
                //    playerData.GetInstance().NearRIarr.Remove(tarkey);
                //}
            }

            //if( playerData.GetInstance().NearRIarr.ContainsKey(tarkey))
            // {
            //     RoleInfo ri = playerData.GetInstance().NearRIarr[tarkey];
            //     ri.hp = (short)hp;
            //     //if(ri.RoleObj!=null)
            //     //{
            //     //    GameObject.Destroy(ri.RoleObj);
            //     //}
            // }
            //CharacterState cs = null;
            //GameObject obj = CreatePeople.GetInstance().GetTargert(tarkey);
            //if (obj != null)
            //{
            //    cs = obj.GetComponent<CharacterState>();
            //    if (cs != null)
            //    {
            //        cs.SetBorn(hp);
            //    }
            //}
        }
        return(false);
    }
Beispiel #13
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);
    }
Beispiel #14
0
    //其他玩家行走消息
    public bool ScenceMapWalkHandle(CReadPacket packet)
    {
        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.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;
                    }
                }
            }
        }

        return(true);
    }
Beispiel #15
0
    //创建场景中的物体
    public bool AddOtherPlayerHandle(CReadPacket packet)
    {
        if (playerData.GetInstance().NearRIarr.Count > 20)
        {
            Debug.Log(packet.ToString());
            return(false);
        }

        Dictionary <string, object> data = packet.data;

        object[] alDatas = data["al"] as object[];//addlist

        if (alDatas != null)
        {
            // Debug.Log("al===>" + alDatas.Length);
            for (int i = 0; i < alDatas.Length; i++)
            {
                Dictionary <string, object> playerInfo = (Dictionary <string, object>)alDatas[i];
                if (CreatePeople.GetInstance() == null)
                {
                    return(false);
                }
                long     key = long.Parse(playerInfo["ky"].ToString());
                RoleInfo ri  = CreateRoleInfo(playerInfo);
                if (playerData.GetInstance().NearRIarr.ContainsKey(ri.keyID))
                {
                    //如果已经包含了,是否把新的数据更新过来

                    DoConcludeRi(ri);
                }

                playerData.GetInstance().NearRIarr.Add(ri.keyID, ri);

                if (SceneManager.GetActiveScene().name != GameLibrary.UI_Major &&
                    SceneManager.GetActiveScene().name != GameLibrary.LGhuangyuan &&
                    SceneManager.GetActiveScene().name != GameLibrary.PVP_1V1
                    )
                {
                    if (GameLibrary.Instance().isLoadOtherPepole)
                    {
                        GameLibrary.Instance().isLoadOtherPepole = false;
                    }
                    // return false;
                }
                else
                {
                    if (ri.accID == 0)//
                    {
                        CreatePeople.GetInstance().CreatOtherObject(ref ri);
                    }
                    else//其他玩家
                    {
                        if (!CreatePeople.GetInstance().OtherplayerDic.ContainsKey(key))
                        {
                            Debug.Log("创建其他玩家");
                            CreatePeople.GetInstance().CreatOtherObject(ref ri);
                        }
                        else
                        {
                            Debug.Log("玩家已在列表里");
                        }
                    }


                    if (playerData.GetInstance().NearRIarr.ContainsKey(key))
                    {
                        if (playerInfo.ContainsKey("pt"))
                        {
                            playerData.GetInstance().NearRIarr[key].petid = Convert.ToInt64(playerInfo["pt"]);
                            CreatePeople.GetInstance().UpdateOtherPlayerInfo(key, UpdatePlayerInfoType.Pet);
                        }
                        if (playerInfo.ContainsKey("mt"))
                        {
                            playerData.GetInstance().NearRIarr[key].mount = Convert.ToInt64(playerInfo["mt"]);
                            CreatePeople.GetInstance().UpdateOtherPlayerInfo(key, UpdatePlayerInfoType.Mount);
                        }
                    }
                }
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }