Ejemplo n.º 1
0
 public override void work()
 {
     //Debug.Log("work Stronghold");
     if (minersQueue.Count > 0)
     {
         for (int i = minersQueue.Count; i > 0; i--)
         {
             Miner miner = minersQueue[(i - 1)].GetComponent <Miner>();
             if (!miner.IsDroneSent)
             {
                 foreach (GameObject droneGO in this.dromes.Values)
                 {
                     CargoDrone drome = droneGO.GetComponent <CargoDrone>();
                     if (!drome.isOn)
                     {
                         //Debug.Log(("SENDING DRONE TO: " + minersQueue[(i - 1)].name));
                         miner.IsDroneSent = true;
                         droneGO.GetComponent <CargoDrone>().moveTo(minersQueue[(i - 1)]);
                         minersQueue.RemoveAt((i - 1));
                         return;
                     }
                 }
             }
         }
     }
     else
     {
         //Debug.Log("NO MINERS WAITING!");
     }
 }
    public void SendDroneToResBox(ResourcesBox rbox)
    {
        if (rbox == null)
        {
            return;
        }
        CargoDrone drone = null;

        foreach (CargoDrone c in transportDrones)
        {
            if (c.gameObject.activeSelf == false || c.target == null)
            {
                drone = c; break;
            }
        }
        if (drone == null)
        {
            drone = transportDrones[(int)Random.value * (transportDrones.Length - 1)];
        }
        if (drone != null)
        {
            drone.target = rbox;
            if (!drone.gameObject.activeSelf)
            {
                drone.transform.position = transform.TransformPoint(droneHangarPos);
                drone.gameObject.SetActive(true);
            }
            drone.changeDestinationAfterHaul = true;
        }
    }
Ejemplo n.º 3
0
    public void returnedToBase(CargoDrone drome)
    {
        bool  materialSaved = false;
        float cargo         = drome.unloadCargo();

        if ((this.data.productionQty + cargo) < this.data.storageCty)
        {
            materialSaved            = true;
            this.data.productionQty += cargo;
        }
        else
        {
            if (this.storageStructures.Count > 0)
            {
                foreach (GameObject storageGO in this.storageStructures.Values)
                {
                    MineralStorage materialStorage = storageGO.GetComponent <MineralStorage>();
                    if ((materialStorage.Data.productionQty + cargo) < materialStorage.Data.storageCty)
                    {
                        materialSaved = true;
                        materialStorage.Data.productionQty += cargo;
                        break;
                    }
                }
            }
            else
            {
                //Debug.Log("There is not material storage units available.");
            }
        }

        if (!materialSaved)
        {
            isStorageAvailable = false;
            //Debug.Log("Stop sending dromes.");
        }

        //if (checkMinerName(drome.Target.name))
        //{
        //minersQueue.Remove(drome.Target);
        //drome.Target = null;
        //drome.IsOn = false;
        work();
        //}
    }