private static void MinionGenerationEvent(DbGeography loc) { Console.WriteLine("Ontogenesis started"); //generate wild minion group WildMinionGeneratorManager.InitiateOntogenesis(loc); UsersManager.UpdateEventSaturations(loc, 1); }
public static void Generate(string point) { DbGeography loc = DbGeography.FromText(point); WildMinionGeneratorManager.GenerateWildMinionGroup(loc); }
public static Orders ContinueOrders(Battlegroup bg, Orders o) { bool death = false; using (var db = new MinionWarsEntities()) { ModifierCoeficients ttl = db.ModifierCoeficients.Find(26); var difference = (DateTime.Now - bg.creation.Value).TotalMinutes; if (difference > ttl.value) { WildMinionGeneratorManager.SaveToPool(bg); bg.location = null; bg.orders_id = null; death = true; db.Battlegroup.Attach(bg); db.Entry(bg).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } if (!death) { DbGeography newLoc = o.location; switch (o.name) { case "roam": o.name = "wait"; break; case "wait": var waitTime = (DateTime.Now - bg.lastMovement.Value).TotalMinutes; if (waitTime < 5) { o.name = "wait"; } else { o.name = "roam"; newLoc = GiveRandomDestination(bg, 250); } break; case "complete_task": o.name = "return"; newLoc = GetReturnDestination(bg); break; case "return": newLoc = GetReturnDestination(bg); if (bg.location.Distance(newLoc) < 10) { bg.location = null; bg.orders_id = null; newLoc = null; using (var db = new MinionWarsEntities()) { db.Battlegroup.Attach(bg); db.Entry(bg).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } break; } o.location = newLoc; o.directions = Geolocations.Geolocations.GetNewDirections(bg.location, o); o.current_step = Geolocations.Geolocations.GetDirectionMovement(bg.location, o); using (var db = new MinionWarsEntities()) { db.Orders.Attach(o); db.Entry(o).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(o); } else { return(null); } }