public void AllTypesHaveStorages() { ResourcesStorage storages = new ResourcesStorage(); Assert.AreEqual(0, storages.NextAmount(ResourceType.Air)); Assert.AreEqual(0, storages.NextAmount(ResourceType.Food)); Assert.AreEqual(0, storages.NextAmount(ResourceType.Water)); }
public Station() { ResourcesStorage = new ResourcesStorage(); projects = new List <Project>(); numCompletedProjectsNextTurn = 0; upkeepDeltas = new List <ResourceDelta>(); Modules = new[] { new CrewModule() }; }
private void Display(ResourcesStorage singleton) { var storage = singleton.GetAllProducts(); foreach (var(key, value) in storage) { Console.WriteLine($"{key}: {value:0.00} unit(s)"); } Console.WriteLine($"Total energy usage: {singleton.TotalUsage.ToString("0.00", CultureInfo.CurrentCulture)}"); }
public void TryAddRejectsAllDeltas() { var storages = new ResourcesStorage(); storages.TryAddDeltas(new[] { new ResourceDelta(ResourceType.Air, 20), new ResourceDelta(ResourceType.Air, -30), new ResourceDelta(ResourceType.Food, 20) }); Assert.AreEqual(0, storages.NextAmount(ResourceType.Air)); Assert.AreEqual(0, storages.NextAmount(ResourceType.Food)); }
public void HappyCase() { var storages = new ResourcesStorage(); storages.AddDelta(new ResourceDelta(ResourceType.Air, 20)); storages.AddDelta(new ResourceDelta(ResourceType.Food, -20)); Assert.AreEqual(20, storages.NextAmount(ResourceType.Air)); Assert.AreEqual(-20, storages.NextAmount(ResourceType.Food)); storages.Tick(); Assert.AreEqual(20, storages.NextAmount(ResourceType.Air)); Assert.AreEqual(20, storages.ResourceStorages[ResourceType.Air].CurrentAmount); }
public void TestUpkeep() { var station = new Station(); ResourcesStorage storage = station.ResourcesStorage; storage.AddDelta(new ResourceDelta(ResourceType.Air, 20)); station.DoTurn(); station.AddUpkeepDelta(new ResourceDelta(ResourceType.Air, -10)); // upkeep depletes stored resource first Assert.AreEqual(10, storage.NextAmount(ResourceType.Air)); station.DoTurn(); Assert.AreEqual(0, storage.NextAmount(ResourceType.Air)); // and will launch resources via the rocket instead of going negative station.DoTurn(); Assert.AreEqual(0, storage.NextAmount(ResourceType.Air)); }
private MathCore() { Resource.CreateNewResurce("Ore"); Resource.CreateNewResurce("Cuper"); Resource.CreateNewResurce("Plastic"); Resource.CreateNewResurce("Coal"); Resource.CreateNewResurce("Oil"); ResourcesStorage storage1 = new ResourcesStorage(); storage1.AddNewResource("Cuper", 100); storage1.AddNewResource("Ore", 100); storage1.AddNewResource("Plastic", 100); ResourcesStorage storage2 = new ResourcesStorage(); storage2.AddNewResource("Oil", 100); storage1.AddNewResource("Ore", 100); storage2.AddNewResource("Coal", 100); //NewGame(6, 6, storage1); }
public bool NewGame(int x, int y, ResourcesStorage storage) { GameField = new List <List <byte> >(); for (int i = 0; i < x; i++) { GameField.Add(new List <byte>()); for (int j = 0; j < y; j++) { Resource r = storage.GetOneRandomResource(); if (r != null) { GameField[i].Add((byte)storage.GetOneRandomResource().Id); } else { return(false); } } } this.storage = storage; return(true); }
public ResourcesService(ResourcesStorage storage) { _storage = storage; }
public IEnumerator storeFood() { if (toCarry.GetType().IsSubclassOf(typeof(Foods))) { //Debug.Log("Storing food"); FoodStorage sRoom = null; NavNode target = null; for (int i = 0; i < NavGraph.rooms.Count; i++) { if (NavGraph.rooms[i].specialization == null) { continue; } if (NavGraph.rooms[i].specialization.GetType() == typeof(FoodStorage)) { NavNode spot = ((FoodStorage)NavGraph.rooms[i].specialization).demandFreeSpot(); Debug.Log("spot " + spot); if (spot != null) { sRoom = (FoodStorage)NavGraph.rooms[i].specialization; target = spot; // Debug.Log("targeting"); } } } if (target == null) { //Debug.Log("No Target"); lookForJob = true; World.w.workers.Add(this); yield break; } Debug.Log("moving " + toCarry + " to " + target.position); path = PathFind.getPath(World.w.GetBlockNegCoor(position).navNode, target); startWalking(); while (Vector2.Distance(position, target.position) > .2f) { yield return(null); } sRoom.addFood(new StorageElement((Foods)toCarry, target.position)); } else { //Debug.Log("Storing item"); ResourcesStorage sRoom = null; NavNode target = null; for (int i = 0; i < NavGraph.rooms.Count; i++) { if (NavGraph.rooms[i].specialization == null) { continue; } if (NavGraph.rooms[i].specialization.GetType() == typeof(ResourcesStorage)) { NavNode spot = ((ResourcesStorage)NavGraph.rooms[i].specialization).demandFreeSpot(); if (spot != null) { sRoom = (ResourcesStorage)NavGraph.rooms[i].specialization; target = spot; } } } if (target == null) { lookForJob = true; World.w.workers.Add(this); yield break; } Debug.Log("moving " + toCarry + " to " + target.position); path = PathFind.getPath(World.w.GetBlock(position).navNode, target); startWalking(); while (Vector2.Distance(position, target.position) > .2f) { yield return(null); } sRoom.addResource(new ResourcesElement((Resource)toCarry, target.position)); } lookForJob = true; World.w.workers.Add(this); toCarry = null; anime.SetInteger("toCarryID", 0); anime.SetInteger("Direction", anime.GetInteger("Direction") - 4); yield return(null); }
public override void ResourcesMining(ResourcesStorage storage) { storage.StoreProducts(Resource, ProduceResources / 7); }
public virtual void ResourcesMining(ResourcesStorage storage) { storage.StoreProducts(Resource, ProduceResources); }
public void ConsumeEnergy(ResourcesStorage storage) { storage.SubtractProduct(Resource, ConsumedEnergy); }