예제 #1
0
    public void InitGame(LevelManager.LEVEL playingLevel)
    {
        //don't initiate the game if the game is already running!
        if (currState == State.Playing)
        {
            return;
        }

        // set the state
        currState = State.Playing;

        audioEnemyMovement.Play();

        // get level info
        LevelManager.LevelInfo lvlInfo = LevelManager.GetLevelInfo(playingLevel);

        // set current level to starting level
        currentLevel = playingLevel;

        // create enemy wave
        enemyManager.CreateEnemyWave(lvlInfo.enemyInXPos, lvlInfo.enemyInYPos, lvlInfo.enemyInZPos, lvlInfo.enemyMovingSpeedFactor, lvlInfo.enemySeparationSpacing);

        // update player lives in ui
        uiManager.updateLivesRemaining(player1.StartingTotalLives);

        // update current level in ui
        uiManager.updateLevelNumber((int)playingLevel + 1);

        // show text on the graffiti
        RefreshUI();
    }
예제 #2
0
    void GUIStateLoad()
    {
        Vector2 centerGroupSize = new Vector2(guiLoad.scrollviewSize.x,
            guiLoad.scrollviewSize.y + guiLoad.verticalSpacing + guiLoad.btnSize.y);
        Rect r = new Rect(trgtRes.x / 2 - centerGroupSize.x / 2 + guiLoad.centerGroupOffset.x,
            trgtRes.y / 2 - centerGroupSize.y / 2 + guiLoad.centerGroupOffset.y, centerGroupSize.x, centerGroupSize.y);

        GUI.BeginGroup(r);
            r = new Rect(0, 0, guiLoad.scrollviewSize.x, guiLoad.scrollviewSize.y);

            string[] files = System.IO.Directory.GetFiles("Levels/", "*.lev");

            Rect viewRect = new Rect(0, 0, 0,
                files.Length * guiLoad.itemBtnSize.y + (files.Length - 1) * guiLoad.verticalSpacing);

            loadScrollPos = GUI.BeginScrollView(r, loadScrollPos, viewRect);
                r = new Rect(0, 0, guiLoad.itemBtnSize.x, guiLoad.itemBtnSize.y);

                for (int i = 0; i < files.Length; i++) {
                    int start = files[i].LastIndexOf("/") + 1;
                    int end = files[i].LastIndexOf(".");
                    string levelName = files[i].Substring(start, end - start);

                    if (GUI.Button(r, levelName)) {
                        selLevInf = lm.LoadLevelInfo(levelName);
                    }

                    if (i+1 != files.Length) {
                        r.y += guiLoad.itemBtnSize.y + guiLoad.verticalSpacing;
                    }
                }
            GUI.EndScrollView();

            r = new Rect(0, guiLoad.scrollviewSize.y + guiLoad.verticalSpacing, guiLoad.btnSize.x, guiLoad.btnSize.y);
            if (GUI.Button(r, "Back")) {
                lastState = state;
                state = State.Pause;
                selLevInf.levelName = "";
            }
        GUI.EndGroup();

        if (selLevInf.levelName != "") {
            GUIDisplayLevelInfo();
        }
    }