コード例 #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
            MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_2", true);
            MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_3", true);
            MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);

            StartCoroutine(GameManager.Instance.CoGameWin());
        }
    }
コード例 #2
0
    void MarkLevelCompleted()
    {
        // sets the level completed
        // by default next level will be unlocked
        MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);

        // manual unlocking looks like this:
        // MadLevelProfile.SetLocked("level_name", false);

        // remembering that level is completed
        completed = true;
    }
コード例 #3
0
        public void Update()
        {
            endScore.text = "Moves: " + moves;

            // End of game
            if (selectedCellColorList.Count == 0)
            {
                var canvas = GameObject.Find("Level Canvas");

                this.gameObject.SetActive(false);
                Instantiate(endPanel, canvas);
                MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
            }
        }
コード例 #4
0
        public void Update()
        {
            GameObject[] allActiveColors = GameObject.FindGameObjectsWithTag("activeColor");
            endTime         += Time.deltaTime;
            statusScore.text = "Time: " + endTime.ToString("f1") + " s";
            endScore.text    = "Time: " + endTime.ToString("f1") + " seconds";

            // End of game
            if (allActiveColors.Length == 0 && activeColorsReady)
            {
                var canvas = GameObject.Find("Level Canvas");

                this.gameObject.SetActive(false);
                Instantiate(endPanel, canvas);
                MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
            }
        }
コード例 #5
0
    public IEnumerator endGame()
    {
        yield return(new WaitForSeconds(0.2f));

        // Show Game Over panel
        //gameOverPanel.SetActive(true);
        //iTween.Stop(gameObject);
        iTween.ValueTo(gameObject, iTween.Hash("from", zeroScale, "to", originalScale, "time", 0.2f, "ignoretimescale", true, "onUpdate", "scaleGameOverPanel"));
        Time.timeScale = 0.0f;

        // Get current Level best score
        int bestScore = MadLevelProfile.GetLevelInteger(MadLevel.currentLevelName, "best score");

        // If Player's score is greater than best score,set new best score
        if (destroyUnit._score > bestScore)
        {
            MadLevelProfile.SetLevelInteger(MadLevel.currentLevelName, "best score", destroyUnit._score);
            bestScore = destroyUnit._score;
        }

        // Show player Score and best score
        scoreText.text     = destroyUnit._score.ToString();
        bestScoreText.text = bestScore.ToString();

        // Set current level Star rating based on Player's Score
        if (destroyUnit._score >= puzzleGen._3starPoint)
        {
            MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_3", true);
        }
        if (destroyUnit._score >= puzzleGen._2starPoint)
        {
            MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_2", true);
        }
        if (destroyUnit._score >= puzzleGen._1starPoint)
        {
            MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
            MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
        }
    }
コード例 #6
0
        // Random and progressive selection from group of all dots
        IEnumerator RandomPick()
        {
            Transform  randomCell;
            List <int> randomNumbers = new List <int>();
            var        numberOfCells = this.gameObject.transform.childCount;

            for (int i = 0; i <= numberOfCells; i++)
            {
                int index = Random.Range(0, numberOfCells);

                if (!randomNumbers.Contains(index))
                {
                    randomNumbers.Add(index);
                    randomCell = this.gameObject.transform.GetChild(index);
                    randomCell.gameObject.SetActive(true);
                    yield return(new WaitForSeconds(1f));

                    randomCell.gameObject.SetActive(false);

                    // End of game
                    if (randomNumbers.Count == numberOfCells)
                    {
                        var canvas = GameObject.Find("Level Canvas");

                        Instantiate(endPanel, canvas);
                        MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                    }
                }
                else
                {
                    if (i < numberOfCells)
                    {
                        i--;
                    }
                }
            }
        }
