// method that loops through each seed and checks it corresponding resitances vs the disastertype. // if no resitance it removes the seed from plantedSeeds public void checkSeedResistance(int disasterDay) { NaturalDisaster disasterType = this.naturalDisasters[disasterDay]; //loop through all seeds and check resistance. List <int> removableItems = new List <int>(); foreach (var item in this.plantedSeeds) { bool resistant = false; foreach (DisasterProperty resistance in item.Value.specie.resistantProperties) { if (resistance == disasterType.property) { resistant = true; break; } } //remove seed from item if no resistance if (!resistant) { removableItems.Add(item.Key); } } foreach (var key in removableItems) { //this.plantedSeeds.Remove (key); this.plantedSeeds[key].daysGrown = 500; //TODO: HACKY! Needs fix if this is ever to be built upon (also changed from original design of "removing" stuff } }
void CollisionWithNatureDisaster(Unit unit, NaturalDisaster storm, float distance) { if (distance <= unit.SoftRadius + storm.SoftRadius) { unit.isNatureDisaster(storm); } if (distance <= unit.HardRadius + storm.HardRadius) { unit.OnDead(); } }
public void isNatureDisaster(NaturalDisaster naturalDis) { move.applyNatureForce(naturalDis.CalculateForce(ObjectTransform.position)); }
/// <summary> /// Creates a natural disaster task. /// </summary> /// <param name="taskName">Name of the task.</param> /// <param name="taskDescription">String which describes the task.</param> /// <param name="streetConnectors">A List of all connectors.</param> /// <param name="priority">Shows the priority of the task.</param> /// <param name="disasterType">Specifies the type of disaster.</param> /// <param name="roadDamage">Shows whether the road is damaged or not.</param> /// <param name="blockages">Specifies the number of blockages.</param> /// <param name="from">From when does this task start.</param> /// <param name="to">When does the task approx. end.</param> public void CreateNaturalDisasterTask(string taskName, string taskDescription, List <StreetConnector> streetConnectors, int priority, string disasterType, bool roadDamage, int blockages, DateTime from, DateTime to) { RoadMaintenanceTask task = new NaturalDisaster(taskName, taskDescription, streetConnectors, priority, disasterType, roadDamage, blockages); ScheduleTask(task, from, to); }