internal void UpdatePlayerMovement(ProjectXServer.Messages.PlayerMoveRequest msg) { Player _p = FindNetPlayer(msg.ClientID); if (_p != null) { _p.Target = new Vector2(msg.Target[0], msg.Target[1]); _p.AddActionSet("Launch", CharacterState.Launch, CharacterActionSetChangeFactor.AnimationCompleted, null); _p.AddActionSet("Moving", CharacterState.Moving, CharacterActionSetChangeFactor.ArriveTarget, _p.Target); _p.AddActionSet("Landing", CharacterState.Landing, CharacterActionSetChangeFactor.AnimationCompleted, null); _p.AddActionSet("Idle", CharacterState.Idle, CharacterActionSetChangeFactor.AnimationCompleted, null); } }
internal void UpdatePlayerTarget(ProjectXServer.Messages.PlayerTargetChanged msg) { Player _p = FindNetPlayer(msg.ClientID); if (_p != null) { _p.Target = new Vector2(msg.Target[0], msg.Target[1]); } }
public void UpdatePlayerPosition(ProjectXServer.Messages.PlayerPositionUpdate msg) { Player _p = null; if (msg.ClientID == localplayer.ClientID) { _p = localplayer; } else { _p = FindNetPlayer(msg.ClientID); } if (_p != null) { //由于网络包会先到,所以最后会导致netplayer的target和position重合 //也就无法根据之间的距离差来求出最后人物停止的方向 //所以这里做个小的调整,根据服务器计算出的人物朝向来将人物位置稍微调整一下 _p.Position = new Vector2(msg.Position[0] - (float)(msg.Dir) * 0.001f, msg.Position[1]); if (msg.State == (int)CharacterState.Correct) { //_p.ClearActionSet(); _p.AddActionSet("Idle", CharacterState.Idle, CharacterActionSetChangeFactor.Immediate, null); } if (_p == localplayer) _p.UpdateSceneScroll(); } }