示例#1
0
文件: CatFood.cs 项目: geniejeans/SP4
    public void OnCollisionEnter(Collision other)
    {
        CharacterInstance character = other.gameObject.GetComponent <CharacterInstance>();

        if (other.gameObject.name == "Character")
        {
            if (character.GetHealth() < 20)
            {
                int health;
                health = Random.Range(1, 10);
                character.AddHealth(health);
            }

            Destroy(gameObject);
        }
    }