Ejemplo n.º 1
0
    //迭代加权平滑 弹簧 物理运动平滑手段
    private Vector3 GetInfoPredictPos(AvatarInfo p1)
    {
        var passTime = NetworkScene.Instance.GetPredictPassServerTime(p1.FrameID);
        var speed    = NetworkUtil.FloatPos(p1.SpeedX, 0, p1.SpeedY);

        if (passTime > 0)
        {
            return(MobaUtil.FloatPos(p1) + speed * (passTime + Util.FrameSecTime));
        }
        else
        {
            return(MobaUtil.FloatPos(p1) + speed * Util.FrameSecTime);
        }
    }
Ejemplo n.º 2
0
 //预测其它玩家的控制位置
 //服务器上的FrameId 都是整数
 //客户端的FrameId是浮点数
 //计算得到这一阵结束时候的位置
 public override Vector3 GetServerPos()
 {
     if (NetworkScene.Instance != null)
     {
         if (positions.Count > 0)
         {
             return(MobaUtil.FloatPos(curInfo));
         }
         else
         {
             return(MobaUtil.FloatPos(curInfo));
         }
     }
     else
     {
         return(transform.position);
     }
 }
Ejemplo n.º 3
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;
        }
    }
Ejemplo n.º 4
0
 public override Vector3 GetCurInfoPos()
 {
     return(MobaUtil.FloatPos(curInfo));
 }