public void StartNewGame()
    {
        StopAllCoroutines();
        var camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <MainGameCamera> ();

        camera.Disable();
        if (_boards != null)
        {
            DestroyBoards();
            DestroyPieces();
        }
        _boards     = new Board[3];
        _gameEngine = new GameEngine(_boards);
        State       = GameManagerState.PLAYING;
        Logger      = new Logger();
        CreateBoards();
        InitBoards();
        _overlayManager.ClearLogs();
        _overlayManager.SetLabel(Texts.GetString("WhiteTurnText"), UnityEngine.Color.white);
        _players[0].Init(Color.WHITE, _boards, this);
        _players[1].Init(Color.BLACK, _boards, this);

        //StartCoroutine (Play());
        Play();
    }
 void Start()
 {
     settings = Settings.Instance;
     saveAngleAndPositionText.text         = Texts.GetString("SaveAngleAndPositionText");
     saveAngleAndPositionToggle.isOn       = settings.SaveAngleAndPositionOnBoardChange;
     rotateCameraOnPlayerChangeText.text   = Texts.GetString("RotateCameraOnPlayerChangeText");
     rotateCameraOnPlayerChangeToggle.isOn = settings.RotateCameraOnChangePlayer;
     volumeText.text = Texts.GetString("VolumeText");
     volumeSlider.normalizedValue = settings.SoundVolume;
     toMainMenuText.text          = Texts.GetString("MainMenuButtonText");
 }
    public void SetLabel(string text, UnityEngine.Color c)
    {
        var textElem = infoFrame.GetComponentInChildren <Text> ();

        textElem.text  = text;
        textElem.color = c;

        returnToMenuButton.GetComponentInChildren <Text> ().text       = Texts.GetString("GoToMenuButtonText");
        logButton.GetComponentInChildren <Text> ().text                = Texts.GetString("LogButtonText");
        showCapturedPiecesButton.GetComponentInChildren <Text> ().text = Texts.GetString("CapturedPiecesButtonText");
        goUPButton.GetComponentInChildren <Text> ().text               = Texts.GetString("BoardUpButtonText");
        goDownButton.GetComponentInChildren <Text> ().text             = Texts.GetString("BoardDownButtonText");
        logFrame.GetComponent <LogListGenerator> ().Init(GameManager.Instance.Logger.GetLog());
    }
Exemple #4
0
    void Start()
    {
        startButton.GetComponentInChildren <Text>().text = Texts.GetString("StartGameButtonText");
        startButton.onClick.AddListener(StartGame);

        resumeButton.GetComponentInChildren <Text>().text = Texts.GetString("ResumeGameButtonText");
        resumeButton.onClick.AddListener(ResumeGame);
        resumeButton.interactable = false;

        settingsButton.GetComponentInChildren <Text>().text = Texts.GetString("SettingsButtonText");
        settingsButton.onClick.AddListener(ShowSettings);

        exitButton.GetComponentInChildren <Text>().text = Texts.GetString("ExitButtonText");
        exitButton.onClick.AddListener(Exit);
    }
        public void LaunchSelectedBoatDataRefreshTask()
        {
            StopSelectedBoatDataRefreshTask();

            if (SelectedBoatNumber != null)
            {
                SelectedBoatCancellationTokenSource = new CancellationTokenSource();

                Tasks.RefreshSelectedBoat(SelectedBoatCancellationTokenSource.Token);
                NmeaServer.Start();
                TimeSpan t = TimeSpan.FromMilliseconds(Conf.REQUEST_RATE);
                string humanReadableRate = string.Format("{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms", t.Hours, t.Minutes, t.Seconds, t.Milliseconds);
                MessageHub.PublishAsync(new LogMessage(this, new LogText($"{Texts.GetString("RequestRateInformation")}{humanReadableRate}")));
                MessageHub.PublishAsync(new BoatDataServiceStatusChanged(Global.Instance, true));
            }
        }
    void Start()
    {
        ChoosePlayersText.text = Texts.GetString("ChoosePlayersText");
        WhitePlayerText.text   = Texts.GetString("WhitePlayerText");
        BlackPlayerText.text   = Texts.GetString("BlackPlayerText");
        var HumanText = Texts.GetString("HumanText");

        WhiteHumanText.text = HumanText;
        BlackHumanText.text = HumanText;
        var AIText = Texts.GetString("AIText");

        WhiteAIText.text = AIText;
        BlackAIText.text = AIText;

        WhiteHumanToggle.isOn = true;
        WhiteAIToggle.isOn    = false;
        BlackHumanToggle.isOn = true;
        BlackAIToggle.isOn    = false;

        StartGameButtonText.text = Texts.GetString("StartGameButtonText");
        CancelButtonText.text    = Texts.GetString("CancelButtonText");
    }
 private void NmeaServer_OnNMEASent(string nmea)
 {
     MessageHub.PublishAsync(new LogMessage(this, new LogText($"{Texts.GetString("NMEASent")} {Environment.NewLine}{nmea}", Color.Gray)));
 }
 private void NmeaServer_OnServerError(Exception exception)
 {   
     MessageHub.PublishAsync(new LogMessage(this, new LogText($"{Texts.GetString("NMEAServerError")}{exception.Message}\r\n", Color.Red)));
     StopSelectedBoatDataRefreshTask();
 }
 private void NmeaServer_OnClientConnected(string address)
 {
     MessageHub.PublishAsync(new LogMessage(this, new LogText($"{Texts.GetString("ClientConnected")}{address}")));
     NmeaServer.SendData();
 }
    IEnumerator DoTurnRoutine(PlayerMove move)
    {
        Logger.PrepareMove(move.start, move.end, _boards);

        if (ActivePlayer.PlayerType == PlayerType.AI)
        {
            _camera.GoToBoard((int)move.end.z);

            while (IsAnimated)
            {
                yield return(null);
            }
        }

        EngineResponse response = _gameEngine.DoTurn(move.start, move.end);

        while (IsAnimated)
        {
            yield return(null);
        }

        if (response == EngineResponse.CHECK)
        {
            _overlayManager.SetLabel(Texts.GetString("CheckText"), UnityEngine.Color.red);
            Logger.LogMove(true, false);
        }
        else if (response == EngineResponse.CHECK_MATE)
        {
            State = GameManagerState.FINISHED;
            _overlayManager.SetLabel(Texts.GetString("CheckmateText"), UnityEngine.Color.red);
            Logger.LogMove(false, true);
        }
        else
        {
            if (ActivePlayerColor == Color.BLACK)
            {
                _overlayManager.SetLabel(Texts.GetString("BlackTurnText"), UnityEngine.Color.black);
            }
            else
            {
                _overlayManager.SetLabel(Texts.GetString("WhiteTurnText"), UnityEngine.Color.white);
            }
            Logger.LogMove(false, false);
        }

        while (IsAnimated)
        {
            yield return(null);
        }

        _overlayManager.SetCapturedList(Logger.CapturedPieces);

        if (State == GameManagerState.PLAYING)
        {
            foreach (var player in _players)
            {
                if (player.Color == ActivePlayerColor)
                {
                    player.DoTurn();
                    break;
                }
            }
        }
    }