Beispiel #1
0
    public void StartTimer(string data)
    {
        GameStarting info = JsonUtility.FromJson <GameStarting>(data);

        GameManager.instance.Log.text += "game-starting " + info.starts_in + Environment.NewLine;
        GameManager.instance.StartTimer(info.starts_in);
    }
        private void Go_Click(object sender, RoutedEventArgs e)
        {
            List <string> names = null;

            names = spTextboxes.Children.OfType <TextBox>()
                    .Where(texbox => texbox.Name.StartsWith("tbxP"))
                    .Select(texbox => texbox.Text).ToList <string>();

            GameStarting?.Invoke(names);
        }
Beispiel #3
0
        public void StartGame()
        {
            var playingPlayers = GetAllLobbyPlayers().Where(x => x.PlayerPosition != PlayerPosition.Spectator).ToList();

            if (playingPlayers.Count < 2)
            {
                throw new InvalidActionException("Not enough players.");
            }

            _server.OnClientConnected   -= ServerOnOnClientConnected;
            _server.OnClientDisonnected -= ServerOnOnClientDisonnected; // TODO: postarat se o tyto handlery

            foreach (var lobbyPlayer in GetAllLobbyPlayers().Where(x => x.PlayerHandler != null))
            {
                lobbyPlayer.PlayerHandler.GameStarting();
            }

            // Game updaters
            var gameUpdaters = new List <IGameUpdater>();
            var localGame    = new LocalGame(_hostPlayer.PlayerId);

            gameUpdaters.Add(localGame);
            foreach (var lobbyPlayer in GetAllLobbyPlayers().Where(x => x.PlayerHandler != null))
            {
                gameUpdaters.Add(new RemoteGameUpdater(lobbyPlayer.PlayerHandler.Receiver));
            }

            var board        = new BoardFactory().CreateBoard();
            var gameSettings = new GameSettings();

            // Build the game manager
            var gameManager = new GameManager(board, gameSettings, new MultipleGameUpdater(gameUpdaters), GetAllLobbyPlayers());

            gameManager.DiceRolling = new DiceRolling(gameManager);
            gameManager.TurnLogic   = new TurnLogic(gameManager);
            gameManager.Start();

            var hostPlayer = gameManager.Players.Find(x => x.PlayerId == _hostPlayer.PlayerId);

            if (hostPlayer == null)
            {
                throw new FatalGameException("Invalid host player id");
            }

            var hostPlayerController = new LocalPlayerController(hostPlayer);

            localGame.SetPlayerController(hostPlayerController);

            GameStarting?.Invoke(localGame);
        }
