Beispiel #1
0
 private void NetworkMove(EntityInfo info)
 {
     if (aibase == null)
     {
         aibase = gameObject.GetComponent <AIBase>();
     }
     if (aibase != null)
     {
         var aiState = aibase.GetAI().state;
         if (aiState != null && aiState.type == AIStateEnum.IDLE)
         {
             var curPos = transform.position;
             var tarPos = NetworkUtil.FloatPos(info.X, info.Y, info.Z);
             var vdir   = tarPos - curPos;
             if (vdir.sqrMagnitude >= 2)
             {
                 transform.position = tarPos;
             }
         }
     }
 }
Beispiel #2
0
        public override void NetworkAttribute(GCPlayerCmd cmd)
        {
            var info = cmd.AvatarInfo;

            if (attr == null)
            {
                attr = GetComponent <NpcAttribute>();
            }

            Log.Net("OtherSync: " + info);
            if (info == null)
            {
                Debug.LogError("NetMatchInfo is Null ");
                return;
            }
            NetworkMove(info);

            //服务器通知瞬间传送位置
            if (info.ResetPos)
            {
                if (aiBase != null)
                {
                    aiBase.GetAI().ChangeState(AIStateEnum.IDLE);
                }

                var netPos = MobaUtil.FloatPos(info);
                transform.position = netPos;
                positions.Clear();
            }


            if (info.HasTeamColor)
            {
                attr.SetTeamColorNet(info.TeamColor);
                curInfo.TeamColor = info.TeamColor;
            }
            if (info.HasIsMaster)
            {
                attr.SetIsMasterNet(info.IsMaster);
                curInfo.IsMaster = info.IsMaster;
            }

            var dataChanged = false;
            var skillCount  = curInfo.KillCount;

            if (info.HasKillCount)
            {
                skillCount        = info.KillCount;
                curInfo.KillCount = info.KillCount;
                dataChanged       = true;
            }

            var deadCount = curInfo.DeadCount;

            if (info.HasDeadCount)
            {
                deadCount         = info.DeadCount;
                curInfo.DeadCount = info.DeadCount;
                dataChanged       = true;
            }

            var secondaryAttackCount = curInfo.SecondaryAttackCount;

            if (info.HasSecondaryAttackCount)
            {
                secondaryAttackCount         = info.SecondaryAttackCount;
                curInfo.SecondaryAttackCount = info.SecondaryAttackCount;
                dataChanged = true;
            }

            if (info.HasScore)
            {
                curInfo.Score = info.Score;
                dataChanged   = true;
            }

            if (dataChanged)
            {
                var sid = attr.GetNetView().GetServerID();
                ScoreManager.Instance.NetSyncScore(sid, curInfo.Score, sid, skillCount, deadCount, secondaryAttackCount);
            }

            if (info.HasContinueKilled)
            {
                curInfo.ContinueKilled = info.ContinueKilled;
                if (curInfo.ContinueKilled > 0)
                {
                }
            }
            if (info.HasPlayerModelInGame && curInfo.PlayerModelInGame != info.PlayerModelInGame)
            {
                curInfo.PlayerModelInGame = info.PlayerModelInGame;
                GetComponent <MobaModelLoader>().LoadModel(curInfo.PlayerModelInGame);
                var unitData = Util.GetUnitData(true, curInfo.PlayerModelInGame, 0);
                attr.SetObjUnitData(unitData);

                //SkillDataController.skillDataController.InitSkillShotAfterSelectSkill(curInfo.PlayerModelInGame);
            }
            if (info.HasHP)
            {
                curInfo.HP = info.HP;
                attr.SetHPNet(info.HP);
            }
            if (info.HasLevel)
            {
                curInfo.Level = info.Level;
                attr.ChangeLevel(info.Level);
            }
            if (info.HasState)
            {
                curInfo.State = info.State;
            }
        }