예제 #1
0
    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();
    }
예제 #2
0
    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);
    }
예제 #3
0
    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);
    }