// Update is called once per frame
    void FixedUpdate()
    {
        switch (gs)
        {
        case GameState.DISABLED:
            break;

        case GameState.INITGAME:
            deltatime += 0.01f;
            if (deltatime > maxInVisT)
            {
                deltatime = 0;
                gs        = GameState.DISABLED;
                GetComponent <GridGenerator>().RotateAllCards();
                GetComponent <GridGenerator>().gridState = GridGenerator.GridState.ALLCARDSSTOPED;
                GetComponent <ScoreManager>().parseScore = true;
            }
            break;

        case GameState.GAMELOOP:
            deltatime += 0.01f;

            if (deltatime > tbs && tbs != 1 &&
                GetComponent <GridGenerator>().GetCardsInMovement() < (GetComponent <GridGenerator>().GetCardsInGame() - 2))
            {
                GetComponent <GridGenerator>().ShuffleTwoCards();
                deltatime = 0;
            }
            if (CheckEndCondition())
            {
                gs = GameState.ENDGAME;
            }
            if (GetComponent <GridGenerator>().AllCardsUncoveredCorrectly() &&
                GetComponent <GridGenerator>().isInfinite)
            {
                gs = GameState.RESET;
            }
            break;

        case GameState.ENDGAME:
            if (!this.GetComponent <CardData>().cards[this.GetComponent <GridGenerator>().LastIdMonsterUncovered].unlocked &&
                !GetComponent <GridGenerator>().isInfinite&& GetComponent <GridGenerator>().AllCardsUncoveredCorrectly())
            {
                int i = this.GetComponent <GridGenerator>().LastIdMonsterUncovered;
                this.GetComponent <CardData>().SetCardInfo(i, true);
                this.GetComponent <GaleryController>().cardsInGalery[i].GetComponent <GaleryCardScript>().UnlockCard();
                restartMenu.SetCardUnlockedInfo(GetComponent <CardData>().cards[i],
                                                GetComponent <CardData>().cardSprites[i],
                                                GetComponent <GaleryController>().rarityColor[GetComponent <CardData>().cards[i].rarity]);
                restartMenu.ActivateNewCardUnlocked();
            }

            GetComponent <InputController>().DeactivateInput(false);
            GetComponent <InputController>().ResetInputController();
            if (!loseGame && !GetComponent <GridGenerator>().isInfinite)
            {
                GetComponent <ScoreManager>().CompareScore();
            }
            else if (GetComponent <GridGenerator>().isInfinite)
            {
                GetComponent <ScoreManager>().CompareScore();
            }
            GetComponent <ScoreManager>().SaveGame();
            GetComponent <InterfaceController>().ResetLives();
            GetComponent <GridGenerator>().CleanGrid(true);
            gs = GameState.DISABLED;
            break;

        case GameState.CHANGEMENU:
            GetComponent <InterfaceController>().SetRestartMenu();
            if (loseGame)
            {
                GetComponent <AudioManager>().PlayGameEffect(3);
            }
            else
            {
                GetComponent <AudioManager>().PlayGameEffect(2);
            }
            if (publiCounter % 3 == 2)
            {
                GetComponent <InicializerScript>().ShowInterstitial();
            }
            publiCounter++;
            gs = GameState.DISABLED;

            break;

        case GameState.RESET:
            GetComponent <InputController>().DeactivateInput(false);
            GetComponent <InputController>().ResetInputController();
            GetComponent <GridGenerator>().CleanGrid(true);
            gs = GameState.DISABLED;
            GetComponent <GridGenerator>().GenerateGrid();
            break;
        }
    }