Beispiel #1
0
 //pozivanje funkcije koja prikuplja resurse
 void UnitsGatherResource(ResourceSource resource, Unit[] units)
 {
     if (units.Length == 1)
     {
         units[0].GatherResource(resource, UnitMover.GetUnitDestinationAroundResource(resource.transform.position));
     }
     else
     {
         Vector3[] destinations = UnitMover.GetUnitGroupDestinationsAroundResource(resource.transform.position, units.Length);
         for (int x = 0; x < units.Length; x++)
         {
             units[x].GatherResource(resource, destinations[x]);
         }
     }
 }
Beispiel #2
0
    // called when we command units to gather a resource
    void UnitsGatherResource(ResourceSource resource, Unit[] units)
    {
        // are just selecting 1 unit?
        if (units.Length == 1)
        {
            units[0].GatherResource(resource, UnitMover.GetUnitDestinationAroundResource(resource.transform.position));
        }
        // otherwise, calculate the unit group formation
        else
        {
            Vector3[] destinations = UnitMover.GetUnitGroupDestinationsAroundResource(resource.transform.position, units);

            for (int x = 0; x < units.Length; x++)
            {
                units[x].GatherResource(resource, destinations[x]);
            }
        }
    }