Example #1
0
    protected override void StateEnd()
    {
        ResetStateController();

        this.uiController.SetActiveClientFooterGroup(false);

        clientController.CurrentState = ClientController.ClientState.WaitingPlayers;
        currentTurnStep = TurnSteps.Movement;
        clientController.PlayerNullableNextPosition = null;
        clientController.PlayerNullableNexSound     = null;
        clientController.PlayerNullableWillAttack   = null;
    }
Example #2
0
    void NextStep()
    {
        currentStep = (TurnSteps)(currentStep + 1);

        if (currentStep == TurnSteps.NEXT_TURN)
        {
            gameTurn++;

            if (TURNS_BEFORE_WINTER - gameTurn <= 0)
            {
                CheckForVictoryOrDefeat();
                return;
            }

            currentStep = (TurnSteps)0;
        }

        switch (currentStep)
        {
        case TurnSteps.Upkeep:
            UpkeepStep();
            break;

        case TurnSteps.Dices:
            DicesStep();
            break;

        case TurnSteps.Main:
            MainStep();
            break;

        case TurnSteps.Event:
            EndStep();
            break;

        default:
            Debug.LogError("Should not happen: " + currentStep);
            break;
        }
    }
Example #3
0
    protected override void ExecuteLogic()
    {
        switch (currentTurnStep)
        {
        case TurnSteps.Movement:
            ClientPing();
            if (clientController.PlayerNullableNextPosition.HasValue)
            {
                currentTurnStep = TurnSteps.PlayerWillAttack;
            }

            break;

        case TurnSteps.PlayerWillAttack:
            if (clientController.CurrentPlayerState == ClientController.PlayerState.Alien)
            {
                if (!clientController.PlayerNullableWillAttack.HasValue)
                {
                    this.uiController.SetTwoButtonsVisibility(true);
                    ClientPing();
                }
                else
                {
                    this.uiController.SetTwoButtonsVisibility(false);
                    if (clientController.PlayerNullableWillAttack.Value)
                    {
                        clientController.PlayerNullableNexSound = clientController.PlayerNullableNextPosition;
                        ActivateEffectFeedback(EffectFeedback.SectorSound);
                        currentTurnStep = TurnSteps.SendData;
                    }
                    else
                    {
                        currentTurnStep = TurnSteps.Card;
                    }
                }
            }
            else
            {
                currentTurnStep = TurnSteps.Card;
            }
            break;

        case TurnSteps.Card:
            string tileCode = BoardManager.TranslateTilePositionToCode(clientController.PlayerNullableNextPosition.Value);
            BoardManager.PossibleTypes tileType = clientController.GetTileType(tileCode);

            if (tileType == BoardManager.PossibleTypes.EventTile)
            {
                EventDeck.CardTypes cardType = clientController.Deck.DrawCard();

                switch (cardType)
                {
                case EventDeck.CardTypes.AnySectorSound:
                    TimeLogger.Log("CLIENT {0} can choose a sector to make a noise", clientController.ClientId);
                    uiController.SetInfoText("Choose an alarm sector");
                    ActivateEffectFeedback(EffectFeedback.ChooseSector);
                    clientController.GlowPossibleNoises();
                    currentTurnStep = TurnSteps.Noise;
                    break;

                case EventDeck.CardTypes.CurrentSectorSound:
                    TimeLogger.Log("CLIENT {0} make a noise in his sector", clientController.ClientId);
                    ActivateEffectFeedback(EffectFeedback.SectorSound);
                    clientController.PlayerNextSound = clientController.PlayerNextPosition;
                    currentTurnStep = TurnSteps.Noise;
                    break;

                case EventDeck.CardTypes.NoSound:
                    TimeLogger.Log("CLIENT {0} is silent", clientController.ClientId);
                    ActivateEffectFeedback(EffectFeedback.LuckDangerousSector);
                    currentTurnStep = TurnSteps.SendData;
                    break;
                }
            }
            else
            {
                ActivateEffectFeedback(EffectFeedback.Silent);
                currentTurnStep = TurnSteps.SendData;
            }
            break;

        case TurnSteps.Noise:
            ClientPing();
            if (clientController.PlayerNullableNexSound.HasValue)
            {
                currentTurnStep = TurnSteps.SendData;
            }
            break;

        case TurnSteps.SendData:
            uiController.SetInfoText();
            clientController.ClientCommunication.SchedulePutPlayRequest(
                (Vector2Int)clientController.PlayerNullableNextPosition,
                clientController.PlayerNullableNexSound.HasValue ? (Vector2Int)clientController.PlayerNullableNexSound : new Vector2Int(-1, -1),     // TODO - check if is there better solutions than V(-1,-1)
                clientController.PlayerNullableWillAttack.HasValue ? (bool)clientController.PlayerNullableWillAttack : false
                );
            StateEnd();
            break;
        }
    }