Пример #1
0
 public override bool UseItem(Item item, out Item newItem)
 {
     newItem = item;
     if (item.prefabName.Equals(GROWTH_ITEM))
     {
         if (growthState == GrowthStates.Growing)
         {
             newItem     = null;
             growthState = GrowthStates.FullyGrown;
         }
     }
     else if (growthState == GrowthStates.FullyGrown)
     {
         broken       = true;
         coll.enabled = false;
         foreach (GameObject drop in drops)
         {
             GameObject dropItem = (GameObject)Instantiate(drop);
             Item       i        = dropItem.GetComponent <Item> ();
             i.Setup();
             i.DropItem(transform.position + new Vector3(Random.Range(-dropBounds.x, dropBounds.x), Random.Range(-dropBounds.y, dropBounds.y), 0));
         }
     }
     UpdateSprite();
     return(true);
 }
Пример #2
0
    new void Start()
    {
        base.Start();
        usableItemTypes       = new[] { typeof(Weapon) };
        usableItemPrefabNames = new[] { GROWTH_ITEM };

        dropBounds = coll.bounds.extents;
        if (sRend.sprite.Equals(budTileSprite))
        {
            growthState = GrowthStates.Planted;
        }
        else if (sRend.sprite.Equals(growingTileSprite))
        {
            growthState = GrowthStates.Growing;
        }
        else
        {
            growthState = GrowthStates.FullyGrown;
        }
    }
Пример #3
0
 public override void Load(Hashtable tsd)
 {
     base.Load(tsd);
     growthState = (GrowthStates)tsd ["growing"];
     UpdateSprite();
 }
Пример #4
0
 public void Plant()
 {
     growthState = GrowthStates.Planted;
     UpdateSprite();
 }