public void ProcessBuilding(ushort buildingId, BuildingHandler handler) { ProcessBuilding( buildingId, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId], handler); }
// Start is called before the first frame update void Start() { _buildingHandler = GameObject.Find("Game Manager").GetComponent <BuildingHandler>(); _buttonImage = GetComponent <Image>(); _defaultColor = _buttonImage.color; GetComponent <Button>().onClick.AddListener(OnClick); }
// Start is called before the first frame update void Start() { _gameManager = GameObject.Find("Game Manager").GetComponent <GameManager>(); _buildingHandler = GameObject.Find("Game Manager").GetComponent <BuildingHandler>(); _newPosition = transform.position; _newRotation = transform.rotation; _newZoom = cameraTransform.localPosition; InitCameraPosition(); }
/// <summary> /// Main loop, runs the WebSocket connection. /// </summary> protected void RunSocket() { //We don't really need to store the handlers; //just create them and let them call our EnqueueMessage method. //XXX automatically find these like WebServer does. Log($"Creating socket handlers (thread: {Thread.CurrentThread.Name})"); BudgetHandler budgetHandler = new BudgetHandler(this); BuildingHandler buildingHandler = new BuildingHandler(this); CameraHandler cameraHandler = new CameraHandler(this); ChirperHandler chirperHandler = new ChirperHandler(this); CitizenHandler citizenHandler = new CitizenHandler(this); CityInfoHandler cityInfoHandler = new CityInfoHandler(this); DebugHandler debugHandler = new DebugHandler(this); DistrictHandler districtHandler = new DistrictHandler(this); FlagsHandler flagsHandler = new FlagsHandler(this); InstancesHandler instancesHandler = new InstancesHandler(this); LimitsHandler limitsHandler = new LimitsHandler(this); NotificationHandler notificationHandler = new NotificationHandler(this); ReflectionHandler reflectionHandler = new ReflectionHandler(this); TerrainHandler terrainHandler = new TerrainHandler(this); TransportHandler transportHandler = new TransportHandler(this); VehicleHandler vehicleHandler = new VehicleHandler(this); Log("Waiting for messages"); try { while (true) { if (stream.DataAvailable) { HandleNextMessage(); } String msg = GetNextOutgoingMessage(); if (msg != null) { byte[] buf = Encoding.UTF8.GetBytes(msg); SendFrame(buf); } Thread.Sleep(100); } } catch (ObjectDisposedException) { //we're done, stream is closed Log("Connection closed"); } catch (OperationCanceledException) { Log("Connection closed"); } }
// Use this for initialization void Start() { _lastAction = Time.time; _achieverScore = 0; _explorerScore = 0; _killerScore = 0; _socializerScore = 0; _cameraManager = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraManager>(); _buildHandler = new GameObject("BuildingHandler").AddComponent <BuildingHandler>(); _gameUIHandler = Instantiate((Resources.Load(Glob.UIPrefab) as GameObject).GetComponent <UIHandler>()); _soundHandler = new GameObject("SoundHandler").AddComponent <SoundHandler>(); _allCities = new City[Glob.AmountOfAICities + 1]; _playerCity = new GameObject("PlayerCity").AddComponent <City>().Initialize(new PlayerCityManager(), Glob.CityWidth, Glob.CityLength, Glob.TileSpacing, new Vector3(0, 0, 0)); _allCities[0] = _playerCity; for (int i = 1; i < Glob.AmountOfAICities + 1; i++) { if (HardModeEnabled) { _allCities[i] = new GameObject("AICity" + i).AddComponent <City>().Initialize(new AICityManager(Glob.HardAIDifficulty), Glob.CityWidth, Glob.CityLength, Glob.TileSpacing, new Vector3(Glob.CitySpacing * i, 0, 0)); } else { _allCities[i] = new GameObject("AICity" + i).AddComponent <City>().Initialize(new AICityManager(Glob.EasyAIDifficulty), Glob.CityWidth, Glob.CityLength, Glob.TileSpacing, new Vector3(Glob.CitySpacing * i, 0, 0)); } } _buildHandler.SetCurrentCity(_allCities[0]); Tutorial _tut = new GameObject("Tutorial").AddComponent <Tutorial>(); _bridgePlayer = GameObject.Find("Bridge1"); _bridgeAI = GameObject.Find("Bridge"); _bridgeAI.SetActive(false); _bridgePlayer.SetActive(false); }
public AIInputHandler Initialize(BuildingHandler pBuildingHandler) { _buildingHandler = pBuildingHandler; return(this); }
public void ProcessBuilding(ushort buildingId, ref Building building, BuildingHandler handler) { handler(buildingId, ref building); }
/// <summary> /// Processes a single file /// </summary> /// <param name="fileName"></param> /// <returns></returns> IEnumerator Run(string fileName) { var counter = 0; var sw = new Stopwatch(); sw.Start(); var lastFrame = sw.ElapsedMilliseconds; using (XmlReader reader = XmlReader.Create(fileName, new XmlReaderSettings { IgnoreWhitespace = true })) { yield return(null); while (!reader.EOF) { reader.Read(); if (reader.LocalName == "CityModel") { break; } } var version = 0; for (int i = 0; i < reader.AttributeCount; i++) { var attr = reader.GetAttribute(i); if (attr == "http://www.opengis.net/citygml/1.0") { version = 1; break; } if (attr == "http://www.opengis.net/citygml/2.0") { version = 2; break; } } if (version == 0) { Debug.LogWarning("Possibly invalid xml. Check for xml:ns citygml version."); } while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "cityObjectMember") { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "Building") { counter++; if (UpdateRate > 0 && sw.ElapsedMilliseconds > lastFrame + UpdateRate) { lastFrame = sw.ElapsedMilliseconds; yield return(null); } BuildingHandler.HandleBuilding(reader, this); } if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "X3DMaterial") { //HandleMaterial(reader); } if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "ParameterizedTexture") { //HandleTexture(reader); } } } } } //CombineMeshes(); //ApplyMaterials(); yield return(null); }
public void updateBuildings() { if (buildings.Count == 0) { return; } int numOfDrills = 0; int numOfRefineries = 0; int numOfBarracks = 0; maxNumberOfHumans = 0; foreach (BuildingTypes building in buildings) { if (building == BuildingTypes.drill) { numOfDrills++; } else if (building == BuildingTypes.researchFacility) { if (Random.Range(0f, 100f) < discoverAstroidChance) { discoverNewAstroid(); } } else if (building == BuildingTypes.house) { maxNumberOfHumans += 5; } else if (building == BuildingTypes.refinery) { numOfRefineries++; } else if (building == BuildingTypes.barrack) { numOfBarracks++; } } instability += 1f / (3f + numOfBarracks) * 2; if (instability >= 100) { BuildingTypes type = buildings[Random.Range(0, buildings.Count)]; for (int i = 0; i < transform.GetComponentsInChildren <BuildingHandler>().Length; i++) { BuildingHandler bh = transform.GetComponentsInChildren <BuildingHandler>()[i]; if (bh.type == type) { Destroy(bh.gameObject); break; } } buildings.Remove(type); instability = Mathf.Pow(1f / 2f, numOfBarracks + 1 - Mathf.Log(100) / Mathf.Log(2)); } if (numberOfHumans < maxNumberOfHumans / 5) { numberOfHumans = maxNumberOfHumans / 5; } localResources[(int)resource] += (int)((vainSize * Mathf.Pow(numOfDrills, 2f / 3f)) * Mathf.Max(numberOfHumans / 3, 1) * Mathf.Pow(3, numOfRefineries)); localResources[(int)ResourceTypes.rock] += (int)((Mathf.Pow(numOfDrills, 1f / 2f)) * Mathf.Max(numberOfHumans / 3, 1) * numOfRefineries / 2); if (humanTimer > timeBetweenHumans) { humanTimer -= timeBetweenHumans; numberOfHumans++; } //Resources.resources[(int)ResourceTypes.fuel] -= numberOfHumans/5; }
// Use this for initialization void Start() { core = FindObjectOfType <Core>(); buildingHandler = core.GetComponent <BuildingHandler>(); }