public void LoadCity(CityState state) { // set random citizen color citizenControl.setRandomCitizenColor(); // clean up any existing stuff CleanCity(); // resets metrics & game over stuff resetGameOverStuff(); // load from saved state metrics.setCityName(state.cityName); metrics.setTimeRemaining(state.timeRemaining); foreach (Node node in state.sidewalks) { structureControl.addSidewalk(node.i, node.j); } foreach (Node node in state.buildings) { structureControl.addBuilding(node.i, node.j); } foreach (Node node in state.citizens) { citizenControl.addCitizen(node.i, node.j); } metrics.setNumPoints(state.points); }
private static async Task DoClientWork(IClusterClient client) { var problem = ProblemBuilder.Build(File.ReadAllLines(@"..\Resources\a_example.in")); var solution = new Solution(problem.NumberOfCars); var state = new CityState(problem.Cars.ToImmutableList(), new RidesView3(problem.Rides, problem.Bonus), 0); var tree = client.GetGrain <ITreeGrain <MakeRideAction> >(Guid.NewGuid()); tree.Init(state).Wait(); tree.Build().Wait(); INodeView <MakeRideAction> node; // while ((node = tree.GetTopAction().Result) != null) // { // if (!node.Action.Car.Equals(Car.SkipRide)) // { // solution.CarActions[node.Action.Car.Id].Add(node.Action); // } // // tree.ContinueFrom(node.Id).Wait(); // tree.Build().Wait(); // } Console.WriteLine("Finished"); Console.WriteLine(solution.GetTotalScore(problem.Bonus).ToString()); Console.WriteLine(solution.ToString()); }
public override List <HexCell> IsValidTarget(HexCell target) { List <HexCell> targetCells = new List <HexCell>(); List <HexCell> cells = PathFindingUtilities.GetCellsInRange(target, (config as BribeConfig).Range); List <HexCell> cityCells = cells.FindAll(c => c.City); foreach (HexCell cityCell in cityCells) { CityState cityState = cityCell.City.GetCityState(); if (!cityState) { continue; } Player player = cityState.Player; if (player) { if (player != gameObject.GetComponent <Unit>().GetPlayer()) { continue; } if (cityState.GetInfluence(player) >= 100) { continue; } } targetCells.Add(cityCell); } return(targetCells); }
public HexUnit CreateMercenary(CombatUnitConfig combatUnitConfig, HexCell cell, Player player, int cityStateID = -1) { HexUnit hexUnit = Instantiate(combatUnitPrefab).GetComponent <HexUnit>(); CombatUnit combatUnit = hexUnit.GetComponent <CombatUnit>(); combatUnit.SetCombatUnitConfig(combatUnitConfig); hexUnit.UnitPrefabName = name; hexUnit.Grid = hexGrid; hexUnit.Location = cell; hexUnit.Orientation = Random.Range(0f, 360f); hexUnit.HexUnitType = HexUnit.UnitType.COMBAT; hexGrid.AddUnit(hexUnit); CityState cityState = cityStates.Find(c => c.CityStateID == cityStateID); if (cityState) { combatUnit.SetCityState(cityState); } if (player.IsHuman) { hexUnit.Controllable = true; } combatUnit.Mercenary = true; player.AddMercenary(combatUnit); return(hexUnit); }
public static void Load(BinaryReader reader, GameController gameController, HexGrid hexGrid, int header) { int cityStateID = reader.ReadInt32(); Color color = new Color(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 1.0f); CityState instance = gameController.CreateCityState(color); instance.CityStateID = cityStateID; if (header >= 2) { int playerNumber = reader.ReadInt32(); if (playerNumber != -1) { instance.Player = gameController.GetPlayer(playerNumber); } } int unitCount = reader.ReadInt32(); for (int i = 0; i < unitCount; i++) { CombatUnit combatUnit = CombatUnit.Load(reader, gameController, hexGrid, header, instance.CityStateID); } if (header >= 3) { int exploredCellCount = reader.ReadInt32(); for (int i = 0; i < exploredCellCount; i++) { HexCell cell = hexGrid.GetCell(reader.ReadInt32()); if (!instance.exploredCells.Contains(cell)) { instance.exploredCells.Add(cell); } } } }
private void Awake() { // Inventory setup this.PlayerInventory = new Inventory(storeHouseSize, storeHouseWeight, true); this.GovtInventory = new Inventory(govtSize, govtWeight, false); this.PeoplesInventory = new Inventory(peopleSize, peopleWeight, false); this.goodsToSupply = new Dictionary <Good.GoodType, float> { { Good.GoodType.Drugs, 10 }, { Good.GoodType.Exotics, 10 }, { Good.GoodType.Food, 10 }, { Good.GoodType.Fuel, 10 }, { Good.GoodType.Ideas, 10 }, { Good.GoodType.Medicine, 10 }, { Good.GoodType.People, 10 }, { Good.GoodType.Textiles, 10 }, { Good.GoodType.Water, 10 }, { Good.GoodType.Weapons, 10 } }; this.hoursInState = 0; State = CityState.Normal; PlayerInventory = new Inventory(storeHouseSize, storeHouseWeight, true); PeoplesInventory = new Inventory(peopleSize, peopleWeight, false); GovtInventory = new Inventory(govtSize, govtWeight, false); foreach (Good g in goods) { PlayerInventory.AddGood(g); PeoplesInventory.AddGood(g); GovtInventory.AddGood(g); } }
public async Task ATest() { var problem = ProblemBuilder.Build(File.ReadAllLines(@"..\..\..\Resources\a_example.in")); var solution = new Solution(problem.NumberOfCars); var state = new CityState(problem.Cars.ToImmutableList(), new RidesView3(problem.Rides, problem.Bonus), 0); var tree = GrainFactory.GetGrain <ITreeGrain <MakeRideAction> >(Guid.NewGuid()); await tree.Init(state); await tree.Build(); INodeView <MakeRideAction> node; while ((node = await tree.GetTopAction()) != null) { Trace.WriteLine(node.Action); if (!node.Action.Car.Equals(Car.SkipRide)) { solution.CarActions[node.Action.Car.Id].Add(node.Action); } await tree.ContinueFrom(node.Id); await tree.Build(); } Assert.NotNull(solution); Trace.WriteLine("Finished"); Trace.WriteLine(solution.GetTotalScore(problem.Bonus).ToString()); Trace.WriteLine(solution.ToString()); Assert.Equal(10, solution.GetTotalScore(problem.Bonus)); }
/// <summary> /// Background operations<para/> /// Фоновые операции /// </summary> static void ThreadedLoading() { // Reading DAT files // Чтение настроек State = CityState.ReadingConfigs; TimeCycleManager.Init(); // Reading definitions and placements // Чтение IDE и IPL State = CityState.ReadingDefinitions; ObjectManager.ReadDefinitions(); State = CityState.ReadingPlacements; ObjectManager.ReadPlacements(); // Reading collision files // Чтение файлов коллизии State = CityState.ReadingCollisions; CollisionManager.Init(); // Creating static object proxies // Создание прокси-объектов статики State = CityState.CreatingPlacements; StaticManager.Init(); // Loading completed // Загрузка города завершена State = CityState.Complete; }
public bool CanSave() { return(!string.IsNullOrWhiteSpace(CustomerName) && !string.IsNullOrWhiteSpace(AddressLine) && !string.IsNullOrWhiteSpace(CityState) && CityState.Trim().Contains(" ") && !string.IsNullOrWhiteSpace(ZipCode)); }
/// <summary> /// Background operations<para/> /// Фоновые операции /// </summary> static void ThreadedLoading() { // Reading DAT files // Чтение настроек State = CityState.ReadingConfigs; TimeCycleManager.Init(); // Reading definitions and placements // Чтение IDE и IPL State = CityState.ReadingDefinitions; ObjectManager.ReadDefinitions(); State = CityState.ReadingPlacements; ObjectManager.ReadPlacements(); // Reading collision files // Чтение файлов коллизии State = CityState.ReadingCollisions; CollisionManager.Init(); // Creating static object proxies // Создание прокси-объектов статики State = CityState.CreatingPlacements; StaticManager.Init(); // Loading completed // Загрузка города завершена State = CityState.Complete; }
public void CreateCity(HexCell cell) { if (!cell.City) { CityState cityState = gameController.CreateCityState(); gameController.CreateCity(cell, cityState); } }
public CityState CreateCityState() { CityState instance = Instantiate(cityStatePrefab); instance.transform.SetParent(cityStatesObject.transform); instance.PickColor(); cityStates.Add(instance); return(instance); }
private void Apply(CityAdded @event) { _state = new CityState { Id = new NonEmptyIdentity(Id), Name = new CityName(@event.Name), Status = @event.Status }; }
public void SetCityStatePlayer(Player player, int cityStateID) { CityState cityState = cityStates.Find(c => c.CityStateID == cityStateID); if (cityState && cityState.Player != player) { cityState.Player = player; } }
public static void Load(BinaryReader reader, GameController gameController, HexGrid hexGrid, int header) { HexCoordinates coordinates = HexCoordinates.Load(reader); int cityStateID = reader.ReadInt32(); CityState cityState = gameController.GetCityState(cityStateID); HexCell cell = hexGrid.GetCell(coordinates); gameController.CreateCity(cell, cityState); }
public void SetCityState(CityState cityState) { if (cityStateOwner) { cityStateOwner.RemoveCity(this); } cityStateOwner = cityState; cityStateOwner.AddCity(this); }
public CityState CreateCityState(Color color) { CityState instance = Instantiate(cityStatePrefab); instance.transform.SetParent(cityStatesObject.transform); RemoveCityStateColor(color); instance.Color = color; cityStates.Add(instance); return(instance); }
public async Task <IActionResult> Places(string zip, string keyword) { CityState location = await zd.GetCity(zip); float latitude = location.lat; float longitude = location.lng; Places places = await pd.GetPlaces(latitude, longitude, keyword); return(View(places)); }
public async Task <IActionResult> Restaurants(string zip, string cuisine) { CityState location = await zd.GetCity(zip); float latitude = location.lat; float longitude = location.lng; Places places = await pd.GetRestaurants(latitude, longitude, cuisine); return(View(places)); }
public void DestroyCityState(CityState cityState) { possibleCityStateColors.Add(cityState.Color); if (cityState.Player) { cityState.Player.RemoveCityState(cityState); } cityStates.Remove(cityState); cityState.DestroyCityState(); }
public void Clear() { HQState.Clear(); CityState.Clear(); HeroDeck.Clear(); VillainDeck.Clear(); BystanderStack.Clear(); MastermindTactics.Clear(); KOPile.Clear(); EscapePile.Clear(); }
public void SaveCity() { CityState state = new CityState(); state.cityName = metrics.getCityName(); state.timeRemaining = metrics.getTimeRemaining(); state.citizens = citizenControl.getCitizens(); state.sidewalks = structureControl.getSidewalks(); state.buildings = structureControl.getBuildings(); state.points = metrics.getNumPoints(); SaveGameToDisk(state); }
public override void Use(HexCell target = null) { if (target.City) { CityState cityState = target.City.GetCityState(); cityState.AdjustInfluenceForAllExcluding(gameObject.GetComponent <Unit>().GetPlayer(), (config as PropagandaConfig).GetInfluence()); cityState.CheckInfluence(); } PlayParticleEffect(); PlayAbilitySound(); PlayAnimation(); }
public void CreateCity(HexCell cell, CityState cityState) { City city = Instantiate(cityPrefab); city.transform.localPosition = HexMetrics.Perturb(cell.Position); city.SetHexCell(cell); city.transform.SetParent(citiesObject.transform); city.SetCityState(cityState); city.HexVision.AddVisibleObject(city.CityUI.gameObject); city.UpdateUI(); cities.Add(city); hexGrid.AddCity(city); }
public async Task SiloSayHelloTest() { var problem = ProblemBuilder.Build(File.ReadAllLines(@"..\..\..\Resources\a_example.in")); var state = new CityState(problem.Cars.ToImmutableList(), new RidesView3(problem.Rides, problem.Bonus), 0); var grain = GrainFactory.GetGrain <ITreeGrain <MakeRideAction> >(Guid.NewGuid()); await grain.Init(state); await grain.Build(); var bestNode = await grain.GetTopAction(); Assert.NotNull(bestNode); Trace.WriteLine(bestNode.Action); }
void Start() { ShowSliderValue(); newGameButton.onClick.AddListener(delegate { this.gameObject.SetActive(false); string cityName = nameText.text; cityControl.setupNewGame(cityName, sliderUI.value); }); loadGameButton.onClick.AddListener(delegate { if (dropdownHidden) { return; } // load selected file from disk CityState cityState = new CityState(); cityState.sidewalks = new List <Node>(); cityState.sidewalks.Add(new Node(1, 1)); cityState.buildings = new List <Node>(); cityState.sidewalks.Add(new Node(2, 2)); cityState.citizens = new List <Node>(); cityState.sidewalks.Add(new Node(3, 3)); string filename = savedGameDropdown.options[savedGameDropdown.value].text; BinaryFormatter bf = new BinaryFormatter(); if (File.Exists(Application.persistentDataPath + "/save_games/" + filename)) { FileStream file = File.Open(Application.persistentDataPath + "/save_games/" + filename, FileMode.Open); JsonUtility.FromJsonOverwrite((string)bf.Deserialize(file), cityState); file.Close(); } cityControl.LoadCity(cityState); this.gameObject.SetActive(false); }); sliderUI.onValueChanged.AddListener(delegate { ShowSliderValue(); }); returnMainMenuButton.onClick.AddListener(delegate { loadSavedGameNames(); this.gameObject.SetActive(true); }); quitButton.onClick.AddListener(delegate { Application.Quit(); }); loadSavedGameNames(); }
private void CheckAgainstBSSF(CityState state) { //Console.WriteLine("Solution: " + state.LowerBound + " BSSF: " + bssf_cost); //Check if the solution beats the bssf if (state.LowerBound < bssf_cost) { bssf_cost = state.LowerBound; bssf = state.Path; //Complete the path by adding the only destination left bssf.Add(cities[state.Children[0]]); //Comment out this line to disable pruning agenda.Prune(bssf_cost); } }
public HexUnit CreateCityStateUnit(CombatUnitConfig combatUnitConfig, HexCell cell, int cityStateID) { CityState cityState = cityStates.Find(c => c.CityStateID == cityStateID); HexUnit hexUnit = Instantiate(combatUnitPrefab).GetComponent <HexUnit>(); CombatUnit combatUnit = hexUnit.GetComponent <CombatUnit>(); combatUnit.SetCombatUnitConfig(combatUnitConfig); hexUnit.Grid = hexGrid; hexUnit.Location = cell; hexUnit.Orientation = Random.Range(0f, 360f); hexUnit.HexUnitType = HexUnit.UnitType.COMBAT; hexGrid.AddUnit(hexUnit); cityState.AddUnit(hexUnit.GetComponent <CombatUnit>()); return(hexUnit); }
public void SaveGameToDisk(CityState cityState) { // make save directory if it doesn't exist if (!hasSaveFile()) { Directory.CreateDirectory(Application.persistentDataPath + "/save_games"); } BinaryFormatter bf = new BinaryFormatter(); //Debug.Log(Application.persistentDataPath + "/save_games/" + cityState.cityName + ".json"); FileStream file = File.Create(Application.persistentDataPath + "/save_games/" + cityState.cityName + ".json"); var json = JsonUtility.ToJson(cityState); bf.Serialize(file, json); file.Close(); }
public override List <HexCell> IsValidTarget(HexCell target) { List <HexCell> targetCells = new List <HexCell>(); List <HexCell> cells = PathFindingUtilities.GetCellsInRange(target, (config as PropagandaConfig).Range); List <HexCell> cityCells = cells.FindAll(c => c.City); foreach (HexCell cityCell in cityCells) { CityState cityState = cityCell.City.GetCityState(); if (!cityState || cityState.Player == gameObject.GetComponent <Unit>().GetPlayer()) { continue; } targetCells.Add(cityCell); } return(targetCells); }
public void UpdateItem(int currID, int maxID) { if (data != null) { if (data.config.ID > maxID) { state = CityState.Unlocked; } else { if (data.config.ID != currID) { state = CityState.Pass; } else { state = CityState.Current; } } } }
public void CentreMap() { CityState cityState = humanPlayer.GetCityStates().FirstOrDefault(); if (cityState) { hexMapCamera.MoveCamera(cityState.GetCity().GetHexCell()); } else { Agent agent = humanPlayer.GetAgents().FirstOrDefault(); if (agent) { hexMapCamera.MoveCamera(agent.HexUnit.Location); } else { HexMapCamera.ValidatePosition(); } } }
private void ChangeState(CityState state) { switch (state) { case CityState.Catch: catching[currentForm].PlayAnimation(); break; case CityState.PostCatch: catchingRelease[currentForm].PlayAnimation(); break; case CityState.Fear: fear[currentForm].PlayAnimation(); PlayWord(WordType.Ouch); if (fearSound[currentForm] != null) { fearSound[currentForm].Fire(); } break; case CityState.Idle: idle[currentForm].PlayAnimation(); break; case CityState.Laugh: laugh[currentForm].PlayAnimation(); int t = Randomizer.GetRandomInt(3); if (t == 0) PlayWord(WordType.Woot); else if (t == 1) PlayWord(WordType.Yeah); else PlayWord(WordType.Haha); if (laughSound[currentForm] != null) { laughSound[currentForm].Fire(); } break; case CityState.Stopped: stopped[currentForm].PlayAnimation(); if (currentState == CityState.WakeingUp) { wakeingUp[currentForm].PauseAnimation(); } break; case CityState.Throw: throwing[currentForm].PlayAnimation(); throwRgball.NotifyThrow(); throwRgball = null; break; case CityState.WakeingUp: wakeingUp[currentForm].PlayAnimation(); if (currentState == CityState.Sleeping) { sleeping[currentForm].PauseAnimation(); } break; case CityState.Rotate: case CityState.Sleeping: sleeping[currentForm].PlayAnimation(); break; case CityState.WaitingGather: throwingPrepare[currentForm].PlayAnimation(); break; } currentState = state; }
/// <summary> /// Rose Steffensmeier /// Created: 2015/02/27 /// </summary> /// <remarks> /// Pat Banks /// Updated: 2015/04/03 /// Added GuestPIN /// </remarks> /// <param name="FirstName"></param> /// <param name="LastName"></param> /// <param name="Address1"></param> /// <param name="Address2"></param> /// <param name="CityState"></param> /// <param name="PhoneNumber"></param> /// <param name="EmailAddress"></param> /// <param name="Room"></param> /// <param name="Active"></param> /// <param name="GuestPIN"></param> public HotelGuest(string FirstName, string LastName, string Address1, string Address2, CityState CityState, string PhoneNumber, string EmailAddress, string Room, string GuestPIN, bool Active = true) { SetValues(null, FirstName, LastName, Address1, Address2, CityState, PhoneNumber, EmailAddress, Room, GuestPIN, Active); }
/// <summary> /// Rose Steffensmeier /// Created: 2015/02/27 /// </summary> /// <remarks> /// Pat Banks /// Updated: 2015/04/03 /// Added GuestPIN /// </remarks> /// <param name="HotelGuestID"></param> /// <param name="FirstName"></param> /// <param name="LastName"></param> /// <param name="Address1"></param> /// <param name="Address2"></param> /// <param name="CityState"></param> /// <param name="PhoneNumber"></param> /// <param name="EmailAddress"></param> /// <param name="Room"></param> /// <param name="Active"></param> /// <param name="GuestPIN"></param> private void SetValues(int? HotelGuestID, string FirstName, string LastName, string Address1, string Address2, CityState CityState, string PhoneNumber, string EmailAddress, string Room, string GuestPIN, bool Active) { this.HotelGuestID = HotelGuestID; this.FirstName = FirstName; this.LastName = LastName; this.Address1 = Address1; this.Address2 = Address2; this.CityState = CityState; this.PhoneNumber = PhoneNumber; this.EmailAddress = EmailAddress; this.Room = Room; this.Active = Active; this.GuestPIN = GuestPIN; }
private void CreateChildren(CityState parent) { CityState child; for (int i = 0; i < parent.Children.Count; i++) { //make child child = new CityState(parent.CostMatrix, parent.LowerBound, parent.Path, cities[parent.Children[i]]); //The last argument is get the next feasible destination from //a list the current state has produced //Comment this if expression except for the AddCandidate statement to disable pruning on generation //check if lower bound < bssf if (child.LowerBound < bssf_cost) //add to agenda agenda.AddCandidate(child); else { //Prune! ++pruneCnt; } } //commit candidates to agenda agenda.CommitCandidates(); }
private void InitAgenda(ref double[,] CostMatrix) { CityState firstState = new CityState(CostMatrix, 0, new ArrayList(), cities[0]); agenda.AddCandidate(firstState); agenda.CommitCandidates(); }
public void AddCandidate(CityState state) { candidates.Add(state); }