public void ResourceOrders(RubeUnit rube, Construct construct, Resource resource) { rube.NewOrder(new MoveOrder(resource.transform.position)); rube.Mark(resource); rube.AddOrder(new TakeResourceOrder(resource)); rube.AddOrder(new MoveOrder(construct.transform.position)); rube.AddOrder(new UseResourceOrder(construct)); }
public Resource SelectResourceByDistance(RubeUnit rube, Resource[] resourcesOfType) { List <float> resourceDistance = new List <float>(); Dictionary <float, Resource> distanceDictionary = new Dictionary <float, Resource>(); foreach (var resource in resourcesOfType) { float distance = Vector3.Distance(rube.transform.position, resource.transform.position); resourceDistance.Add(distance); distanceDictionary.Add(distance, resource); } resourceDistance.Sort(); return(distanceDictionary[resourceDistance[0]]); }
private void ReturnToWork(Unit unit) { if (unit.Type != UnitType.Rube) { return; } RubeUnit rube = unit as RubeUnit; if (rube.BuildingConstruct == null || rube.BuildingConstruct.IsReady) { return; } OnUnitIdle?.Invoke(new List <Unit> { rube }, rube.BuildingConstruct); }
public void BuildOrders(RubeUnit rube, Construct construct) { rube.NewOrder(new MoveOrder(construct.transform.position)); rube.AddOrder(new BuildOrder(construct)); }