コード例 #1
0
    // Attack 3
    public void Rest()
    {
        //regerate some amount of health at the end
        BonHealth myHealth = GetComponentInChildren <BonHealth>();

        myHealth.GainHealth(amountHealed);
    }
コード例 #2
0
    // Originally OnCollisionEnter2D(Collision2D col)
    void OnTriggerEnter2D(Collider2D col)
    {
        GameObject foe = col.gameObject;

        if (foe.GetComponentInChildren <BonHealth>())
        {
            BonHealth badHealth = foe.GetComponentInChildren <BonHealth>();
            badHealth.LoseHealth(dmg);
            if (foe.GetComponentInParent <Rigidbody2D>())
            {
                Rigidbody2D badrb2d = foe.GetComponentInParent <Rigidbody2D>();
                print("contact");
                badrb2d.AddForce(new Vector2(rightForce, upForce), ForceMode2D.Force);
            }
        }
    }
コード例 #3
0
    // Originally OnCollisionEnter2D(Collision2D col)
    void OnTriggerEnter2D(Collider2D col)
    {
        GameObject foe = col.gameObject;

        if (foe.GetComponentInChildren <BonHealth>())
        {
            BonHealth badHealth = foe.GetComponentInChildren <BonHealth>();
            badHealth.GainHealth(healing);
            if (foe.GetComponentInParent <Rigidbody2D>())
            {
                Rigidbody2D badrb2d = foe.GetComponentInParent <Rigidbody2D>();
                print("contact");
                badrb2d.AddForce(new Vector2(rightForce, upForce), ForceMode2D.Force);
                if (deathOnImpact)
                {
                    Destroy(gameObject, 0.1f);
                }
            }
        }
    }