Exemplo n.º 1
0
    public virtual IEnumerator ExecutePowerup(int powerup, List <Cube> cubes, List <int> positions, Swipes.Direction direction)
    {
        /*if (tutSpawner != null) {
         *      if (!tutSpawner.ValidProgress ()) {
         *              LevelManager.instance.lastPulseIndex = LevelManager.instance.pulseIndex - 1;
         *              LevelManager.instance.pulseIndex = LevelManager.instance.lastPulseIndex + 1;
         *              tutSpawner.UpdateBoard ();
         *      }
         * }*/

        if (LevelManager.instance.movesLeft > 0 && finishedAnimation)
        {
            GestureDetector.ready = false;
            if (LevelManager.instance.moveInfo[powerup] > 0)
            {
                finishedAnimation = false;

                switch (powerup)
                {
                case 0:
                    switch_.TryExecute(cubes[0], direction);
                    break;

                case 1:
                    rotate.GetDirectionAndExecute(cubes, positions);
                    break;

                case 2:
                    switchRow.TryExecute(cubes[0], direction);
                    break;

                default:
                    Debug.LogError("Powerup not defined!");
                    break;
                }
            }
            else if (LevelManager.instance.gameState == LevelManager.GameState.InLevel && spawner.powerupMovesLeft[powerup].gameObject.activeInHierarchy)
            {
                spawner.powerupMovesLeft[powerup].GetComponent <UIAnimations>().PulseSize(Colors.powerupMissing);
            }

            yield return(new WaitForSeconds(Constants.CubeSwitchTime));

            finishedAnimation = true;
            spawner.UpdateBoard();
            GestureDetector.ready = true;
        }
    }