Пример #1
0
    // Use this for initialization
    void Start()
    {
        highScoreCalculator = GameObject.Find("High Score Calculator").GetComponent <High_Score_Calculator> ();
        //first check if they're using the most recent version of the game
        if (PlayerPrefs.GetInt("Version", 0) != versionNumber)
        {
            highScoreCalculator.Reset_All_Scores();
            foreach (High_Score_Displayer hsd in hsds)
            {
                hsd.update_scores();
            }
            PlayerPrefs.SetInt("Version", versionNumber);
        }
        achievementHandler = GameObject.Find("Achievement Handler").GetComponent <Achievement_Script> ();
        gpgNotification    = GameObject.Find("Google Play Notification").GetComponent <GPG_Notification> ();
        Goto_Game_Mode_Layer();
        shutter.Begin_Vertical_Open();

        GameObject MCobject = GameObject.FindGameObjectWithTag("Music Controller");

        mc = MCobject.GetComponent <Music_Controller> ();

        mc.Play_Music("Menu");

        //just in case this is the first time playing, set Wiz to be for sure unlocked
        PlayerPrefs.SetInt("Wiz unlocked", 1);
        //tell achievmement handler to check gamemodes that are supposed to be active
        achievementHandler.Check_Gamemode_Unlocked();

        activeMode = 0;
        prevMode   = 0;
        ScrollDown.BroadcastMessage("FadeOut", null, SendMessageOptions.DontRequireReceiver);
        for (int i = 0; i < 4; i++)
        {
            OrigButtonSprite[i] = GameButtons[i].GetComponent <Image>().sprite;
            OrigDescText[i]     = Descriptions[i].GetComponent <Text>().text;
        }
        GameMode_Unlocker();

        if (PlayerPrefs.GetInt("Played Before", 0) == 1)
        {
            Destroy(HTPEmphasizer);
        }
    }
