Example #1
0
    public IEnumerator SpawnAfterSpawnTime(UnitSlot.UnitSlotData data)
    {
        spawningText.text    = data.Name;
        spaningTimeText.text = data.SpawnTime + " sec";
        currentlySpawing     = true;
        float startTime = Time.time;

        yield return(new WaitWhile(() =>
        {
            spaningTimeText.text = data.SpawnTime - (Time.time - startTime) + " sec";
            return Time.time - startTime < data.SpawnTime;
        }));

        Spawner.SpawnerInstance.CmdSpawnUnit((int)data.Unit);
        slots.RemoveAt(0);
        for (int i = slots.Count - 1; i >= slots.Count; i--)
        {
            slots[i] = slots[i + 1];
        }

        currentlySpawing = false;
        UpdateQueue();
        spawningText.text    = "-";
        spaningTimeText.text = "- sec";
    }
Example #2
0
 public bool Add(UnitSlot.UnitSlotData data)
 {
     if (slots.Count >= images.Length)
     {
         return(false);
     }
     if (Inventory.IronResource < data.IronCost)
     {
         return(false);
     }
     if (Inventory.OilResource < data.OilCost)
     {
         return(false);
     }
     Inventory.IronResource -= data.IronCost;
     Inventory.OilResource  -= data.OilCost;
     slots.Add(data);
     UpdateQueue();
     return(true);
 }