private void Start() { networkManager = GameObject.Find("NetworkManager"); networkConnector = networkManager.GetComponent <MonoTcpNetworkConnector>(); messageProcessor = networkManager.GetComponent <MonoClientMessageProcessor>(); userLobbyObject = networkManager.GetComponent <UserLobbyObject>(); int number = userLobbyObject.GetJoinedLobby().Users.FindIndex(x => x.Name == userLobbyObject.GetLoggedInUser().Name); gameService = new GameService(networkConnector, messageProcessor, userLobbyObject); setPlayerGameObject(number); setPlayerScripts(); }
public async void MovementToServerAsync() { BattleTanks.Domain.Entities.Tank tank = new BattleTanks.Domain.Entities.Tank(userLobbyObject.GetLoggedInUser().Id, (int)Math.Round(playerTank.transform.position.x), (int)Math.Round(playerTank.transform.position.y), (int)Math.Round(playerTank.transform.position.z), (int)Math.Round(playerTank.transform.rotation.x), (int)Math.Round(playerTank.transform.position.y)); await gameService.MoveTankAsync(tank); }
public async Task MoveTankAsync(Tank tank) { TankMovementCommand tankMovementCommand = new TankMovementCommand(Guid.NewGuid(), _userLobbyObject.GetJoinedLobby().Name, tank, _userLobbyObject.GetLoggedInUser().Id); await _networkConnector.SendMessageAsync(tankMovementCommand, CancellationToken.None); }