Ejemplo n.º 1
0
    // Hitting colliders
    void OnCollisionEnter2D(Collision2D other)
    {
        if (!isFinished)
        {
            if (other.gameObject.tag == "powerUp")
            {
                if (playerLives == 1)
                {
                    animator.Play("fromSmallToBig");
                }
                else if (playerLives == 2)
                {
                    animator.Play("fromBigToFire");
                }
                audioManager.MarioPwrUp();
                Destroy(other.gameObject);
                scores.AddScoreAmount(1000);
                GameObject e = GameObject.Instantiate(scoreLable);
                e.transform.position = new Vector3(transform.position.x - 0.5f, transform.position.y + 1.5f, -8f);
                sc = e.GetComponent <ScoreLableScript> ();
                if (sc != null)
                {
                    sc.setScore(1000);
                }
                if (playerLives < 3)
                {
                    playerLives++;
                }
            }

            if (other.gameObject.tag == "Flag")
            {
                isFinished             = true;
                other.collider.enabled = false;
                player.isKinematic     = true;
                audioManager.stopBackgroundMusic();
                audioManager.PlayFlagPole();
                GameObject.Find("FinishFlag").GetComponent <flagCompleteScript>().activate();
            }

            if (other.gameObject.tag == "SuperStarTag")
            {
                audioManager.MarioPwrUp();
                audioManager.stopBackgroundMusic();
                audioManager.PlayStarMusic();
                Destroy(other.gameObject);
                hasSuperStar       = true;
                superStarCountDown = 500;
                animator.SetBool("hasSuperStar", true);
            }
        }
    }
Ejemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Player")
        {
            GameObject e = GameObject.Instantiate(scoreLable);
            e.transform.position = new Vector3(transform.position.x - 0.5f, transform.position.y + 1.5f, -8f);
            sc = e.GetComponent <ScoreLableScript> ();
            if (sc != null)
            {
                sc.setScore("1UP");
            }

            GameObject.Find("AudioController").GetComponent <AudioManager> ().PlayExtra();
            Destroy(this.gameObject);
        }
    }
Ejemplo n.º 3
0
    // Method if enemy is hit by fireBall
    public void gotShot()
    {
        gameObject.layer = 2;
        score.AddScoreAmount(100);
        GameObject e = GameObject.Instantiate(scoreLable);

        e.transform.position = new Vector3(enemy.transform.position.x - 0.5f, enemy.transform.position.y + 1.5f, -8f);
        sc = e.GetComponent <ScoreLableScript> ();
        if (sc != null)
        {
            sc.setScore(100);
        }

        //velocity = 0;
        enemy.velocity             = new Vector2(enemy.velocity.x, 5f);
        enemy.transform.localScale = new Vector2(enemy.transform.localScale.x, -enemy.transform.localScale.y);

        // Disable collider so enemy falls through the floor
        this.GetComponent <Collider2D> ().enabled = false;
    }
Ejemplo n.º 4
0
    void Dies()
    {
        GetComponent <Collider2D>().enabled = false;

        velocity = 0;
        anim.SetBool("isHit", true);

        GameObject e = GameObject.Instantiate(scoreLable);

        e.transform.position = new Vector3(transform.position.x - 0.5f, transform.position.y + 1.5f, -8f);
        sc = e.GetComponent <ScoreLableScript> ();
        if (sc != null)
        {
            sc.setScore(100);
        }

        //text.text = "100";
        gameObject.tag = "neutralized";
        Destroy(this.gameObject, 0.5f);
    }
Ejemplo n.º 5
0
    void OnCollisionEnter2D(Collision2D other)
    {
        Debug.Log("flag");
        if (other.gameObject.tag == "Player")
        {
            if (player.transform.position.y > 2 && player.transform.position.y < 3)
            {
                score.AddScoreAmount(100);
                GameObject e = GameObject.Instantiate(scoreLable);
                e.transform.position = new Vector3(transform.position.x - 0.5f, transform.position.y + 1.5f, -8f);
                sc = e.GetComponent <ScoreLableScript> ();
                if (sc != null)
                {
                    sc.setScore(100);
                }
            }
            if (player.transform.position.y > 3 && player.transform.position.y < 5)
            {
                score.AddScoreAmount(400);
                GameObject e = GameObject.Instantiate(scoreLable);
                e.transform.position = new Vector3(transform.position.x - 0.5f, transform.position.y + 1.5f, -8f);
                sc = e.GetComponent <ScoreLableScript> ();
                if (sc != null)
                {
                    sc.setScore(400);
                }
            }
            if (player.transform.position.y > 5 && player.transform.position.y < 7)
            {
                score.AddScoreAmount(800);
                GameObject e = GameObject.Instantiate(scoreLable);
                e.transform.position = new Vector3(transform.position.x - 0.5f, transform.position.y + 1.5f, -8f);
                sc = e.GetComponent <ScoreLableScript> ();
                if (sc != null)
                {
                    sc.setScore(800);
                }
            }
            if (player.transform.position.y > 7 && player.transform.position.y < 11)
            {
                score.AddScoreAmount(2000);
                GameObject e = GameObject.Instantiate(scoreLable);
                e.transform.position = new Vector3(transform.position.x - 0.5f, transform.position.y + 1.5f, -8f);
                sc = e.GetComponent <ScoreLableScript> ();
                if (sc != null)
                {
                    sc.setScore(2000);
                }
            }

            if (player.transform.position.y > 11)
            {
                score.AddScoreAmount(4000);
                GameObject e = GameObject.Instantiate(scoreLable);
                e.transform.position = new Vector3(transform.position.x - 0.5f, transform.position.y + 1.5f, -8f);
                sc = e.GetComponent <ScoreLableScript> ();
                if (sc != null)
                {
                    sc.setScore(4000);
                }
            }
        }
    }