コード例 #7
0
    void OnGUI()
    {
        if (timer != 0)
        {
            GUI.Box(new Rect(1170, 127, 80, 30), "Score : " + score.ToString("0"), menuStyleScore);

            GUI.Box(new Rect(20, 30, 80, 30), "Waktu :" + timer.ToString("0"), menuStyleScore);
        }
        timer -= Time.deltaTime;

        if (timer < 0 && score <= level || healthBarSlider.value < 0.0f)
        {
            //Time.timeScale = 0;
            showgui = 0;
            timer   = 0;
            //Debug.Log("tes");
            //Time.timeScale = 0;
            GUI.Box(new Rect(200, 140, 950, 400), "Anda kalah, Score : \n" + score.ToString("0") + "\n " +
                    "Untuk kembali ke menu awal miringkan tangan ke kiri \n\n Untuk mengulangi permainan " +
                    "miringkan tangan ke kanan", boxStyle);
            //Time.timeScale = 1;

            if (pxsLeapInput.GetHandAxis("Rotation") > 0)
            {
                //Debug.Log("kanan");
                //		Time.timeScale = 1;
                if (Application.loadedLevelName == "level1")
                {
                    Application.LoadLevel("level1");
                }
                else if (Application.loadedLevelName == "level2")
                {
                    Application.LoadLevel("level2");
                }
                else if (Application.loadedLevelName == "level3")
                {
                    Application.LoadLevel("level3");
                }
                else if (Application.loadedLevelName == "level4")
                {
                    Application.LoadLevel("level4");
                }
                else
                {
                    Application.LoadLevel("level5");
                }
            }
            if (pxsLeapInput.GetHandAxis("Rotation") < 0)
            {
                Application.LoadLevel("main_menu_final");
            }
        }

        if (score > level && showgui > 0 || timer < 0 && score >= level)
        {
            timer = 0;
            //Time.timeScale = 0;
            GUI.Box(new Rect(200, 140, 950, 400), "Anda Menang, Score : \n" + score.ToString("0") + "\n Untuk kembali ke menu awal miringkan tangan ke kiri \n\n Untuk lanjut ke level berikutnya miringkan tangan ke kanan", boxStyle);
            if (pxsLeapInput.GetHandAxis("Rotation") > 0)
            {
                //Debug.Log("kanan");
                //	Time.timeScale = 1;
                if (Application.loadedLevelName == "level1")
                {
                    Application.LoadLevel("level2");
                }
                else if (Application.loadedLevelName == "level2")
                {
                    Application.LoadLevel("level3");
                }
                else if (Application.loadedLevelName == "level3")
                {
                    Application.LoadLevel("level4");
                }
                else if (Application.loadedLevelName == "level4")
                {
                    Application.LoadLevel("level5");
                }
                else
                {
                }
            }
            if (pxsLeapInput.GetHandAxis("Rotation") < 0)
            {
                //MadLevel.LoadLevelByName ("Level Select Screen");
                Application.LoadLevel("main_menu_final");
            }
        }

        if (timer <= 0 && score >= level)
        {
            if (Application.loadedLevelName == "level2")
            {
                if (score > 15)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_2", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_3", true);

                    MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
                else if (score > 10)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_2", true);

                    //MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
                else if (score > 5)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);

                    MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
            }
            else if (Application.loadedLevelName == "level1")
            {
                if (score > 18)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_2", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_3", true);

                    MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
                else if (score > 13)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_2", true);

                    //MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
                else if (score > 7)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);

                    MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
            }
            else if (Application.loadedLevelName == "level3")
            {
                if (score > 21)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_2", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_3", true);

                    MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
                else if (score > 18)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_2", true);

                    //MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
                else if (score > 15)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);

                    MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
            }
            else if (Application.loadedLevelName == "level4")
            {
                if (score > 24)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_2", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_3", true);

                    MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
                else if (score > 21)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_2", true);

                    //MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
                else if (score > 18)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);

                    MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
            }
            else
            {
                level = level5;
                if (score > 27)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_2", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_3", true);

                    MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
                else if (score > 24)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_2", true);

                    //MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
                else if (score > 21)
                {
                    MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);

                    MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
                }
            }



            //MadLevel.LoadLevelByName("Level Select Screen");
        }
    }