private void SelectUnitOrProvince() { var collider = getRayCastMeshNumber(); if (collider != null) { int provinceNumber = Province.FindByCollider(collider); if (provinceNumber > 0) { MainCamera.selectProvince(provinceNumber); if (!Input.GetKey(AdditionKey)) // don't de select units if shift is pressed { Game.selectedArmies.ToList().PerformAction(x => x.DeSelect()); } } else { var unit = collider.transform.GetComponent <Unit>(); if (unit != null) { var army = unit.Province.AllStandingArmies().Where(x => x.getOwner() == Game.Player).Next(ref nextArmyToSelect); if (army != null) { if (Input.GetKey(AdditionKey)) { if (Game.selectedArmies.Contains(army)) { army.DeSelect(); } else { army.Select(); } } else { if (Game.selectedArmies.Count > 0) { Game.selectedArmies.ToList().PerformAction(x => x.DeSelect()); } army.Select(); } } } } } else { MainCamera.selectProvince(-1); if (!Input.GetKey(AdditionKey)) { Game.selectedArmies.ToList().PerformAction(x => x.DeSelect()); } } }
private void SendUnitTo() { var collider = getRayCastMeshNumber(); if (collider != null) { Province sendToPovince = null; int meshNumber = Province.FindByCollider(collider); if (meshNumber > 0) // send armies to another province { sendToPovince = World.FindProvince(meshNumber); } else // better do here sort of collider layer, hitting provinces only { var unit = collider.transform.GetComponent <Unit>(); if (unit != null) { sendToPovince = unit.Province; } } var addPath = Input.GetKey(AdditionKey); foreach (var item in Game.selectedArmies) { if (addPath) { item.AddToPath(sendToPovince); } else { item.SetPathTo(sendToPovince); } Game.provincesToRedrawArmies.Add(item.Province); } //Unit.RedrawAll(); } }