Beispiel #1
0
    /// <summary>
    /// On collision, it shows a splash
    /// </summary>
    /// <param name="other"></param>
    void OnTriggerEnter2D(Collider2D other)
    {
        //we also add a debug log to know what the projectile touch
        //Debug.Log("Projectile Collision with " + other.gameObject);

        bool notsplash = false;

        MoonboyController e = other.GetComponent <MoonboyController>();

        if (e != null)
        {
            //Debug.Log("ASIENDO DANIO");
            e.ChangeHealth(-1);
            if (e.isdashing)
            {
                notsplash = true;
            }
        }

        if (!notsplash)
        {
            Destroy(gameObject);
            GameObject splashhit = Instantiate(splashobject, rigidbody2d.position, Quaternion.identity);
        }
    }
    /// <summary>
    /// Damages main character by one if it detects collision
    /// </summary>
    /// <param name="other"></param>
    void OnTriggerStay2D(Collider2D other)
    {
        MoonboyController controller = other.GetComponent <MoonboyController>();

        if (controller != null)
        {
            controller.ChangeHealth(-1);
        }
    }
Beispiel #3
0
    /// <summary>
    /// Once it collides with the main character, it decreases its health by 1.
    /// </summary>
    /// <param name="collision"></param>
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("Projectile Collision with " + collision.gameObject);

        MoonboyController e = collision.GetComponent <MoonboyController>();

        if (e != null)
        {
            e.ChangeHealth(-2);
        }
    }
Beispiel #4
0
    /// <summary>
    /// Adds health to the main character
    /// </summary>
    /// <param name="other"></param>
    void OnTriggerEnter2D(Collider2D other)
    {
        MoonboyController controller = other.GetComponent <MoonboyController>();

        if (controller != null)
        {
            if (controller.health < controller.maxHealth)
            {
                controller.ChangeHealth(1);
                Destroy(gameObject);
            }
        }
    }
Beispiel #5
0
    /// <summary>
    /// On collision, it damages the main character unless it's blocking
    /// </summary>
    /// <param name="collision"></param>
    private void OnTriggerEnter2D(Collider2D collision)
    {
        MoonboyController e = collision.GetComponent <MoonboyController>();

        if (e != null)
        {
            if (e.currentState == PlayerState.blocking)
            {
                Debug.Log(transform.parent.GetComponent("EnemyController"));

                EnemyController ec = transform.parent.GetComponent <EnemyController>();

                StartCoroutine(Parried(ec));

                return;
            }
            else
            {
                e.ChangeHealth(-1);
            }
        }
    }