Exemplo n.º 1
0
        private ResourceHub FindClosestResource(List <Building> inGameBuildings)
        {
            // finds out which resourcehub is the closest to the character, and returns it.

            ResourceHub        closestResource = null;
            List <ResourceHub> resourcehubs    = new List <ResourceHub>();

            foreach (Building building in inGameBuildings)
            {
                if ((building.GetType()).Equals(typeof(ResourceHub)))
                {
                    resourcehubs.Add((ResourceHub)building);
                }
            }

            foreach (ResourceHub reHub in resourcehubs)
            {
                if (closestResource == null)
                {
                    closestResource = reHub;
                }
                else
                {
                    if (closestResource.Location.IsFurtherThan(CurrentBlock, reHub.Location))
                    {
                        closestResource = reHub;
                    }
                }
            }
            Logger.WriteActivityLog(ID, " found closest resource " + closestResource.ToString());
            return(closestResource);
        }
Exemplo n.º 2
0
 private void GatherResources(ResourceHub resource)
 {
     Logger.WriteActivityLog(ID, " is gathering resource from " + resource.ToString());
     MoveTo(resource);
     resource.EnterBuilding(this);
     Resources++;
     resource.SubtractResource(1);
     Rest--;
     Thread.Sleep(MovementSpeed * 15);
     resource.LeaveBuilding(this);
 }