コード例 #1
0
ファイル: GameManager.cs プロジェクト: SlowSeer/BrickUm
    private XmlDocument myLevelSave; // XML Doc for saving.
#endif


    // Initialize (MonoSingleton)
    public override void Init()
    {
        paddle = paddleObject.GetComponent <PaddleBehaviour>();

        GameObject _gameSetup;

        if (GameObject.FindGameObjectWithTag("GameSetup") == null)
        {
            _gameSetup = GameObject.Instantiate(gameSetupPrefab, Vector3.zero, Quaternion.identity) as GameObject;
        }
        else
        {
            _gameSetup = GameObject.FindGameObjectWithTag("GameSetup");
        }
        gameSetup  = _gameSetup.GetComponent <GameSetup>();
        brickTheme = gameSetup.brickThemes[1]; // Just do grayscale as default and let it switch to color.

        // Delete prefs.
        //PlayerPrefs.DeleteAll();
    }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: SlowSeer/BrickUm
    void Start()
    {
        // Have we transitioned into this scene properly? If not, go back to menu.
        if (gameSetup == null || sSelectedCampaign < 0 || sSelectedLevel < 0)
        {
            Application.LoadLevel("MainMenu"); return;
        }

        // Grab all the bricks in the scene and keep them in a list. -- Shouldn't be any.
        foreach (GameObject b in GameObject.FindGameObjectsWithTag("Brick"))
        {
            bricksActive.Add(b);
        }



        // Load Level (Some quick checks to make sure a level has been selected)
        if (gameSetup != null)
        {
            // Get Selected Game Level... FreePlay or Campaign/KidMode
            if (gameMode == GameMode.FreePlay)
            {
                sSelectedGameLevel = gameSetup.freePlayLevels[sSelectedLevel];
            }
            else
            {
                sSelectedGameLevel = gameSetup.gameCampaigns[sSelectedCampaign].campaignLevels[sSelectedLevel];
            }

            if (sSelectedGameLevel != null && sSelectedGameLevel.levelData != null)
            {
                // Load our level Date.
                LoadLevel(sSelectedGameLevel.levelData);

                // Set Background.
                background.GetComponent <Renderer>().material = gameSetup.backgrounds[sSelectedGameLevel.background];

                // Set Paddle Color
                paddle.paddleColor = sSelectedGameLevel.paddleColor;

                // Set the color theme of the bricks.
                brickTheme = gameSetup.brickThemes[sSelectedGameLevel.brickTheme];

                // Create Ball.
                ballObject = GameObject.Instantiate(gameSetup.BallTypes[sSelectedGameLevel.ball], ballSpawn.position, Quaternion.identity) as GameObject;
                ball       = ballObject.GetComponent <BallBehaviour>();
            }
        }

        // Initiate Game Settings.

        // Kid mode gets a higher buff chance and easier difficulty.
        if (gameMode == GameMode.KidMode)
        {
            buffChance     = 20;
            gameDifficulty = GameDifficulty.Easy;
        }

        textTitle.text    = sSelectedGameLevel.levelName;
        textSubtitle.text = "Position paddle then tap the ball to start!";

        textBuff.GetComponent <Renderer>().enabled = false;
        textBuffRenderer = textBuff.GetComponent <Renderer>();
        textBuffColor    = textBuffRenderer.material.color;

        // We dont start with a bomb, do disable the button.
        guiBombButton.usable = false;
    }