コード例 #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Player")
        {
            other.gameObject.GetComponent <PlayerController>().enabled = false;
            canvas.sortingLayerName = "UI";
            storeFront.SetActive(true);

            Score_End.text = PlayerController.currentLevelScore.ToString();

            Score_End_Best.text = GameManagerNew.playerData[SceneNumber].bestScore.ToString();

            if (PlayerController.currentLevelScore > 1)
            {
                Medal_Image.sprite = Medal_One;
            }

            if (PlayerController.currentLevelScore >= 500)
            {
                Medal_Image.sprite = Medal_Two;
            }

            if (PlayerController.currentLevelScore >= 1000)
            {
                Medal_Image.sprite = Medal_Three;
            }


            // Replace old score with new score by passing level name, and stripping "level" string to leave only number
            //GameManager.Instance.SaveLevelProgress(Convert.ToInt32(SceneManager.GetActiveScene().name.ToString().Replace("Level", "")), PlayerController.currentLevelScore);


            // First check to see if this level has already been unlocked and is just being replayed
            if (!GameManagerNew.playerData[SceneNumber].levelPlayedBefore)
            {
                GameManagerNew.playerData[SceneNumber + 1].levelEnabled = true;
            }
            else
            {
                Debug.Log("Message from " + GetType().Name + ": This level HAS been played");
            }

            if (GameManagerNew.playerData[SceneNumber].bestScore < Convert.ToInt32(Score_End.text))
            {
                Debug.Log("End of level reached. Current score is greater than previous");
                GameManagerNew.playerData[SceneNumber].bestScore = Convert.ToInt32(Score_End.text);
            }

            Debug.Log(Convert.ToInt32(Score_End));

            // Save the player prefs
            GameManagerNew.SaveGameData();
        }
    }
コード例 #2
0
 public void CloseErrorMessage()
 {
     ErrorMessageObject.SetActive(false);
     GameManagerNew.SaveGameData();
     Application.Quit();
 }
コード例 #3
0
 public void CloseGift()
 {
     GameManagerNew.SaveGameData();
     GiftPanel.SetActive(false);
 }