示例#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);
        }
    }
示例#2
0
    /// <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);
        }
    }
示例#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);
        }
    }
示例#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);
            }
        }
    }
示例#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);
            }
        }
    }