Пример #2
0
    void Awake()
    {
        if (SceneManager.GetActiveScene().name == "Split Title Scene")
        {
            SceneManager.UnloadScene("Split Title Scene");
        }
        achievementHandler = GameObject.FindGameObjectWithTag("Achievement Handler").GetComponent <Achievement_Script> ();

        //begin with the assumption that you're not in quick mode and there's not countdown
        isCountingDown = false;

        switch (PlayerPrefs.GetInt("Mode", 0))
        {
        case 0:
            gameType = "Wiz";
            break;

        case 1:
            gameType = "Quick";
            break;

        case 2:
            gameType = "Wit";
            break;

        case 3:
            gameType = "Holy";
            break;
        }

        mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera> ();

        //let's grab the music controller
        GameObject MCobject = GameObject.FindGameObjectWithTag("Music Controller");

        mc = MCobject.GetComponent <Music_Controller> ();

        //reposition score to wherever it may be
        scoreText.transform.GetComponent <BoxCollider2D> ().offset = (mainCamera.ViewportToWorldPoint(scoreText.transform.position))
                                                                     - scoreText.transform.position;

        multiRun = false;
        //instantiate the grids with their appropriate starting values
        for (int r = 0; r <= 7; r++)
        {
            for (int c = 0; c <= 15; c++)
            {
                grid[r, c]      = null;
                colorGrid[r, c] = null;
                checkGrid[r, c] = false;
            }
            cluster[r] = null;
        }

        multiplier    = 1;
        checkGameOver = false;
        piecesPlaced  = 0;
        checkFlag     = false;
        movesMade     = 0;
        score         = 0;
        //load the splitter with the spawned splitter object
        GameObject splitterObject = GameObject.Find("Splitter");

        if (splitterObject != null)
        {
            splitter = splitterObject.GetComponent <Splitter_script>();
        }

        gameOver = false;
        //load the side columns if they exist
        sideColumns [0] = null;
        sideColumns [1] = null;
        GameObject[] scols = GameObject.FindGameObjectsWithTag("Side Column");
        GameObject   spellHandlerObject = GameObject.Find("Spell Handler");

        spellHandler = spellHandlerObject.GetComponent <SpellHandler> ();
        if (gameType == "Wit")
        {
            availableCount = 8;

            //no powers in Wit
            Destroy(spellHandlerObject);

            //Wit does not use the sidecolumns, get rid of them
            Destroy(scols[1]);
            Destroy(scols[0]);
            mc.Play_Music(gameType);
        }
        else if (gameType == "Quick")
        {
            availableCount = 4;
            if (scols [0] != null && scols [1] != null)
            {
                //make sure they're loaded properly, left is 0, right is 1
                if (scols[0].GetComponent <SideColumn>().sideInt == 0)
                {
                    sideColumns[0] = scols[0].GetComponent <SideColumn>();
                    sideColumns[1] = scols[1].GetComponent <SideColumn>();
                }
                else
                {
                    sideColumns[0] = scols[1].GetComponent <SideColumn>();
                    sideColumns[1] = scols[0].GetComponent <SideColumn>();
                }
            }
            quickMoveSides = false;
            StartCoroutine("StartingCountDown");
            splitter.setState("canShoot", false);

            // no powers in Quick, only Holy and Wiz
            Destroy(spellHandlerObject);
        }
        else if (gameType == "Wiz")
        {
            //powers are in Wiz, start out with 5 kinds of blocks
            availableCount = 5;
            if (scols [0] != null && scols [1] != null)
            {
                //make sure they're loaded properly, left is 0, right is 1
                if (scols[0].GetComponent <SideColumn>().sideInt == 0)
                {
                    sideColumns[0] = scols[0].GetComponent <SideColumn>();
                    sideColumns[1] = scols[1].GetComponent <SideColumn>();
                }
                else
                {
                    sideColumns[0] = scols[1].GetComponent <SideColumn>();
                    sideColumns[1] = scols[0].GetComponent <SideColumn>();
                }
            }
            spellHandler.redReady    = true;
            spellHandler.orangeReady = false;
            spellHandler.yellowReady = true;
            spellHandler.greenReady  = true;
            spellHandler.blueReady   = true;
            spellHandler.purpleReady = true;
            spellHandler.cyanReady   = false;
            spellHandler.whiteReady  = false;
            mc.Play_Music(gameType);
        }
        else if (gameType == "Holy")
        {
            //Holy has everything at once. Essentially hard mode
            availableCount = 8;
            if (scols [0] != null && scols [1] != null)
            {
                //make sure they're loaded properly, left is 0, right is 1
                if (scols[0].GetComponent <SideColumn>().sideInt == 0)
                {
                    sideColumns[0] = scols[0].GetComponent <SideColumn>();
                    sideColumns[1] = scols[1].GetComponent <SideColumn>();
                }
                else
                {
                    sideColumns[0] = scols[1].GetComponent <SideColumn>();
                    sideColumns[1] = scols[0].GetComponent <SideColumn>();
                }
            }
            spellHandler.redReady    = true;
            spellHandler.orangeReady = true;
            spellHandler.yellowReady = true;
            spellHandler.greenReady  = true;
            spellHandler.blueReady   = true;
            spellHandler.purpleReady = true;
            spellHandler.cyanReady   = true;
            spellHandler.whiteReady  = true;
            mc.Play_Music(gameType);
        }

        if (gameType != "Wit" && sideColumns != null && sideColumns[0].side == "Right")
        {
            SideColumn temp = sideColumns[0];
            sideColumns[0] = sideColumns[1];
            sideColumns[1] = temp;
        }
        sidesChecked = false;

        //initially update the moves and scores
        updateMoves();
        updateScore();

        //get the pause stuff in order
        isPaused = false;
        GameOverLayer.SetActive(false);
        shutter.Begin_Horizontal_Open();

        //high score stuff
        newHighScore       = false;
        HighScoreText.text = "";
        tipText.text       = "";
        Score_Text_Canvas  = GameObject.Find("Score Text Canvas");
    }
