Ejemplo n.º 1
0
    public virtual C_Food SpawnFood(GameObject FoodPrefab)
    {
        Vector3 randVec  = GetTankBounds();
        Vector3 spawnLoc = transform.position + new Vector3(Random.Range(-1.0f, 1.0f) * randVec.x, Random.Range(-1.0f, 1.0f) * randVec.y, Random.Range(-1.0f, 1.0f) * randVec.z);

        GameObject newFood = Instantiate(FoodPrefab, spawnLoc, Quaternion.identity);

        C_Food foodScript = newFood.GetComponent <C_Food>();

        return(foodScript);
    }
Ejemplo n.º 2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Food")
        {
            if (IsHungry)
            {
                C_Food foodComp = other.GetComponent <C_Food> ();

                if (foodComp != null)
                {
                    Hunger += foodComp.FoodValue;
                    Destroy(other.gameObject);
                }
            }
        }
    }