// TODO: // 1. send worker to the position near building, queued event when arrival // 2. start construction object, queued event when finished // 2.5. if interrupted, worker can repeat step 1 and continue on 2 without creating a new object // 3. finished event, return to gather public void CreateBuilding(BuildingType buildingType, Position position) { IBuilding building; switch (buildingType) { case BuildingType.BaseCenter: building = new BaseCenter(position); GameTimer.Schedule(BASE_CENTER_DELAY, () => { building.IsFinished = true; }); break; case BuildingType.NubianArmory: building = new NubianArmory(position); GameTimer.Schedule(NUBIAN_ARMORY_DELAY, () => { building.IsFinished = true; }); break; default: throw new Exception("Wrong building type parameter in CreateBuilding"); } Model.Instance.Buildings.Add(building); }
/// <summary> /// Finds all Resources situated near a Base. /// </summary> /// <param name="baseCenter">Base near which all nearest resources will be looked for.</param> /// <typeparam name="TResource">Type of the Resource to be searched for.</typeparam> /// <returns>List of resources.</returns> public static List <TResource> GetResourcesNearBase <TResource>(BaseCenter baseCenter) where TResource : IResource { const int maxPathLengthFromBase = 50; var building = (Building)baseCenter; // The building has all its resources cached if (building.NearbyResorces == null) { var allResourcesList = new List <Resource>(); ForEach <Resource, Resource>(resource => { if (resource.Position.PathFrom(baseCenter.Position).IsLengthLessThan(maxPathLengthFromBase) != null) { allResourcesList.Add(resource); } }, GameManager.Instance.Players[0].SharedResources); building.NearbyResorces = allResourcesList; } // They are further filtered by the chosen generic type var list = new List <TResource>(); ForEach <TResource, Resource>(resource => { list.Add(resource); }, building.NearbyResorces); return(list); }
public override void Dispose() { base.Dispose(); BaseCenter.Dispose(); }
/// <summary> /// Finds all Resources situated near a Base. /// </summary> /// <param name="baseCenter">Base near which all nearest resources will be looked for.</param> /// <typeparam name="TResource">Type of the Resource to be searched for.</typeparam> /// <returns>List of resources.</returns> public static List <TResource> GetResourcesNearBase <TResource>(BaseCenter baseCenter) where TResource : IResource { throw new NotImplementedException(); }