Пример #3
0
    void FixedUpdate()
    {
        //check to see if a piece is in the splitter area after each board check
        if (checkGameOver)
        {
            for (int c = 7; c <= 8; c++)
            {
                for (int r = 0; r <= 7; r++)
                {
                    if (colorGrid[r, c] != null && grid[r, c] != null)
                    {
                        gameOverText.text = "Game Over";
                        gameOver          = true;
                        GameOverLayer.SetActive(true);
                        mc.Stop_Music();
                        splitter.setState("canShoot", false);
                        //unlocking candy cane splitter
                        if (!achievementHandler.is_Splitter_Unlocked("Candy Cane") && score > 0 && score < 200)
                        {
                            achievementHandler.Unlock_Splitter("Candy Cane");
                        }

                        if (!achievementHandler.is_Splitter_Unlocked("Dark") && (gameType == "Wiz" || gameType == "Holy"))
                        {
                            if (!spellHandler.Used_Spells() && score > 1000)
                            {
                                achievementHandler.Unlock_Splitter("Dark");
                            }
                        }
                    }
                }
            }
            checkGameOver = false;
        }

        //things that should only happen once at gameover
        if (gameOver && ffGameOver)
        {
            ffGameOver = false;
            achievementHandler.Add_Score(gameType, score);
            GameObject.Find("GO Black Screen").GetComponent <Fader>().FadeIn();
            tipText.text = tips[Random.Range(0, tips.Count())];
            mc.Play_Music("Gameover");
        }

        //check that the music controller isn't being a dick about the game over music
        if (gameOver && (mc.MusicSource.clip.name != "Split It Game Over" || !mc.MusicSource.isPlaying))
        {
            mc.Play_Music("Gameover");
        }

        if (!achievementHandler.is_Splitter_Unlocked("Caution") || !achievementHandler.is_Pieceset_Unlocked("Blob"))
        {
            int dangerPieces = Get_Danger_Pieces();
            if (!achievementHandler.is_Splitter_Unlocked("Caution") && gameType != "Holy" && gameType != "Wiz" && dangerPieces >= 5 && dangerPieces == 0)
            {
                achievementHandler.Unlock_Splitter("Caution");
            }
            if (!achievementHandler.is_Pieceset_Unlocked("Blob") && gameType == "Holy" && dangerPieces == 16)
            {
                achievementHandler.Unlock_Pieceset("Blob");
            }
        }

        if (!gameOver && Get_Danger_Pieces() > 0)
        {
            mc.Start_Slow_Tick();
        }
        else
        {
            mc.Stop_Slow_Tick();
        }
        //if both pieces have been placed, set the checkGrid to false and check the board
        if (piecesPlaced >= 2)
        {
            piecesPlaced  = 0;
            checkGameOver = true;
            if (checkFlag)
            {
                clearedLastTurn        = piecesDeletedThisSplit;
                piecesDeletedThisSplit = false;
                checkBoard();
                checkFlag = false;
                //check to see if it's time to move the sides in
            }
            else if (!isCountingDown)
            {
                splitter.setState("canShoot", true);
            }
            GameObject[] sidebars = GameObject.FindGameObjectsWithTag("Sidebar");
            //here's where we do side-entering management
            if ((gameType == "Wiz" || gameType == "Holy") && !sidesChecked)
            {
                if (movesMade % sideMovesLimit == 0)
                {
                    addSideColumns();
                    sideColumns[0].shakeStage = 0;
                    sideColumns[1].shakeStage = 0;
                    sidebars [0].BroadcastMessage("Reset");
                    sidebars [1].BroadcastMessage("Reset");
                    mc.Stop_Fast_Tick();
                }
                else if (sideMovesLimit - (movesMade % sideMovesLimit) <= 8)
                {
                    switch (sideMovesLimit - (movesMade % sideMovesLimit))
                    {
                    case 1:
                        sideColumns[0].isShaking  = false;
                        sideColumns[1].isShaking  = false;
                        sideColumns[0].ready      = true;
                        sideColumns[1].ready      = true;
                        sideColumns[0].shakeStage = 0;
                        sideColumns[1].shakeStage = 0;
                        sidebars [0].BroadcastMessage("Increment_Lights");
                        sidebars [1].BroadcastMessage("Increment_Lights");
                        break;

                    case 2:
                        sideColumns[0].shakeStage = 3;
                        sideColumns[1].shakeStage = 3;
                        sidebars [0].BroadcastMessage("Increment_Lights");
                        sidebars [1].BroadcastMessage("Increment_Lights");
                        break;

                    case 3:
                        sideColumns[0].shakeStage = 2;
                        sideColumns[1].shakeStage = 2;
                        sidebars [0].BroadcastMessage("Increment_Lights");
                        sidebars [1].BroadcastMessage("Increment_Lights");
                        break;

                    case 4:
                        sideColumns[0].isShaking  = true;
                        sideColumns[1].isShaking  = true;
                        sideColumns[0].shakeStage = 1;
                        sideColumns[1].shakeStage = 1;
                        mc.Start_Fast_Tick();
                        sidebars [0].BroadcastMessage("Increment_Lights");
                        sidebars [1].BroadcastMessage("Increment_Lights");
                        break;

                    case 5:
                        sidebars [0].BroadcastMessage("Increment_Lights");
                        sidebars [1].BroadcastMessage("Increment_Lights");
                        break;

                    case 6:
                        sidebars [0].BroadcastMessage("Increment_Lights");
                        sidebars [1].BroadcastMessage("Increment_Lights");
                        break;

                    case 7:
                        sidebars [0].BroadcastMessage("Increment_Lights");
                        sidebars [1].BroadcastMessage("Increment_Lights");
                        break;

                    case 8:
                        sidebars [0].BroadcastMessage("Increment_Lights");
                        sidebars [1].BroadcastMessage("Increment_Lights");
                        break;
                    }
                }
                sidesChecked = true;
            }
            else if ((gameType == "Quick") && !sidesChecked)
            {
                //quick mode moves the sides in based off of time, not moves
                if (quickMoveSides)
                {
                    addSideColumns();
                    sideColumns[0].ready = false;
                    sideColumns[1].ready = false;
                    quickMoveSides       = false;
                    StartCoroutine("QuickSideTimer");
                    mc.Stop_Fast_Tick();
                }
                sidesChecked = true;
            }
        }
    }