Пример #1
0
 // Update is called once per frame
 void Update()
 {
     if (drillProgress < drillTime)
     {
         drillProgress += Time.deltaTime;
     }
     if (drillProgress >= drillTime)
     {
         drillProgress = 0;
         ItemSpawning.Spawn(new Item(drops[(int)Mathf.Floor(Random.Range(0, drops.Length))], dropAmount), transform.position + itemOffset);
         if (drillEffect != null)
         {
             Instantiate(drillEffect, transform.position + itemOffset, Quaternion.identity);
         }
     }
 }
    void OnTriggerEnter2D(Collider2D col)
    {
        if (!requirementsMet)
        {
            return;
        }
        Block b = col.GetComponent <Block>();

        if (b)
        {
            if (b.fluid)
            {
                ItemSpawning.Spawn(new Item(b.DropItem, b.dropAmount), transform.position + (Vector3)offset);
                Destroy(b.gameObject);
            }
        }
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        int  i = 0;
        bool b = false;

        foreach (Item item in storedItems)
        {
            if (item.amount >= recipe.input[i].amount)
            {
                b = true;
            }
            else
            {
                b = false;
            }
            i++;
        }
        if (b)
        {
            if (smeltProgress < recipe.craftDuration)
            {
                smeltProgress += Time.deltaTime * smelterTier;
            }
            if (smeltProgress >= recipe.craftDuration)
            {
                ItemSpawning.Spawn(recipe.output, transform.position + spawnedItemOffset);
                smeltProgress = 0;
                int i2 = 0;
                foreach (Item item in storedItems)
                {
                    item.amount -= recipe.input[i2].amount;
                    i2++;
                }
            }
        }
    }