コード例 #1
0
ファイル: Entity.cs プロジェクト: monkeylashes/lalala
    private void OnCollisionEnter(Collision collision)
    {
        if (Diet == null || CompareTag("plant"))
        {
            return;
        }

        if (collision.gameObject.CompareTag("wall"))
        {
            Ai.SetState(AI.State.Searching);
            return;
        }

        if (Diet.Contains(collision.gameObject.tag))
        {
            //Debug.Log("found food: " + collision.gameObject);
            //Instantiate(particle, collision.gameObject.transform.position, Quaternion.identity);
            //collision.gameObject.SetActive(false);
            //Destroy(collision.gameObject, Random.Range(2f, 10f));
            collision.gameObject.GetComponent <Entity>().Die();
            Hunger -= nutrition;

            if (Hunger <= 0f)
            {
                //Instantiate(gameObject);
                GameManager.Resurrect(gameObject.tag, gameObject.transform);
                Hunger = 8f;
            }
            Ai.ClearState();
        }
        else
        {
            Ai.ClearState();
        }
    }