Exemplo n.º 1
0
    //Drop object
    public void Drop(AnimalCharacter animalCharacter)
    {
        MakeDynamic();
        GetComponent <Rigidbody>().AddForce(animalCharacter.transform.forward * 10f);
        this.occupied = false;
        animalCharacter.bHoldObject = false;
        animalCharacter.holdObject  = null;

        //Register affordance
        UIAffordance.RegisterObject(this.gameObject);
    }
Exemplo n.º 2
0
 private void Update()
 {
     if (!occupied)
     {
         stayFreshTime -= Time.deltaTime;
         if (stayFreshTime < 0)
         {
             //Unregister game object at affordance map
             UIAffordance.UnregisterObject(this.gameObject);
             Destroy(this.gameObject);
         }
     }
 }
Exemplo n.º 3
0
    //Plant seed on it
    void Plant(ASeed seed)
    {
        hasPlants     = true;
        seed.occupied = true;
        seed.MakeStatic();
        seed.transform.parent        = this.transform;
        seed.transform.localPosition = Vector3.zero;

        GetComponent <BoxCollider>().enabled = false;


        StartCoroutine(GrowSeed(seed));

        //Grow seed to a tree
        IEnumerator GrowSeed(ASeed aSeed)
        {
            //Debug.Log("Soil Plant: " + seed.objectType.ToString());

            yield return(new WaitForSeconds(aSeed.growTime));

            //A seed becomes a tree;
            GameObject tree = Instantiate(seed.plantPrefab, this.transform.position, Quaternion.identity);

            tree.transform.parent = this.transform;

            //calculate size
            Vector3 boxSize  = tree.GetComponent <BoxCollider>().size;
            Vector3 soilSize = this.GetComponent <BoxCollider>().size;

            float treeSize = soilSize.x / (boxSize.x + 0.1f);

            tree.transform.localScale = new Vector3(treeSize, treeSize, treeSize);

            //Distroy seed and soil
            UIAffordance.UnregisterObject(aSeed.gameObject);
            Destroy(aSeed.gameObject);
        }
    }
Exemplo n.º 4
0
    //Eat food
    public void Eat(AnimalCharacter animalCharacter)
    {
        animalCharacter.StopMove();

        //Debug.Log("AFood(eat): " + this.objectType.ToString());
        animalCharacter.currentActivity = EActivity.Eat;
        StartCoroutine(EatFood());

        //Eat animation
        animalCharacter.animator.SetInteger("animation", 4);
        IEnumerator EatFood()
        {
            yield return(new WaitForSeconds(this.eatTime));

            animalCharacter.SetIdle();

            //Gain fullness
            animalCharacter.fullness = Mathf.Min(animalCharacter.fullness + fullGain, 1f);

            //Distroy this food
            UIAffordance.UnregisterObject(this.gameObject);
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 5
0
    public List <string> animalCharacterNames; //hold animal character names

    protected void AWake()
    {
        UIAffordance.RegisterObject(this.gameObject);
    }