public FindDivision(DivisionController controller, DivisionController commanderSendingOrder, RememberedDivision finish) { this.commanderSendingOrder = commanderSendingOrder; this.controller = controller; this.finish = finish; this.target = null; }
/// <summary> /// used when copying /// </summary> /// <param name="division"></param> /// <param name="controller"></param> public Division(Division division, DivisionController controller = null) { this.Commander = division.Commander; this.PossibleOrders = new List <Order>(division.PossibleOrders); this.Subordinates = new HashSet <int>(division.Subordinates); this.Soldiers = new ObservableCollection <Soldier>(division.Soldiers); this.NumSoldiers = division.NumSoldiers; if (division.CommandingOfficer != null) { this.CommandingOfficer = new Officer(division.CommandingOfficer); } this.DivisionId = division.DivisionId; this.TeamId = division.TeamId; OrderSystem = new MultiOrder(this, DivisionId, "division order queues", new List <Order>(), false); this.OrderSystem.OngoingOrder = division.OrderSystem.OngoingOrder; this.Name = "Division " + DivisionId; this.Controller = controller; this.Zones = division.Zones; this.IsMessenger = division.IsMessenger; SetupModifiers(); RecalculateAggrigateValues(); this.Soldiers.CollectionChanged += OnSoldiersChanged; }
public override void Proceed() { Vector3 currLoc = controller.transform.position; float distanceToFinish = (finish.position - currLoc).magnitude; //if target is null look for it in the visible divisions if (target == null) { controller.FindVisibleDivision(finish.divisionId, out target); } //if it isnt null go find em if (target != null) { distanceToFinish = (target.transform.position - currLoc).magnitude; } //when this is true then we have caught up to our target if (distanceToFinish < .1f && !hasFoundTarget) { hasFoundTarget = true; target = null; } moveToTarget(); }
public void AddDivision(DivisionController division) { if (!Divisions.Contains(division)) { Divisions.Add(division); } }
public void DivisionTestSetUp() { _service = new List <DivisionService>() { new DivisionService() }; _controller = new DivisionController(_service); }
public SendMessage(DivisionController controller, DivisionController commanderSendingOrder, List <Order> message, RememberedDivision target) { this.commanderSendingOrder = commanderSendingOrder; this.controller = controller; this.finish = target; this.target = null; this.message = message; }
private void OnDivisionExitSight(DivisionController controller) { //Debug.Log($"exit {this.name} {controller.name}"); //VisibleControllers.ForEach(x => x.RefreshVisibleDivisions()); RefreshVisibleDivisions(); VisibleControllers.Remove(controller); //VisibleControllers.ForEach(x => x.RefreshVisibleDivisions()); }
public void Init(DivisionController controller = null) { this.DivisionId = DivisionCounter; DivisionCounter++; this.Name = "Division " + DivisionId; this.Controller = controller; this.OrderSystem = new MultiOrder(this, DivisionId, "division order queues", new List <Order>(), false); this.OrderSystem.OngoingOrder = new EmptyOrder(); }
public void SendMessenger(RememberedDivision to, RememberedDivision endTarget, List <Order> orders) { //create a new division DivisionController messenger = CreateNewDivision((int)CommandingOfficer.MessengerDivisionSoldierCnt.Value); messenger.AttachedDivision.IsMessenger = true; messenger.name = "messenger"; messenger.AttachedDivision.ReceiveOrder(new FindDivision(messenger.AttachedDivision, DivisionId, to.DivisionId)); messenger.AttachedDivision.ReceiveOrder(new SendMessage(messenger.AttachedDivision, DivisionId, orders, to.DivisionId, endTarget.DivisionId)); }
public AIControlledDivision(int teamId = -1, DivisionController controller = null, bool enableAI = true) : base(teamId, controller) { _enableAI = enableAI; if (_enableAI) { //ReceiveOrder(new AIOrder(this, DivisionId)); OrderSystem = new AIOrder(this, DivisionId); this.OrderSystem.OngoingOrder = new EmptyOrder(); } }
public void Setup(DivisionController division) { this.division = division; //build menu Dictionary <SoldierType, List <Soldier> > soldiersSplitIntoTypes = division.SplitSoldiersIntoTypes(); foreach (var soldierGroup in soldiersSplitIntoTypes) { CreateCard(soldierGroup.Key, soldierGroup.Value); } }
public virtual DivisionController CreateChild(List <Soldier> soldiersForChild) { GameObject newDivision = Instantiate(divisonPrefab); DivisionController newController = newDivision.GetComponent <DivisionController>(); newController.Init(GenerateRememberedDivision()); newController.soldiers = soldiersForChild; newDivision.transform.position = this.transform.position; newDivision.transform.rotation = this.transform.rotation; subordinates.Add(newController.GenerateRememberedDivision()); GameManager.instance.RefreshAllDivisons(); return(newController); }
public void AbsorbDivision(DivisionController other) { TransferSoldiers(other.soldiers); //kick him out of his commanders subordinate list RememberedDivision parent = other.commander; if (parent != null) { parent.RemoveSubordinate(other.GenerateRememberedDivision()); } GameObject.Destroy(other.gameObject); GameManager.instance.RefreshAllDivisons(); }
public void select(DivisionController divisionController) { if (!UIwaitingForSelection) { selected = divisionController; //bing up order ui OrderDisplayManager.instance.ClearOrders(); OrderDisplayManager.instance.AddOrderSet(selected.possibleOrders); } else { UIResponse(divisionController); } }
//use for creating a new division from inside a new controller public Division(int teamId, DivisionController controller = null) { this.Commander = -1; this.PossibleOrders = new List <Order>(); this.Subordinates = new HashSet <int>(); this.Soldiers = new ObservableCollection <Soldier>(); Init(controller); this.Soldiers.CollectionChanged += OnSoldiersChanged; this.TeamId = teamId; SetupModifiers(); }
private void OnDivisionEnterSight(DivisionController controller) { //Debug.Log($"enter {this.name} {controller.name}"); if (VisibleControllers.Contains(controller)) { VisibleControllers.Remove(controller); } VisibleControllers.Add(controller); //VisibleControllers.ForEach(x => x.RefreshVisibleDivisions()); RefreshVisibleDivisions(); //VisibleControllers.ForEach(x => x.RefreshVisibleDivisions()); }
public void TestSelectPost_NoSelection() { IRpcBroker broker = MockRpcBrokerFactory.GetXusDivisionSetBroker(true); DivisionController controller = new DivisionController(broker); FormCollection formCollection = new FormCollection(); ActionResult result = controller.Select(formCollection); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); RedirectToRouteResult routeResult = (RedirectToRouteResult)result; Assert.AreEqual("Select", routeResult.RouteValues["action"]); }
public DivisionController CreateChild(List <Soldier> soldiersForChild) { GameObject newDivision = Instantiate(DivisionControllerManager.Instance.DivisionPrefab); DivisionController newController = newDivision.GetComponent <DivisionController>(); newController.transform.position = transform.position; newController.Controller = Controller; newController.AttachedDivision.TeamId = Controller.TeamId; newController.AttachedDivision.Soldiers.Clear(); newController.AttachedDivision.TransferSoldiers(soldiersForChild); newController.AttachedDivision.PromoteOfficer(); newController.AttachedDivision.Commander = AttachedDivision.DivisionId; AttachedDivision.AddSubordinate(new RememberedDivision(newController.AttachedDivision)); DivisionControllerManager.Instance.AddDivision(newController); return(newController); }
public virtual Division CreateChild(List <Soldier> soldiersForChild, DivisionController newController) { newController.transform.position = this.Controller.transform.position; newController.transform.rotation = this.Controller.transform.rotation; ControlledDivision newDivision = new ControlledDivision(TeamId, newController) { Soldiers = new ObservableCollection <Soldier>(soldiersForChild) }; AddSubordinate(new RememberedDivision(newDivision)); newDivision.Commander = DivisionId; OnChange(); newDivision.OnChange(); newController.AttachedDivision = newDivision; return(newDivision); }
public void TestPutDivisionNotFound() { var connection = new SqliteConnection("Datasource=:memory:"); connection.Open(); try { var options = new DbContextOptionsBuilder <InternalServicesDirectoryV1Context>() .UseSqlite(connection) .Options; // test a successful case using (var context = new InternalServicesDirectoryV1Context(options)) { context.Database.EnsureCreated(); var division = new Division { DivisionCode = 1 }; context.Division.Add(division); context.Division.Add(new Division { DivisionCode = 2 }); context.Division.Add(new Division { DivisionCode = 3 }); context.SaveChanges(); DivisionController controller = new DivisionController(context); division.DivisionId = 4; division.DivisionName = "division4"; division.DivisionCode = 4; var actionResult = controller.PutDivision(division.DivisionId, division.ToDivisionV1DTO()).Result; var result = actionResult as NotFoundResult; Assert.IsNotNull(result); Assert.AreEqual(404, result.StatusCode); } } finally { connection.Close(); } }
public void TestGetDivision() { var connection = new SqliteConnection("Datasource=:memory:"); connection.Open(); try { var options = new DbContextOptionsBuilder <InternalServicesDirectoryV1Context>() .UseSqlite(connection) .Options; // test a successful case using (var context = new InternalServicesDirectoryV1Context(options)) { context.Database.EnsureCreated(); context.Division.Add(new Division { DivisionCode = 1 }); context.Division.Add(new Division { DivisionCode = 2 }); context.Division.Add(new Division { DivisionCode = 3 }); context.SaveChanges(); DivisionController controller = new DivisionController(context); var actionResult = controller.Get(2).Result; var result = actionResult as OkObjectResult; var division = result.Value as DivisionV1DTO; Assert.IsNotNull(result); Assert.AreEqual(200, result.StatusCode); Assert.IsNotNull(division); Assert.AreEqual(2, division.DivisionId); Assert.AreEqual(2, division.DivisionCode); } } finally { connection.Close(); } }
public void SendMessenger(RememberedDivision to, Order order) { //create a new division //todo make the messenger descesion smart List <Soldier> soldiersToGive = new List <Soldier>(); soldiersToGive.Add(PopSoldier()); DivisionController messenger = CreateChild(soldiersToGive); //give it a move order to go to the division List <Order> orders = new List <Order>(); orders.Add(order); //todo discover location of to messenger.ReceiveOrder(new FindDivision(messenger, this, to)); messenger.ReceiveOrder(new SendMessage(messenger, this, orders, to)); //messenger.ReceiveOrder(new FindDivision(messenger, this, messenger)); // messenger.ReceiveOrder }
public bool TryCreateNewDivision(out DivisionController newDivision) { Soldier soldier = null; try { soldier = PopSoldier(); } catch (InsufficientSoldierCountException) { newDivision = null; return(false); } List <Soldier> soldiersToGive = new List <Soldier> { soldier }; newDivision = Controller.CreateChild(soldiersToGive); return(true); }
public void RenderMapWithTilesAndVision(DivisionController controller, Color visionColor) { int sightDistance = Mathf.RoundToInt(controller.AttachedDivision.MaxSightDistance); if (controller == null) { return; } Vector2 controllerPosition = controller.transform.position; Vector2Int controllerPositionRounded = new Vector2Int(RoundVector(controller.transform.position).x, RoundVector(controller.transform.position).y); //for the x and ys we go one over so that we erase the old sight tiles as we walk past them for (int x = -sightDistance - 1; x <= sightDistance + 1; x++) { for (int y = -sightDistance - 1; y <= sightDistance + 1; y++) { var position = new Vector2Int(x, y) + controllerPositionRounded; var inVision = (new Vector2(position.x, position.y) - controllerPosition).magnitude < controller.AttachedDivision.MaxSightDistance; var color = NotDiscovered; if (inVision) { color = visionColor; } else if (InBounds(controller.AttachedDivision.discoveredMapLocations, position.x, position.y) && controller.AttachedDivision.discoveredMapLocations[position.x, position.y]) { color = FowGrey; } //TerrainTilemap.SetTileFlags(position, TileFlags.None); //TerrainTilemap.SetColor(position, color); SetTileColor(position, color); } } }
private void Update() { for (int i = 0; i < Divisions.Count; i++) { DivisionController division = Divisions[i]; UnityEngine.Profiling.Profiler.BeginSample("find visible"); division.FindVisibleDivisions(); UnityEngine.Profiling.Profiler.EndSample(); UnityEngine.Profiling.Profiler.BeginSample("do orders"); division.AttachedDivision.OrderSystem.DoOrders(division.AttachedDivision); UnityEngine.Profiling.Profiler.EndSample(); UnityEngine.Profiling.Profiler.BeginSample("do background orders"); division.AttachedDivision.OrderSystem.DoBackgroundOrders(division.AttachedDivision); UnityEngine.Profiling.Profiler.EndSample(); UnityEngine.Profiling.Profiler.BeginSample("check refresh"); division.AttachedDivision.CheckRefresh(); UnityEngine.Profiling.Profiler.EndSample(); UnityEngine.Profiling.Profiler.BeginSample("on tick"); division.OnTick(); UnityEngine.Profiling.Profiler.EndSample(); } for (int i = 0; i < Divisions.Count; i++) { DivisionController division = Divisions[i]; if (division.AttachedDivision.HasBeenDestroyed) { Divisions.RemoveAt(i); i--; } } }
public bool FindVisibleDivision(int divisionID, out DivisionController division) { division = null; return(visibleDivisions.TryGetValue(divisionID, out division)); }
public DivisionApiTest() { _seed = Guid.NewGuid().ToString(); _controller = MockController.CreateApi <DivisionController>(new DataContext(_seed, DBTypeEnum.Memory), "user"); }
public void Select(DivisionController divisionController) { Select(divisionController.AttachedDivision); }
public MergeDivisions(DivisionController controller, RememberedDivision target) { this.controller = controller; this.target = target; this.finishedMerging = false; }
void Start() { playerDivision = GameManager.instance.localPlayer.generalDivision; }