void Start()
    {
        platformerInputState = new PlatformerCharacterInputState();
        platformerInputState.isJumpRequested = false;
        platformerInputState.walkDirection   = PlatformerWalkDirection.None;

        platformerState = new PlatformerCharacterState();
    }
 public static void Update(PlatformerCharacterInputState inputState, PlatformerCharacterState characterState)
 {
     if (inputState.isJumpRequested)
     {
         characterState.jumpRequest  = inputState.wasJumpRequested? PlatformerJumpRequest.Continued : PlatformerJumpRequest.Requested;
         inputState.wasJumpRequested = true;
     }
     else
     {
         characterState.jumpRequest  = PlatformerJumpRequest.None;
         inputState.wasJumpRequested = false;
     }
     characterState.walkRequest = inputState.walkDirection;
 }
예제 #3
0
 public MessageHandler RegisterNetwork(MessageHandler send, PlatformerCharacterConfig config, string guid, float trustDistance)
 {
     this.trustDistance   = trustDistance;
     platformerInputState = new PlatformerCharacterInputState();
     platformerInputState.isJumpRequested = false;
     platformerInputState.walkDirection   = PlatformerWalkDirection.None;
     playerInputState        = new PlayerInputState(platformerInputState);
     inputMessage.playerGuid = guid;
     inputMessage.state      = playerInputState.platformerState;
     this.platformerConfig   = config;
     this.networkSend        = send;
     return((opCode, message) => {
         if (opCode == OpCode.PLAYER_POSITION)
         {
             UpdateForServerPosition(((PositionMessage)message).position);
         }
         else if (opCode == OpCode.PLAYER_INPUT)
         {
             UpdateForServerPosition(((PlayerInputMessage)message).position.toVector());
         }
         return 1;
     });
 }
 public PlayerInputState(PlatformerCharacterInputState platformerState)
 {
     this.oldState        = new PlatformerCharacterInputState();
     this.platformerState = platformerState;
     this.platformerState.CopyTo(oldState);
 }
 public bool Equals(PlatformerCharacterInputState other)
 {
     return(walkDirection == other.walkDirection && isJumpRequested == other.isJumpRequested);
 }
 public void CopyTo(PlatformerCharacterInputState other)
 {
     other.walkDirection   = walkDirection;
     other.isJumpRequested = isJumpRequested;
 }