Example #1
0
        static void Main(string[] args)
        {
            Animal animal = new Animal();

            animal.Introduce();

            Cabra caba = new Cabra();

            caba.Introduce();


            Console.WriteLine("-----------------");

            animal = caba;
            animal.Introduce();


            Console.ReadKey();
        }
Example #2
0
    /*private void Explosion()
     * {
     *      Instantiate(Blood, PuntoExplosion.transform.position, Quaternion.identity);
     * }
     */

    private void OnTriggerEnter(Collider other)
    {
        Debug.Log("hit " + other.gameObject);

        if (other.gameObject.CompareTag("Enemy"))
        {
            //
            //	Destroy(blood,2f);
            ID = other.GetComponent <Transform>();

            int monster = EncuentraID(ID);


            switch (monster)
            {
            case 1:
                if (other.gameObject.GetComponentInParent <Ogro>().saludEnemigo > 1)
                {
                    print("Ogro");
                    ogro = other.GetComponentInParent <Ogro>();
                    ogro.saludEnemigo -= 100f;
                    print("Enemigo hit, salud:" + ogro.saludEnemigo.ToString());
                    ogro.barra_Salud.fillAmount = ogro.saludEnemigo / 100f;
                }

                {
                    if (other.gameObject.GetComponentInParent <Ogro>().saludEnemigo <= 0)
                    {
                        Contador_Monedas.scoreValue += ogro.numMonedas;
                        //	this.GetComponent<SphereCollider>().enabled = false;
                        other.GetComponentInParent <NavMeshControl>().enabled = false;
                        other.GetComponentInParent <NavMeshAgent>().enabled   = false;
                        other.GetComponentInParent <Animator>().enabled       = false;

                        //Desactivo barra de salud
                        ogro.barra_Salud.enabled = false;
                        other.GetComponentInParent <DestroyRag>().isRagdoll = true;
                        Destroy(other.gameObject);
                        //Destroy(gameObject);
                    }
                }

                break;

            case 2:
                if (other.gameObject.GetComponentInParent <Esqueleto>().saludEnemigo > 1)
                {
                    print("Esqueleto");
                    Skeleton = other.GetComponentInParent <Esqueleto>();
                    Skeleton.saludEnemigo -= 100f;
                    print("Enemigo hit, salud:" + Skeleton.saludEnemigo.ToString());
                    Skeleton.barra_Salud.fillAmount = Skeleton.saludEnemigo / 100f;
                }

                {
                    if (other.gameObject.GetComponentInParent <Esqueleto>().saludEnemigo <= 0)
                    {
                        scoreValue += Skeleton.numMonedas;
                        //this.GetComponent<SphereCollider>().enabled = false;
                        other.GetComponentInParent <NavMeshControl>().enabled = false;
                        other.GetComponentInParent <NavMeshAgent>().enabled   = false;
                        other.GetComponentInParent <Animator>().enabled       = false;

                        //Desactivo barra de salud
                        Skeleton.barra_Salud.enabled = false;
                        other.GetComponentInParent <DestroyRag>().isRagdoll = true;
                        Destroy(other.gameObject);
                        //	Destroy(gameObject);
                    }
                }
                break;

            case 3:
                if (other.gameObject.GetComponentInParent <Cabra>().saludEnemigo > 1)
                {
                    print("Cabra");
                    cabra = other.GetComponentInParent <Cabra>();
                    cabra.saludEnemigo -= 100f;
                    print("Enemigo hit, salud:" + cabra.saludEnemigo.ToString());
                    cabra.barra_Salud.fillAmount = cabra.saludEnemigo / 100f;
                }

                {
                    if (other.gameObject.GetComponentInParent <Cabra>().saludEnemigo <= 0)
                    {
                        scoreValue += cabra.numMonedas;
                        //	this.GetComponent<SphereCollider>().enabled = false;
                        other.GetComponentInParent <NavMeshControl>().enabled = false;
                        other.GetComponentInParent <NavMeshAgent>().enabled   = false;
                        other.GetComponentInParent <Animator>().enabled       = false;

                        //Desactivo barra de salud
                        cabra.barra_Salud.enabled = false;
                        other.GetComponentInParent <DestroyRag>().isRagdoll = true;
                        Destroy(other.gameObject);
                        //Destroy(gameObject);
                    }
                }
                break;

            case 4:
                if (other.gameObject.GetComponentInParent <Triton>().saludEnemigo > 1)
                {
                    print("Triton");
                    triton = other.GetComponentInParent <Triton>();
                    triton.saludEnemigo -= 100f;
                    print("Enemigo hit, salud:" + triton.saludEnemigo.ToString());
                    triton.barra_Salud.fillAmount = triton.saludEnemigo / 100f;
                }

                {
                    if (other.gameObject.GetComponentInParent <Triton>().saludEnemigo <= 0)
                    {
                        scoreValue += triton.numMonedas;
                        //	this.GetComponent<SphereCollider>().enabled = false;
                        other.GetComponentInParent <NavMeshControl>().enabled = false;
                        other.GetComponentInParent <NavMeshAgent>().enabled   = false;
                        other.GetComponentInParent <Animator>().enabled       = false;

                        //Desactivo barra de salud
                        triton.barra_Salud.enabled = false;
                        other.GetComponentInParent <DestroyRag>().isRagdoll = true;
                        Destroy(other.gameObject);
                        //	Destroy(gameObject);
                    }
                }
                break;
            }
        }

        //E.numVidas--;
    }