Ejemplo n.º 1
0
    void SetState(eLevelAdvanceState newState)
    {
        stateStartTime = realTime;

        switch (newState)
        {
        case eLevelAdvanceState.idle:
            gameObject.SetActive(false);
            if (beginLevelCallback != null)
            {
                beginLevelCallback();
                beginLevelCallback = null;
            }
            break;

        case eLevelAdvanceState.fadeIn:
            gameObject.SetActive(true);
            // Set text
// Uncomment the two lines below once you've implemented the GameManager
//                levelText.text = "Level "+(GameManager.GAME_LEVEL+1);
//                infoText.text = GameManager.GAME_LEVEL_NAME;
            levelRT.localScale = new Vector3(1, 0, 1);
            infoText.color     = Color.clear;
            // Set initial state
            img.color          = Color.clear;
            levelRT.localScale = new Vector3(1, 0, 1);
            infoText.color     = Color.clear;
            // Set timiing and advancement
            stateDuration = fadeTime * 0.2f;
            nextState     = eLevelAdvanceState.fadeIn2;
            break;

        case eLevelAdvanceState.fadeIn2:
            // Set initial state
            img.color          = Color.black;
            levelRT.localScale = new Vector3(1, 0, 1);
            infoText.color     = Color.clear;
            // Set timiing and advancement
            stateDuration = fadeTime * 0.6f;
            nextState     = eLevelAdvanceState.fadeIn3;
            break;

        case eLevelAdvanceState.fadeIn3:
            // Set initial state
            img.color          = Color.black;
            levelRT.localScale = new Vector3(1, 1, 1);
            infoText.color     = Color.clear;
            // Set timiing and advancement
            stateDuration = fadeTime * 0.2f;
            nextState     = eLevelAdvanceState.display;
            break;

        case eLevelAdvanceState.display:
            stateDuration = -1;                     // Displays until the next level is loaded
            nextState     = eLevelAdvanceState.none;
            if (endLevelCallback != null)
            {
                endLevelCallback();
                endLevelCallback = null;
            }
            break;

        case eLevelAdvanceState.fadeOut:
            // Set initial state
            img.color          = Color.black;
            levelRT.localScale = new Vector3(1, 1, 1);
            infoText.color     = Color.white;
            // Set timiing and advancement
            stateDuration = fadeTime * 0.2f;
            nextState     = eLevelAdvanceState.fadeOut2;
            break;

        case eLevelAdvanceState.fadeOut2:
            // Set initial state
            img.color          = Color.black;
            levelRT.localScale = new Vector3(1, 1, 1);
            infoText.color     = Color.clear;
            // Set timiing and advancement
            stateDuration = fadeTime * 0.6f;
            nextState     = eLevelAdvanceState.fadeOut3;
            break;

        case eLevelAdvanceState.fadeOut3:
            // Set initial state
            img.color          = Color.black;
            levelRT.localScale = new Vector3(1, 0, 1);
            infoText.color     = Color.clear;
            // Set timiing and advancement
            stateDuration = fadeTime * 0.2f;
            nextState     = eLevelAdvanceState.idle;
            break;
        }

        state = newState;
    }
    void SetState(eLevelAdvanceState newState)
    {
        stateStartTime = realTime;

        switch (newState)
        {
        case eLevelAdvanceState.idle:
            gameObject.SetActive(false);
            if (idleCallback != null)
            {
                idleCallback();
                idleCallback = null;
            }
            break;

        case eLevelAdvanceState.fadeIn:
            gameObject.SetActive(true);
            // Set text
            levelText.text     = "Level " + AsteraX.GAME_LEVEL;
            levelRT.localScale = new Vector3(1, 0, 1);
            AsteraX.LevelInfo lvlInfo = AsteraX.GetLevelInfo();
            infoText.text  = "Asteroids: " + lvlInfo.numInitialAsteroids + "\tChildren: " + lvlInfo.numSubAsteroids;
            infoText.color = Color.clear;
            // Set initial state
            img.color          = Color.clear;
            levelRT.localScale = new Vector3(1, 0, 1);
            infoText.color     = Color.clear;
            // Set timiing and advancement
            stateDuration = fadeTime * 0.2f;
            nextState     = eLevelAdvanceState.fadeIn2;
            break;

        case eLevelAdvanceState.fadeIn2:
            // Set initial state
            img.color          = Color.black;
            levelRT.localScale = new Vector3(1, 0, 1);
            infoText.color     = Color.clear;
            // Set timiing and advancement
            stateDuration = fadeTime * 0.6f;
            nextState     = eLevelAdvanceState.fadeIn3;
            break;

        case eLevelAdvanceState.fadeIn3:
            // Set initial state
            img.color          = Color.black;
            levelRT.localScale = new Vector3(1, 1, 1);
            infoText.color     = Color.clear;
            // Set timiing and advancement
            stateDuration = fadeTime * 0.2f;
            nextState     = eLevelAdvanceState.display;
            break;

        case eLevelAdvanceState.display:
            stateDuration = displayTime;
            nextState     = eLevelAdvanceState.fadeOut;
            if (displayCallback != null)
            {
                displayCallback();
                displayCallback = null;
            }
            break;

        case eLevelAdvanceState.fadeOut:
            // Set initial state
            img.color          = Color.black;
            levelRT.localScale = new Vector3(1, 1, 1);
            infoText.color     = Color.white;
            // Set timiing and advancement
            stateDuration = fadeTime * 0.2f;
            nextState     = eLevelAdvanceState.fadeOut2;
            break;

        case eLevelAdvanceState.fadeOut2:
            // Set initial state
            img.color          = Color.black;
            levelRT.localScale = new Vector3(1, 1, 1);
            infoText.color     = Color.clear;
            // Set timiing and advancement
            stateDuration = fadeTime * 0.6f;
            nextState     = eLevelAdvanceState.fadeOut3;
            break;

        case eLevelAdvanceState.fadeOut3:
            // Set initial state
            img.color          = Color.black;
            levelRT.localScale = new Vector3(1, 0, 1);
            infoText.color     = Color.clear;
            // Set timiing and advancement
            stateDuration = fadeTime * 0.2f;
            nextState     = eLevelAdvanceState.idle;
            break;
        }

        state = newState;
    }