public void CmdReadyUp(bool ready) { gc.netInfo.readiness[connectionToClient] = ready; List <bool> readinessBools = gc.netInfo.readiness.Values.ToList(); if (readinessBools.All(b => b == true)) { // Debug.Log("All players ready"); List <Owner> ownerOrder = gc.netInfo.GenerateOwnerOrder(gc.mapInfo.owners.Values.ToList()); string[] strOwnerOrder = ownerOrder.Select(o => o.name).ToArray(); gc.SetOwnerOrder(strOwnerOrder); Owner active; do { active = gc.NextOwner(); Debug.Log("Beginning turn for " + active.name); } while (active.conn == null); RpcStartGame(strOwnerOrder, active.name); foreach (Area area in gc.mapInfo.areas.Values) { if (area.modifier.name != "Untraversable") { UnitSpawnInfo info = new UnitSpawnInfo(area); gc.unitIDCounter++; info.ID = gc.unitIDCounter; RpcSpawnUnit(info); } } } }
public void TrySpawnUnit_WaterSpawningSelected_AndValidWaterSpawn_CreatesUnitOfTemplateAtLocation() { var encampment = BuildEncampment(); var locationOfUnit = BuildCell(); var templateToBuild = BuildUnitTemplate(); var spawnInfo = new UnitSpawnInfo() { IsValidSpawn = true, LocationOfUnit = locationOfUnit, TemplateToBuild = templateToBuild }; Func <IHexCell, IEnumerable <IUnitTemplate> > selector = cell => new List <IUnitTemplate>(); MockAvailableUnitsLogic.Setup(logic => logic.NavalTemplateSelector).Returns(selector); MockSpawningTools.Setup(tools => tools.TryGetValidSpawn(encampment, selector)).Returns(spawnInfo); var barbarianCiv = BuildCiv(); MockCivFactory.Setup(factory => factory.BarbarianCiv).Returns(barbarianCiv); MockRandomizer.Setup(randomizer => randomizer.GetRandom01()).Returns(-1f); var unitSpawner = Container.Resolve <BarbarianUnitSpawner>(); Assert.IsTrue(unitSpawner.TrySpawnUnit(encampment), "TrySpawnUnit did not return true as expected"); MockUnitFactory.Verify( factory => factory.BuildUnit(locationOfUnit, templateToBuild, barbarianCiv), Times.Once, "UnitFactory.BuildNot not called as expected" ); }
public void step() { if (unitQueue.Count > 0) { Debug.Log("Spawning Unit From Queue"); UnitSpawnInfo unitInfo = unitQueue.Dequeue(); this.boardManager.addEntity(this.transform.position, unitInfo.owner, this.dirValue, unitInfo.unit); } }
public Unit(UnitSpawnInfo info, MapInfo map) { ID = info.ID; attack = info.attack; defence = info.defence; initiative = info.initiative; maxHealth = info.maxHealth; cooldown = info.cooldown; area = map.areas[info.strAreaID]; owner = map.owners[info.strOwner]; Reset(); }
public void SpawnUnit(UnitSpawnInfo info, bool updateUI = true) { //Should only be called by PlayerNetworking RpcSpawnUnit Unit unit = new Unit(info, mapInfo); unit.area.AddUnit(unit); mapInfo.units[info.ID] = unit; if (updateUI) { uic.UpdateAreaInfo(unit.area); } }
public void TrySpawnUnit_WaterSpawningSelected_AndInvalidWaterSpawn_CreatesLandSpawnIfLandSpawnValid() { var encampment = BuildEncampment(); var landLocation = BuildCell(); var waterLocation = BuildCell(); var landTemplate = BuildUnitTemplate(); var waterTemplate = BuildUnitTemplate(); var landSpawnInfo = new UnitSpawnInfo() { IsValidSpawn = true, LocationOfUnit = landLocation, TemplateToBuild = landTemplate }; var WaterSpawnInfo = new UnitSpawnInfo() { IsValidSpawn = false, LocationOfUnit = waterLocation, TemplateToBuild = waterTemplate }; Func <IHexCell, IEnumerable <IUnitTemplate> > landSelector = cell => new List <IUnitTemplate>(); Func <IHexCell, IEnumerable <IUnitTemplate> > navalSelector = cell => new List <IUnitTemplate>(); MockAvailableUnitsLogic.Setup(logic => logic.LandTemplateSelector).Returns(landSelector); MockAvailableUnitsLogic.Setup(logic => logic.NavalTemplateSelector).Returns(navalSelector); MockSpawningTools.Setup(tools => tools.TryGetValidSpawn(encampment, landSelector)).Returns(landSpawnInfo); MockSpawningTools.Setup(tools => tools.TryGetValidSpawn(encampment, navalSelector)).Returns(WaterSpawnInfo); var barbarianCiv = BuildCiv(); MockCivFactory.Setup(factory => factory.BarbarianCiv).Returns(barbarianCiv); MockRandomizer.Setup(randomizer => randomizer.GetRandom01()).Returns(-1f); var unitSpawner = Container.Resolve <BarbarianUnitSpawner>(); Assert.IsTrue(unitSpawner.TrySpawnUnit(encampment), "TrySpawnUnit did not return true as expected"); MockUnitFactory.Verify( factory => factory.BuildUnit(landLocation, landTemplate, barbarianCiv), Times.Once, "Land template was not created as expected" ); MockUnitFactory.Verify( factory => factory.BuildUnit(waterLocation, waterTemplate, barbarianCiv), Times.Never, "Water template was unexpectedly created" ); }
public void TrySpawnUnit_LandSpawningSelected_AndInvalidLandSpawn_DoesNothingAndReturnsFalse() { var encampment = BuildEncampment(); var landLocation = BuildCell(); var waterLocation = BuildCell(); var landTemplate = BuildUnitTemplate(); var waterTemplate = BuildUnitTemplate(); var landSpawnInfo = new UnitSpawnInfo() { IsValidSpawn = false, LocationOfUnit = landLocation, TemplateToBuild = landTemplate }; var WaterSpawnInfo = new UnitSpawnInfo() { IsValidSpawn = true, LocationOfUnit = waterLocation, TemplateToBuild = waterTemplate }; Func <IHexCell, IEnumerable <IUnitTemplate> > landSelector = cell => new List <IUnitTemplate>(); Func <IHexCell, IEnumerable <IUnitTemplate> > navalSelector = cell => new List <IUnitTemplate>(); MockAvailableUnitsLogic.Setup(logic => logic.LandTemplateSelector).Returns(landSelector); MockAvailableUnitsLogic.Setup(logic => logic.NavalTemplateSelector).Returns(navalSelector); MockSpawningTools.Setup(tools => tools.TryGetValidSpawn(encampment, landSelector)).Returns(landSpawnInfo); MockSpawningTools.Setup(tools => tools.TryGetValidSpawn(encampment, navalSelector)).Returns(WaterSpawnInfo); var barbarianCiv = BuildCiv(); MockCivFactory.Setup(factory => factory.BarbarianCiv).Returns(barbarianCiv); MockRandomizer.Setup(randomizer => randomizer.GetRandom01()).Returns(1f); var unitSpawner = Container.Resolve <BarbarianUnitSpawner>(); Assert.IsFalse(unitSpawner.TrySpawnUnit(encampment), "TrySpawnUnit did not return false as expected"); MockUnitFactory.Verify( factory => factory.BuildUnit(It.IsAny <IHexCell>(), It.IsAny <IUnitTemplate>(), It.IsAny <ICivilization>()), Times.Never, "UnitFactory.BuildUnit was unexpectedly called" ); }
private void Awake() { turnManager = GetComponent <TurnManager>(); unitSpawns = new UnitSpawnInfo[6]; unitSpawns[0] = new UnitSpawnInfo(1, 0); unitSpawns[1] = new UnitSpawnInfo(2, 0); unitSpawns[2] = new UnitSpawnInfo(3, 0); unitSpawns[3] = new UnitSpawnInfo(10, 1); unitSpawns[4] = new UnitSpawnInfo(11, 1); unitSpawns[5] = new UnitSpawnInfo(12, 1); mapHeightsInitialize(); setTilesData(); unitsInitialize(); setDataInBase(); }
public void NetworkStart() { mapInfo = dataImporter.GetData(); areas = mapInfo.areas; uic.gc = this; uic.InitialDrawUnderlay(); uic.InitialDrawOwnership(); uic.ShowOwnership(); foreach (Area area in mapInfo.areas.Values) { UnitSpawnInfo info = new UnitSpawnInfo(area); uic.DrawAreaInfo(area); } GameObject.FindObjectsOfType <NetworkManagerHUD>()[0].showGUI = false; List <string> ownerIDs = mapInfo.owners.Keys.ToList(); uic.ShowDropdown(true, ownerIDs); }
void OnClick() { if (EventSystem.current.IsPointerOverGameObject()) { return; } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity, LayerMask.GetMask("Locator"))) { //Get color32 of pixel that we hit Vector2 v2 = hit.textureCoord; Texture2D t2d = hit.collider.GetComponent <MeshRenderer>().sharedMaterial.mainTexture as Texture2D; v2.x *= t2d.width; v2.y *= t2d.height; Color32 color = t2d.GetPixel(Mathf.FloorToInt(v2.x), Mathf.FloorToInt(v2.y)); string strArea = ColorSettings.RGBToInt(color).ToString(); if (!areas.ContainsKey(strArea)) { return; } Area area = areas[strArea]; if (gs == GameState.SelectMoveFrom) { uic.SelectArea(area); if (uic.selectedArea.owner == activeOwner) { uic.ShowPrompt1(true, "Move (Space)"); } else { uic.ShowPrompt1(false); } } else if (gs == GameState.DeployUnits) { uic.SelectArea(area, false); if (storedInt > 0 && uic.selectedArea.selectable) { UnitSpawnInfo info = new UnitSpawnInfo(area); net.CmdRequestSpawnUnit(info); storedInt--; uic.SetInfoBox("Remaining available to deploy: " + storedInt.ToString()); } } else if (gs == GameState.SelectMoveTo) { uic.SelectArea(area); if (storedAreas1.Contains(uic.selectedArea)) { uic.ShowPrompt1(true, "Move Here (Space)"); } else { uic.ShowPrompt1(false); } } else if (gs == GameState.Browse) { uic.SelectArea(area); } } }
public void RpcSpawnUnit(UnitSpawnInfo info) { gc.SpawnUnit(info); }
public void CmdRequestSpawnUnit(UnitSpawnInfo info) { gc.unitIDCounter++; info.ID = gc.unitIDCounter; RpcSpawnUnit(info); }
public void queueUnit(UnitSpawnInfo unitInfo) { unitQueue.Enqueue(unitInfo); }