Ejemplo n.º 1
0
    //public delegate void TriggerGameOver();
    //public TriggerGameOver GameOverTrigger;

    // Start is called before the first frame update
    void Start()
    {
        Instance = this;
        TimerNum = GetComponent <Text>();
        CountDownTimer.GetInstance().CountDown("main_timer", 60f, (t) =>
        {
            TimerNum.text = string.Format("{0:0}", t);
        }, () =>
        {
            Debug.Log("time is up");

            if (ScoreManager.Instance.GetScore() > 70)
            {
                Game.GetInstance().ToHighScore();
                //SceneManager.LoadScene("HighScore");
            }

            else if (ScoreManager.Instance.GetScore() < 30)
            {
                Game.GetInstance().ToLowScore();
                //SceneManager.LoadScene("LowScore");
            }

            else
            {
                Game.GetInstance().ToMidScore();
                //SceneManager.LoadScene("MidScore");
            }

            CountDownTimer.GetInstance().ClearAllTimers();
        });
    }
Ejemplo n.º 2
0
    //[System.Obsolete]
    void OnCollisionStay2D(Collision2D collision)
    {
        if ("Ground".Equals(collision.gameObject.name))
        {
            playerJumping = false;
        }
        if ("Food(Clone)".Equals(collision.gameObject.name) && !playerCatchFood)
        {
            ScoreManager.Instance.AddToScore(10);
            addScorelLabel.text = "+ 10";
            playerCatchFood     = true;
            rb.isKinematic      = true;
            rb.constraints      = RigidbodyConstraints2D.FreezePosition | RigidbodyConstraints2D.FreezeRotation;
            SetSprite("player_jumpMid");
            collision.gameObject.transform.SetParent(gameObject.transform);
            Destroy(collision.gameObject.GetComponent <Rigidbody2D>());
            playerFacing = PlayerFacing.MID;
            collision.gameObject.transform.position = gameObject.transform.Find("CatchPosition").transform.position;


            CountDownTimer.GetInstance().CountDown("addScorelLabel_timer", 1f, () =>
            {
                addScorelLabel.text = "";
            });

            CountDownTimer.GetInstance().CountDown("playerFall_timer", 0.3f, () =>
            {
                rb.isKinematic = false;
                rb.constraints = RigidbodyConstraints2D.None | RigidbodyConstraints2D.FreezeRotation;
                SetSprite("player_StandMid");
                collision.gameObject.transform.position = gameObject.transform.Find("FoodPosition").transform.position;
                eatAudio.PlayDelayed(0.8f);
            });


            CountDownTimer.GetInstance().CountDown("eatingFood_Timer", 3.2f, () => {
                playerCatchFood = false;
                Destroy(gameObject.transform.Find("Food(Clone)").gameObject);
            });
        }
    }