Beispiel #4
0
 private Task HandleResponseAsync(Response response, CancellationToken ct)
 {
     return(response switch
     {
         PlayerRegistered playerRegistered => OnPlayerRegistered(playerRegistered, ct),
         MapUpdated mapUpdated => OnMapUpdated(mapUpdated, ct),
         GameLink gameLink => OnGameLink(gameLink),
         GameStarting gameStarting => OnGameStarting(gameStarting),
         GameResult gameResult => OnInfoEvent(gameResult),
         CharacterStunned characterStunned => OnInfoEvent(characterStunned),
         HeartBeatResponse heartBeatResponse => OnHearBeatEvent(heartBeatResponse, ct),
         GameEnded gameEnded => OnGameEnded(gameEnded),
         TournamentEnded tournamentEnded => OnTournamentEnded(tournamentEnded),
         InvalidPlayerName invalidPlayerName => OnInfoEvent(invalidPlayerName),
         _ => Task.CompletedTask
     });
Beispiel #5
0
    private IEnumerator StartGameDelayed()
    {
        retriesLeft = MAX_RETRIES;
        GameStarting?.Invoke(this, null);

        yield return(new WaitUntil(() => IsUILoaded));

        IsGameStarted = true;
        //GameTime = Time.time;
        Globals.CurrentStartTime = Time.time;

        Time.timeScale = 1f;

        GameStarted?.Invoke(this, null);

        this.RemoveCoroutine(nameof(StartGameDelayed));
    }
Beispiel #6
0
        public void Join(string playerName, string ip, int port)
        {
            if (_gameClient != null)
            {
                return;
            }

            _gameClient = new GameClient();
            _gameClient.Disconnected        += () => Disconnected?.Invoke();
            _gameClient.LobbyException      += GameClientOnLobbyException;
            _gameClient.SetMyPlayerId       += GameClientOnSetMyPlayerId;
            _gameClient.LobbyPlayersUpdated += GameClientOnLobbyPlayersUpdated;
            _gameClient.ChatServerMessage   += GameClientOnChatServerMessage;
            _gameClient.ChatPlayerMessage   += GameClientOnChatPlayerMessage;
            _gameClient.GameStarting        += starting => GameStarting?.Invoke(new RemoteGame(_gameClient, _myPlayerId));

            _gameClient.Join(playerName, ip, port);
        }
Beispiel #7
0
 private void OnGameStarting(GameStarting gameStarting)
 {
     GameStarting?.Invoke(gameStarting);
 }
 protected virtual void OnGameStarting(GameStartingEventArgs args)
 {
     GameStarting?.Invoke(this, args);
 }
Beispiel #9
0
 void OnGameStarting(bool starting, Turn turn, string opponentConnectionId, string opponentUserName)
 {
     Connection.Current.Status.OpponentDetails = (opponentUserName, opponentConnectionId);
     GameStarting?.Invoke(starting, turn);
 }
Beispiel #10
0
    IEnumerator WaitForKinect()
    {
        Debug.Log("Waiting for Kinect");
        calibrationImage.fillAmount    = 0;
        calibrationCompletionRate.text = (Mathf.CeilToInt(calibrationImage.fillAmount * 100)).ToString() + "%";
        kinectMan.ClearKinectUsers();
        bool calibrateKinect = true;

        //kinectWaitingScreen.SetActive(true);
        //kinect.StartAcquiringTargetBody();

#if ENABLE_CALIBRATION
        yield return(new WaitUntil(() => kinectMan.IsUserDetected()));
#endif
        while (calibrationImage.fillAmount < 1f)
        {
#if ENABLE_CALIBRATION
            calibrateKinect = kinectMan.IsUserDetected();
#endif
            if (!calibrateKinect)
            {
                Debug.Log("Break waiting for Kinect coroutine");
                //set fill to 0;
                //restart calibration in 0.5s;
                startCalibration();
                calibrationImage.DOFillAmount(0.0f, 0.2f);
                calibrationText.text = "CALIBRATION WAS INTERRUPTED!";
                yield break;
            }
            if (calibrationImage != null)
            {
                calibrationImage.fillAmount = calibrationImage.fillAmount + 0.01f;
                calibrationImage.color      = Color.Lerp(Color.white, new Color(1.0f, 1.0f, 1.0f), calibrationImage.fillAmount);
            }
            calibrationCompletionRate.text = (Mathf.CeilToInt(calibrationImage.fillAmount * 100)).ToString() + "%";
            if (calibrationText != null)
            {
                calibrationText.text = calibrationImage.fillAmount < 0.3f ? "IN PROGRESS..." :
                                       calibrationImage.fillAmount < 0.5f ? "HALFWAY THERE!" :
                                       calibrationImage.fillAmount < 0.95f ? "JUST A LITTLE MORE!" : "COMPLETED!";
            }

            yield return(new WaitForSeconds(0.02f));
        }

        if (calibrationImageParent != null)
        {
            calibrationImageParent.transform.DOPunchScale(new Vector3(0.1f, 0.1f), 0.5f, 5, 0.5f);
        }
        //if (calibrationText != null)
        //    calibrationText.transform.DOLocalJump(calibrationText.transform.localPosition, 100f, 1, 0.4f);

        TrinaxManager.trinaxAudioManager.PlayUISFX(TrinaxAudioManager.AUDIOS.CALIBRATION_DONE, TrinaxAudioManager.AUDIOPLAYER.UI_SFX);

        yield return(new WaitForSeconds(1.5f));

        CalibrationCanvas.DOFade(0, 0.2f).OnComplete(() =>
        {
            CalibrationCanvas.blocksRaycasts = false;
            CalibrationCanvas.gameObject.SetActive(false);
        });

        yield return(new WaitForSeconds(0.65f));

        Debug.Log("Calibration Complete");
        calibrated = true;
        GameStarting?.Invoke();
    }