void Update() { if (_running && _player.CanMove) { bool send = false; // check if the player can move in the direction requested. if not make them face that direction if (Input.GetKey(KeyCode.DownArrow)) { if (_map.CanMove(_player.Position + Player.DIR_DOWN)) { _player.MoveTo(PlayerDirection.Down); send = true; } else { _player.Face(PlayerDirection.Down); } } else if (Input.GetKey(KeyCode.LeftArrow)) { if (_map.CanMove(_player.Position + Player.DIR_LEFT)) { _player.MoveTo(PlayerDirection.Left); send = true; } else { _player.Face(PlayerDirection.Left); } } else if (Input.GetKey(KeyCode.RightArrow)) { if (_map.CanMove(_player.Position + Player.DIR_RIGHT)) { _player.MoveTo(PlayerDirection.Right); send = true; } else { _player.Face(PlayerDirection.Right); } } else if (Input.GetKey(KeyCode.UpArrow)) { if (_map.CanMove(_player.Position + Player.DIR_UP)) { _player.MoveTo(PlayerDirection.Up); send = true; } else { _player.Face(PlayerDirection.Up); } } // let the server know this player is moving to a new map cell if (send) { PsObject psobj = new PsObject(); psobj.SetIntArray(ServerConstants.PLAYER_POSITION, Utility.Vector2ToList(_player.Target)); _server.SendRequest(new ExtensionRequest(PlayerCommand.GetCommand(PlayerCommand.PlayerEnum.Move), psobj)); } } // shoot a fireball if (Input.GetKey(KeyCode.Space) && _player.CanShoot) { _player.Shoot(); // let the server know this player shot something PsObject psobj = new PsObject(); psobj.SetIntArray(ServerConstants.PLAYER_POSITION, Utility.Vector2ToList(_player.Target)); psobj.SetIntArray(ServerConstants.PLAYER_HEADING, Utility.Vector2ToList(_player.GetDirectionVector())); _server.SendRequest(new ExtensionRequest(PlayerCommand.GetCommand(PlayerCommand.PlayerEnum.Shoot), psobj)); } }