Ejemplo n.º 1
0
    public override void NetworkAttribute(GCPlayerCmd cmd)
    {
        var info = cmd.AvatarInfo;

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

        Log.Net("MySelfSync: " + 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;
        }
    }