Exemple #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        string collisionTag = collision.gameObject.tag;

        //IEnumerator coroutine = WaitForCollider();

        if (objType == "star")
        {
            if (collisionTag != "Ground" && collisionTag != "Player")
            {
                colliderPU.enabled = false;
            }
        }
        //else if (objType == "mushroom")
        //{
        //    if (collisionTag == "Enemy")
        //    {
        //        colliderPU.enabled = false;

        //        StartCoroutine(coroutine);
        //    }
        //}


        if (collisionTag != "Block" && collisionTag != "Ground" && collisionTag != "Player" && colliderPU.enabled) //Mushroom turns around when hitting collidable object that is not player or ground
        {
            moveSpeed *= -1;
        }
        else if (collisionTag == "Player")
        {
            //Player gets power up
            if (objType == "mushroom")
            {
                trackerPU.isBig = true;
            }
            else if (objType == "flower")
            {
                trackerPU.isFlower = true;
            }
            else
            {
                trackerPU.isStar = true;
            }

            trackerScore.ScoreChecker(objType);

            trackerPU.TransformPlayer();
            Destroy(gameObject);
        }
    }
    public void DeathChecker()
    {
        if (trackerPU.isBig)
        {
            trackerPU.isBig = false;

            trackerPU.TransformPlayer();
        }
        else if (!trackerPU.isBig)
        {
            Debug.Log("Mario is small");

            audioSource      = GameObject.FindGameObjectWithTag("Player").GetComponent <AudioSource>();
            audioSource.clip = death;
            StartCoroutine("KillPlayer");
        }
    }