public RenderableBuilding(BuildingConfiguration template) : base() { BuildingType bt = template.BuildingType; switch (bt) { case BuildingType.Residential: this.data = new Residential(template); break; case BuildingType.Commercial: this.data = new Commercial(template); break; case BuildingType.Industrial: this.data = new Industrial(template); break; case BuildingType.Infrastructure: this.data = new Infrastructure(template); break; } this.entities = new List <Entity>(); this.Name = this.data.GetType().ToString() + "_" + this.GetHashCode(); data.Deleted += this.OnBuildingDeleted; }
private void LoadConfiguration(BuildingConfiguration _bc) { if (0 < _bc.Version && _bc.Version <= 3) { switch (_bc.Version) { case 1: this._income = 70000; this._employees = 500; break; case 2: this._income = 1000000; this._employees = 1000; break; case 3: this._income = 50000000; this._employees = 75000; break; default: goto case 1; } } }
private void LoadConfiguration(BuildingConfiguration _bc) { if (0 < _bc.Version && _bc.Version <= 3) { switch (_bc.Version) { case 1: this.Income = 1000000; this.Employees = 250; this.PollutionAmount = 100; break; case 2: this.Income = 5000000; this.Employees = 750; this.PollutionAmount = 500; break; case 3: this.Income = 75000000; this.Employees = 1000; this.PollutionAmount = 750; break; default: goto case 1; } } }
public ElevatorSchedulingController( ILogger <ElevatorSchedulingController> logger, [FromServices] IEnumerable <IHostedService> services, BuildingConfiguration buildingConfiguration) { _logger = logger; _schedulingSrv = services.FirstOrDefault(x => x is SchedulingService) as SchedulingService; _buildingConfiguration = buildingConfiguration; }
protected Elevator(ElevatorConfiguration _elevatorConfiguration, BuildingConfiguration _buildingConfiguration, ElevatorStrategy _elevatorStrategy) { elevatorConfiguration = _elevatorConfiguration; buildingConfiguration = _buildingConfiguration; elevatorStrategy = _elevatorStrategy; m_driver = new ElevatorDriver(_elevatorConfiguration, _buildingConfiguration); }
public static void CreateBuildingOnCursor(BuildingConfiguration template) { RenderableBuilding rb = new RenderableBuilding(template); rb.Create(GameMgr.StateMgr.Engine.SceneMgr, cityNode); rb.IsVirtual = true; GameMgr.SetCursorBuilding(rb); GameMgr.SetMouseMode(MouseMode.PlacingBuilding); GuiMgr.ShowBuildingPlacementPanel(); }
protected override void InitContent(SpawnInfo info) { BuildingSpawnInfo buildingSpawnInfo = info as BuildingSpawnInfo; Assert.IsNotNull(buildingSpawnInfo, "Tried to spawn building popup without building spawn info!"); this.config = buildingSpawnInfo.config; this.InitSharedVisuals(); }
public CallSimulatorService(ILogger <CallSimulatorService> logger, ICallPanelService callPanelService, BuildingConfiguration buildingConfiguration, CallPanelConfiguration callPanelConfiguration) { _logger = logger; _callPanelService = callPanelService; _buildingConfiguration = buildingConfiguration; _callPanelConfiguration = callPanelConfiguration; }
public ElevatorService(ILogger <ElevatorService> logger, IHubContext <ElevatorTrackingHub> hub, BuildingConfiguration buildingConfiguration, ElevatorConfiguration elevatorConfiguration) { _logger = logger; _hub = hub; _buildingConfiguration = buildingConfiguration; _elevatorConfiguration = elevatorConfiguration; }
BuildingConfiguration GetFakeBuildingConfiguration(string name, BuildingType type, int maxAmount) { BuildingConfiguration result = ScriptableObject.CreateInstance <BuildingConfiguration>(); result.name = name; result.buildingType = type; result.maxAmount = maxAmount; return(result); }
public void Initialize() { configuration = new BuildingConfiguration { NumberOfElevators = 5u, NumberOfFloors = 10u }; sut = new BuildingConfigurationService(configuration); }
public void Init(BuildingConfiguration config, bool canBuild) { this.background.color = config.mainColor; this.title.text = config.buildingName; this.icon.sprite = config.icon; this.locked.SetActive(!canBuild); this.draggable.Init(config); this.draggable.enabled = canBuild; }
/// <summary> /// Writes the blueprint to a file using binary formatting. /// </summary> public void WriteBinary() { using BinaryWriter binaryWriter = new BinaryWriter(File.Open(FilePath, FileMode.OpenOrCreate)); binaryWriter.Write(FriendlyName); binaryWriter.Write(BuildingConfiguration.Count); BuildingConfiguration.ForEach(buildingConfig => buildingConfig.WriteBinary(binaryWriter)); binaryWriter.Write(DigLocations.Count); DigLocations.ForEach(digLocation => { binaryWriter.Write(digLocation.x); binaryWriter.Write(digLocation.y); }); }
public ElevatorBank(BuildingConfiguration _buildingConfiguration, List <Elevator> _elevators, GameClock _gameClock) { buildingConfiguration = _buildingConfiguration; elevators = _elevators; gameClock = _gameClock; foreach (Elevator elevator in elevators) { elevator.registerGameClock(gameClock); } }
public static void Main(String[] args) { System.Diagnostics.Debug.WriteLine("Starting Up"); GameClock clock = new GameClock(100); BuildingConfiguration buildingConfiguration = new BuildingConfiguration("Devonshire Place", -1, 8, 13); ElevatorConfiguration elevatorConfiguration = new ElevatorConfiguration("Elevator 1", 4000); List <ElevatorConfiguration> elevatorConfigurations = new List <ElevatorConfiguration>(); elevatorConfigurations.Add(elevatorConfiguration); ElevatorBankConfiguration bankConfiguration = new ElevatorBankConfiguration("Main Elevators", buildingConfiguration, elevatorConfigurations); Elevator firstElevator = new Elevator(elevatorConfiguration, buildingConfiguration); List <Elevator> elevators = new List <Elevator>(); elevators.Add(firstElevator); ElevatorBank bank = new ElevatorBank(buildingConfiguration, elevators, clock); ElevatorUserGeneration userGenerator = new ElevatorUserGeneration(5, buildingConfiguration.minFloor, buildingConfiguration.maxFloor, bank); StepAction nextAction = new StepAction("SimpleAction", (int stepNumber) => userGenerator.registerUser(stepNumber)); clock.registerStepAction(nextAction); clock.run(); System.Diagnostics.Debug.WriteLine("Successfully executed run. Shutting down"); }
/// <summary> /// Add a new building to the city at the specified coordinates /// </summary> /// <param name="x"></param> /// <param name="y"></param> public static void NewBuilding(int x, int y, BuildingConfiguration b) { if (Initialized) { try { Haswell.Controller.City.CreateBuilding(x, y, b); } catch (BuildingCreationFailedException e) { GameConsole.ActiveInstance.WriteLine(e.Message); GuiMgr.AddInfoPopup(e.Message); } } else { GameConsole.ActiveInstance.WriteError("Unable to create building, no city initialized!"); } }
public void TestGetBuilding() { BuildingConfiguration common = this.configService.GetBuilding("Common_1"); Assert.IsNotNull(common); Assert.AreEqual("Common_1", common.name); Assert.AreEqual(BuildingType.COMMON, common.buildingType); Assert.AreEqual(5, common.maxAmount); BuildingConfiguration unique = this.configService.GetBuilding("Unique_2"); Assert.IsNotNull(unique); Assert.AreEqual("Unique_2", unique.name); Assert.AreEqual(BuildingType.UNIQUE, unique.buildingType); Assert.AreEqual(1, unique.maxAmount); }
public GameObject instantiate(BuildingClass buildingType, GameObject Owner, Vector3 position, bool activated) { GameObject instance = (GameObject)PhotonNetwork.Instantiate("Prefabs/Buildings/" + buildingType.GO.name, position, Quaternion.identity, 0); BuildingConfiguration config = instance.AddComponent <BuildingConfiguration>(); instance.AddComponent <Owner>(); instance.GetComponent <Owner>().owner = Owner; config.metalCost = buildingType.metalCost; config.metalProd = buildingType.metalProd; config.energy = buildingType.energy; config.buildTime = buildingType.buildTime; config.health = buildingType.health; config.name = buildingType.name; config.GO = instance; config.isActivated = activated; return((GameObject)instance); }
public ElevatorDriver(ElevatorConfiguration _elevator, BuildingConfiguration _building) { m_elevator = _elevator; building = _building; m_state = new ElevatorState( 0, DoorState.Open(), ElevatorMovement.Stopped(), ElevatorMovement.Stopped()); m_action = new ElevatorAction(ElevatorAction.Opening, 0); m_stepAction = new StepAction("ElevatorDriver Action", (stepNumber) => proceedToNextState(stepNumber)); }
public bool CanBuildBuilding(BuildingConfiguration buildingConfig) { if (buildingConfig.maxAmount < 0) { return(true); } int amount = 0; foreach (var building in this.buildings) { if (building.Config.Equals(buildingConfig)) { amount++; } } return(amount < buildingConfig.maxAmount); }
public SchedulingService(ILogger <SchedulingService> logger, IHubContext <ElevatorTrackingHub> hub, IServiceProvider serviceProvider, BuildingConfiguration buildingConfiguration, ElevatorConfiguration elevatorConfiguration) { _logger = logger; _serviceProvider = serviceProvider; _buildingConfiguration = buildingConfiguration; _elevatorConfiguration = elevatorConfiguration; for (int i = 0; i < _buildingConfiguration.ElevatorCount; i++) { var elevator = new Elevator(); elevator.Id = i; _elevators.Add(elevator); } _hub = hub; }
private void LoadConfiguration(BuildingConfiguration _bc) { if (0 < _bc.Version && _bc.Version <= 3) { #region TODO //string configurationText = File.OpenText(CONFIGURATIONFILE + _bc.Version + ".json").ReadToEnd(); //JsonTextReader reader = new JsonTextReader(new StringReader(configurationText)); //string s; //while ((s = reader.ReadAsString()) == null) //{ // if (s == null) // break; // this.configuration[s] = reader.Value; //} #endregion switch (_bc.Version) { case 1: this._residents = 4; this._income = 10000; break; case 2: this._residents = 500; this._income = 20000; break; case 3: this._residents = 16; this._income = 100000; break; default: goto case 1; } } }
public bool ReadBinary() { if (File.Exists(FilePath)) { BuildingConfiguration.Clear(); DigLocations.Clear(); try { using (BinaryReader reader = new BinaryReader(File.Open(FilePath, FileMode.Open))) { FriendlyName = reader.ReadString(); int buildingCount = reader.ReadInt32(); for (int i = 0; i < buildingCount; ++i) { BuildingConfig buildingConfig = new BuildingConfig(); if (!buildingConfig.ReadBinary(reader)) { return(false); } BuildingConfiguration.Add(buildingConfig); } int digLocationCount = reader.ReadInt32(); for (int i = 0; i < digLocationCount; ++i) { DigLocations.Add(new Vector2I(reader.ReadInt32(), reader.ReadInt32())); } } return(true); } catch (System.Exception exception) { Debug.LogError("Error when loading blueprint: " + FilePath + ",\n" + nameof(exception) + ":" + exception.Message); } } return(false); }
public List <Building> LoadBuildings() { List <Building> result = new List <Building>(); IBuildingConfigurationService buildingConfigurationService = ServiceLocator.Instance.GetService <IBuildingConfigurationService>(); FullBuildingSave fullSave = this.saveService.Load <FullBuildingSave>(BuildingSaveService.BUILDUNG_SAVE_KEY); if (fullSave != null) { foreach (var saveData in fullSave.buildings) { BuildingConfiguration buildingConfig = buildingConfigurationService.GetBuilding(saveData.configName); Building building = new Building(buildingConfig); building.SetGridPosition(saveData.gridPosition); result.Add(building); } } return(result); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var buildingConfig = new BuildingConfiguration(); Configuration.Bind("Building", buildingConfig); services.AddSingleton(buildingConfig); var callPanelConfig = new CallPanelConfiguration(); Configuration.Bind("CallPanel", callPanelConfig); services.AddSingleton(callPanelConfig); services.AddHttpClient(); services.AddTransient(typeof(ICallPanelService), typeof(CallPanelService)); if (callPanelConfig.CallPanelSimulationEnabled) { services.AddHostedService <CallSimulatorService>(); } services.AddControllers(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var buildingConfig = new BuildingConfiguration(); Configuration.Bind("Building", buildingConfig); services.AddSingleton(buildingConfig); var elevatorConfig = new ElevatorConfiguration(); Configuration.Bind("Elevator", elevatorConfig); services.AddSingleton(elevatorConfig); services.AddTransient <IElevatorService>(s => new ElevatorService(logger: s.GetRequiredService <ILogger <ElevatorService> >(), hub: s.GetRequiredService <IHubContext <ElevatorTrackingHub> >(), buildingConfiguration: buildingConfig, elevatorConfiguration: elevatorConfig)); services.AddHostedService <SchedulingService>(); services.AddControllers(); services.AddSignalR(); }
public Commercial(BuildingConfiguration _bc) : base(Zones.Commercial) { this._buildingConfig = _bc; LoadConfiguration(_bc); }
/// <summary> /// Reads the contents of a JSON-formatted file and adds it to the blueprint. /// </summary> public void ReadJSON() { if (File.Exists(FilePath)) { try { using StreamReader reader = File.OpenText(FilePath); using JsonTextReader jsonReader = new JsonTextReader(reader); JObject rootObject = (JObject)JToken.ReadFrom(jsonReader).Root; JToken friendlyNameToken = rootObject.SelectToken("friendlyname"); JToken buildingsToken = rootObject.SelectToken("buildings"); JToken digCommandsToken = rootObject.SelectToken("digcommands"); if (friendlyNameToken != null && friendlyNameToken.Type == JTokenType.String) { FriendlyName = friendlyNameToken.Value <string>(); } if (buildingsToken != null) { JArray buildingTokens = buildingsToken.Value <JArray>(); if (buildingTokens != null) { foreach (JToken buildingToken in buildingTokens) { BuildingConfig buildingConfig = new BuildingConfig(); buildingConfig.ReadJSON((JObject)buildingToken); BuildingConfiguration.Add(buildingConfig); } } } if (digCommandsToken != null) { JArray digCommandTokens = digCommandsToken.Value <JArray>(); if (digCommandTokens != null) { foreach (JToken digCommandToken in digCommandTokens) { JToken xToken = digCommandToken.SelectToken("x"); JToken yToken = digCommandToken.SelectToken("y"); if (xToken != null && xToken.Type == JTokenType.Integer || yToken != null && yToken.Type == JTokenType.Integer) { DigLocations.Add(new Vector2I(xToken == null ? 0 : xToken.Value <int>(), yToken == null ? 0 : yToken.Value <int>())); } else if (xToken == null && yToken == null) { DigLocations.Add(new Vector2I(0, 0)); } } } } CacheCost(); } catch (System.Exception exception) { Debug.Log("Error when loading blueprint: " + FilePath + ",\n" + nameof(exception) + ": " + exception.Message); } } }
public void InitWithConfig(BuildingConfiguration config) { this.Init(new Building(config)); }
public static TileConfiguration <T> GetFromRootElement(XElement elemRoot, XName name) { TileConfiguration <T> output; if (elemRoot.Element(name).Elements().Count() == 0) { output = new TileMaterialConfiguration <T>(); output.nodeName = name.LocalName; return(output); } string matchType = "NoMatch"; XElement matchElement = elemRoot.Element(name).Elements().First(); foreach (var element in elemRoot.Element(name).Elements()) { if (element.Name.LocalName == "subObject") { continue; } matchType = element.Name.LocalName; matchElement = element; break; } switch (matchType) { case "material": output = new TileMaterialConfiguration <T>(); break; case "tiletype": output = new TileTypeConfiguration <T>(); break; case "random": output = new RandomConfiguration <T>(); break; case "ramp": output = new RampConfiguration <T>(); break; case "item": if (ItemTokenList.IsValid) { output = new ItemConfiguration <T>(); } else { Debug.LogError("Item Types not available in this version of Remotefortressreader. Please upgrade."); output = new TileMaterialConfiguration <T>(); } break; case "buildingType": output = new BuildingConfiguration <T>(); break; case "buildingPosition": output = new BuildingPosConfiguration <T>(); break; case "growth": output = new PlantGrowthConfiguration <T>(); break; case "designation": output = new TileDesignationConfiguration <T>(); break; default: IXmlLineInfo lineinfo = matchElement; Debug.LogError("Found unknown matching method \"" + matchType + "\" int " + elemRoot.BaseUri + ":" + lineinfo.LineNumber + "," + lineinfo.LinePosition + ", assuming material."); output = new TileMaterialConfiguration <T>(); break; } output.nodeName = name.LocalName; return(output); }