Example #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (gameObject.tag == "Obstacle")
        {
            if (other.gameObject.tag == "Knife")
            {
                other.gameObject.GetComponent <Shoot>().isShooting = false;
                moviendose = false;
                gameObject.GetComponent <Animator>().SetBool("IsDead", true);
                Invoke("destruir", 0.5f);
            }
        }
        if (gameObject.tag == "PowerUp")
        {
            if (other.gameObject.tag == "Knife")
            {
                HitSomething.pointPlus      = 2;
                ControlKniveHit.powercount += 2;
                other.gameObject.GetComponent <Shoot>().isShooting = false;
                moviendose = false;
                //gameObject.GetComponent<Animator>().SetBool("IsDead", true);
                //Destroy(other.gameObject);
                Destroy(gameObject);
                Destroy(other.gameObject);
                //ControlKniveHit.knives--;
                ControlKniveHit.GastarAmmo();
                if (ControlKniveHit.knives > 0)
                {
                    Knive = GameObject.FindGameObjectWithTag("Target").GetComponent <HitSomething>().Knive;
                    Instantiate(Knive);
                }
                else if (ControlKniveHit.knives == 0)
                {
                    ControlKniveHit.LastHit = true;
                }
                ControlKniveHit.ispowerActive = true;

                //Invoke("destruir", 0.5f);
            }
        }

        if (other.gameObject.tag == "Salidas")
        {
            Destroy(gameObject);
        }
    }
Example #2
0
    private void OnTriggerStay(Collider other)
    {
        if (gameObject.tag == "Target")
        {
            if (other.gameObject.tag == "Knife")
            {
                if (MenuControl.playSound)
                {
                    GetComponent <AudioSource>().Play();
                }

                other.gameObject.GetComponent <Shoot>().isShooting = false;
                other.gameObject.tag = "KnifeHit";
                other.gameObject.transform.parent = gameObject.transform;
                ControlKniveHit.GastarAmmo();
                ControlKniveHit.points += pointPlus;

                if (ControlKniveHit.knives > 0)
                {
                    Instantiate(Knive);
                }
                else if (ControlKniveHit.knives == 0)
                {
                    ControlKniveHit.LastHit = true;
                }
            }
        }

        else if (gameObject.tag == "KnifeHit")
        {
            if (other.gameObject.tag == "Knife")
            {
                Destroy(GameObject.FindGameObjectWithTag("Target"));
                ControlKniveHit.kniveState = ControlKniveHit.Estate.End;
            }
        }
    }