private static void LoadGameBuildings() { string buildings = GetSaveData("BUILDINGS"); if (buildings != "-1") { string[] buildsData = buildings.Split('|'); foreach (string bd in buildsData) { string[] data = bd.Split('*'); if (data.Length == 2) { Buildable building = GameData.GetBuilding(data[0]); if (building != null) { string[] vPos = data[1].Split(','); if (vPos.Length == 3) { Vector3 pos = new Vector3( float.Parse(vPos[0]), float.Parse(vPos[1]), float.Parse(vPos[2]) ); GameController.island.AddToBuildingBatch(building, pos); } } } } } }
public static int GetCost(this Buildable b) { if (LevelManager.properties == null) { throw new System.ArgumentException("Level not initialized!"); } switch (b) { case Buildable.Powerstation_left: { return(LevelManager.properties.ChargingLeftCost); } case Buildable.Powerstation_right: { return(LevelManager.properties.ChargingRightCost); } case Buildable.Powerstation_down: { return(LevelManager.properties.ChargingDownCost); } case Buildable.Powerstation_up: { return(LevelManager.properties.ChargingUpCost); } case Buildable.Pole: { return(LevelManager.properties.PoleCost); } case Buildable.Plant: { return(LevelManager.properties.PowerplantCost); } } return(0); }
void Awake() { // var targets = new List<MapBuildable>(); // We setup our rectangles for our messages _Save = new Rect(10, 100, 100, 100); _Load = new Rect(10, 200, 100, 100); _SaveMSG = new Rect(10, 120, 400, 40); _LoadMSG = new Rect(10, 140, 400, 40); // Where we want to save and load to and from // _FileLocation=Application.dataPath; _FileLocation = Application.persistentDataPath; _FileName = "SaveData.xml"; // we need soemthing to store the information into // myData=new MapBuildable[400]; myData = new SaveData(); ListOfBuildables.Init(); InitBuildableLayer(); FillBuildableLayer(); DefaultTerrain = new Buildable(); DefaultTerrain = ListOfBuildables.FindByName("Terrain_Flat_Prefab"); EmptyTerrain = new Buildable(); EmptyTerrain = ListOfBuildables.FindByName("Terrain_Empty_Prefab"); }
public override void Deactivate() { base.Deactivate(); validator?.EndValidation(); buildingObject = null; }
private void BuildableTransformed(Buildable buildable) { var builds = new[] { buildable }; BuildablesDestroyed(builds); BuildablesSpawned(builds); }
private void ResetState() { Destroy(current); current = null; IsBuilding = false; CurrentBuildable = Buildable.None; }
public void SEXT(Buildable element) { var ptcaX = _ptca(element.Direction.X, element.Position); var ptcaY = _ptca(element.Direction.Y, element.Position); //var ptcaZ = PTCA(element.Direction.Z, element.Position); var geom = _gmse.Create(1, DbElementTypeInstance.SEXTRUSION); geom.SetAttribute(DbAttributeInstance.TUFL, true); var error = string.Empty; PMLCommander.RunPMLCommand(geom, "PAAX", $"P{ptcaX.GetAsString(DbAttributeInstance.NUMB)}", out error); PMLCommander.RunPMLCommand(geom, "PBAX", $"P{ptcaY.GetAsString(DbAttributeInstance.NUMB)}", out error); PMLCommander.RunPMLCommand(geom, "PHEI", element.Size.Height.ToString(), out error); // no need to set position, as position is set by PAAX and PBAX //PMLCommander.RunPMLCommandInParentheses(geom, "PX", element.Position.X.ToString(), out error); //PMLCommander.RunPMLCommandInParentheses(geom, "PY", element.Position.Y.ToString(), out error); //PMLCommander.RunPMLCommandInParentheses(geom, "PZ", element.Position.Z.ToString(), out error); var sloo = geom.Create(1, DbElementTypeInstance.SLOOP); foreach (var vert in element.Verticies) { var svert = sloo.CreateLast(DbElementTypeInstance.SVERTEX); PMLCommander.RunPMLCommandInParentheses(svert, "PX", vert.X.ToString(), out error); PMLCommander.RunPMLCommandInParentheses(svert, "PY", vert.Y.ToString(), out error); } }
public void StartConstruction(Buildable buildable, string type) { Assert.IsTrue(type == "Room" || type == "Object"); currentlyBuilding = buildable; currentlyBuildingType = type; UpdateConstruction(); }
public BuildTask(Buildable blueprint, Vector3 construction_site) { Blueprint = blueprint; fixed_construction_site = construction_site; has_fixed_construction_site = true; }
void DoBuild(Buildable elt, bool cancel) { if (cancel) { testshit.StopCommand(GetComponent <EntityMirror>()); return; } if (component.buildInProgress && component.currentMode == Game.BuildMode.BUILD_THEN_PLACE && component.remainingTime <= 0) { if (elt.id != component.buildingWhat) { return; } testshit.BeginPlacement(elt.name, point => testshit.DeployCommand(GetComponent <EntityMirror>(), point), point => component.CheckBuildPlacement(component.buildingWhat, (Game.DVector3)point), () => {}); return; } var mode = Game.World.current.entityPrototypes[elt.name].BuildMode(); if (mode == Game.BuildMode.BUILD_IN_PLACE || mode == Game.BuildMode.BUILD_IMMEDIATE) { testshit.BeginPlacement(elt.name, point => testshit.BuildCommand(GetComponent <EntityMirror>(), elt.id, point), point => component.CheckBuildPlacement(elt.id, (Game.DVector3)point) && component.HaveEnoughResources(elt.id), () => {}); } else { testshit.BuildCommand(GetComponent <EntityMirror>(), elt.id, Vector3.zero); } }
public RihaNode place(RihaNode[] parameters) { RihaNode par = parameters[parameters.Length - 1]; RihaNode[] getZero = new RihaNode[] { new RihaNode(ValueType.number, 0) }; RihaNode[] getOne = new RihaNode[] { new RihaNode(ValueType.number, 1) }; string name = par.get(getZero).GetString(); RihaNode tileLocation = par.get(getOne); Buildable building = GameData.GetBuilding(name); if (building != null) { float x = (float)tileLocation.get(getZero).GetValue(); float z = (float)tileLocation.get(getOne).GetValue(); Tile t = GameController.island.GetTileByWorldCoords(x, z); GameController.playerController.SetBuilding(building); GameController.playerController.Build(t); return(new RihaNode(ValueType.boolean, true)); } return(new RihaNode(ValueType.boolean, false)); }
private void sellPropertyEvent(Buildable block) { if (GameController.waitModal) { return; } string text; if (block.getProperties() < 5) { text = "Bạn có chắc muốn bán nhà trên <color=" + block.color + "><b>" + block.blockName + "</b></color> với giá <color=#216C2A><b>" + block.propertyPrice / 2 + "Đ</b></color> không?"; } else { text = "Bạn có chắc muốn bán khách sạn trên <color=" + block.color + "><b>" + block.blockName + "</b></color> với giá <color=#216C2A><b>" + block.propertyPrice / 2 + "Đ</b></color> không?"; } Modal.instance().showModal(text, "Có", "Không", () => { GameController.playerInTurn().sellProperty(block); showInfo(block); }, () => { } ); }
private void buyPropertyEvent(Buildable block) { if (GameController.waitModal) { return; } Player player = GameController.playerInTurn(); if (player.getFund() >= block.propertyPrice) { string text; if (block.getProperties() < 4) { text = "Bạn có chắc muốn mua nhà trên <color=" + block.color + "><b>" + block.blockName + "</b></color> với giá <color=#aa0115><b>" + block.propertyPrice + "Đ</b></color> không?"; } else { text = "Bạn có chắc muốn mua khách sạn trên <color=" + block.color + "><b>" + block.blockName + "</b></color> với giá <color=#aa0115><b>" + block.propertyPrice + "Đ</b></color> không?"; } Modal.instance().showModal(text, "Có", "Không", () => { player.buyProperty(block); showInfo(block); }, () => { } ); } else { Modal.instance().showModal("Bạn không đủ tiền để mua tài sản!", "OK", () => { }); } }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); return; } if (buildables == null || buildables.Length <= 0) { return; } /////GENERATE POOLS buildPools = new Queue <Buildable> [buildables.Length]; for (int i = 0; i < buildPools.Length; i++) { Queue <Buildable> buildQueue = new Queue <Buildable>(); for (int j = 0; j < buildables[i].amount; j++) { Buildable b = (Buildable)Instantiate(buildables[i].buildPrefab, transform.position, Quaternion.identity); buildQueue.Enqueue(b); b.gameObject.SetActive(false); } buildPools[i] = buildQueue; } }
void Start() { spriteRenderer = gameObject.GetComponent <SpriteRenderer>(); node = GetComponentInParent <Node>(); buildable = GetComponent <Buildable>(); if (!spriteRenderer) { throw new UnityException("Auto Tile needs a sprite renderer"); } UnityEngine.Object[] tiles = Resources.LoadAll("AutoTile/" + texture.name); sortedTiles = new UnityEngine.Object[16]; sortedTiles[0] = tiles[16]; sortedTiles[1] = tiles[12]; sortedTiles[2] = tiles[15]; sortedTiles[3] = tiles[11]; sortedTiles[4] = tiles[13]; sortedTiles[5] = tiles[9]; sortedTiles[6] = tiles[14]; sortedTiles[7] = tiles[10]; sortedTiles[8] = tiles[4]; sortedTiles[9] = tiles[8]; sortedTiles[10] = tiles[3]; sortedTiles[11] = tiles[7]; sortedTiles[12] = tiles[1]; sortedTiles[13] = tiles[5]; sortedTiles[14] = tiles[2]; sortedTiles[15] = tiles[6]; UpdateState(); }
public PowerStationRoad BuildPowerstation(Buildable station, Vector2 position, World reference) { Road built = null; Vector2 toFix; switch (station) { case Buildable.Powerstation_left: { built = RoadFactory.CreateChargeSpotLeft((int)position.x, (int)position.y); toFix = position - Vector2.right; break; } case Buildable.Powerstation_right: { built = RoadFactory.CreateChargeSpotRight((int)position.x, (int)position.y); toFix = position + Vector2.right; break; } case Buildable.Powerstation_down: { built = RoadFactory.CreateChargeSpotDown((int)position.x, (int)position.y); toFix = position - Vector2.up; break; } case Buildable.Powerstation_up: { built = RoadFactory.CreateChargeSpotUp((int)position.x, (int)position.y); toFix = position + Vector2.up; break; } default: { throw new System.ArgumentException(); } } //get grid position Vector2 imagpos = reference.GetImagWorldCoordinates((int)position.x, (int)position.y); Vector2 imagfix = reference.GetImagWorldCoordinates((int)toFix.x, (int)toFix.y); //Add new road, destroy old neighbouring road and create new neighbouring road, then ling everything together again roadGrid[(int)imagpos.y, (int)imagpos.x] = built; roads.Remove(roadGrid[(int)imagfix.y, (int)imagfix.x]); //Debug.Log(roadGrid[(int)imagfix.y, (int)imagfix.x]); World.Destroy(roadGrid[(int)imagfix.y, (int)imagfix.x].gameObject); roadGrid[(int)imagfix.y, (int)imagfix.x] = CreateRoad((int)imagfix.x, (int)imagfix.y, (int)toFix.x, (int)toFix.y); Road fixd = roadGrid[(int)imagfix.y, (int)imagfix.x]; roadGrid[(int)imagpos.y, (int)imagpos.x] = null; CreateRoadNetwork(roadGrid); roadGrid[(int)imagpos.y, (int)imagpos.x] = built; built.neighbourRoads.Add(fixd); fixd.neighbourRoads.Add(built); roads.Add(built); roads.Add(fixd); return(built as PowerStationRoad); }
public void SetBuildAction(Buildable building) { currentAction = ActionType.BUILD; buildingAction = building; SpriteRenderer cursorSpriteRenderer = (SpriteRenderer)cursor.GetComponent <SpriteRenderer>(); cursorSpriteRenderer.sprite = building.GetComponent <SpriteRenderer>().sprite; }
private void OnTriggerStay2D(Collider2D collision) { if (collision.tag == "Buildable") { canBuild = true; currentBuildable = collision.GetComponent <Buildable>(); } }
public static BuildTask CreateHelpBuildTask(Buildable project) { BuildTask help_build_task = new BuildTask(null); help_build_task.Project = project; return(help_build_task); }
public void Build(Buildable buildable, BuildableSlot slot) { if (slot.SlotState == BuildableSlot.SlotStates.EMPTY) { GameObject newTower = Instantiate(buildable.Prefab, slot.transform.position, slot.transform.rotation); slot.AssignContent(newTower); } }
public void AddToBuildingBatch(Buildable building, Vector3 location) { if (buildingBatch == null) { buildingBatch = new Dictionary <Vector3, Buildable>(); } buildingBatch.Add(location, building); }
/// <summary> /// Checks if another buildable is within range of this base cluster. /// </summary> /// <param name="buildable">The buildable to check.</param> /// <returns> /// <see langword="true"/> if the buildable is within range. /// <br/> /// <see langword="false"/> if the buildable is outside range. /// </returns> public bool IsWithinRange(Buildable buildable) { var structures = Buildables.OfType <StructureBuildable>(); var distanceCheck = buildable is StructureBuildable ? Mathf.Pow(m_PluginConfiguration.MaxDistanceBetweenStructures, 2) : Mathf.Pow(m_PluginConfiguration.MaxDistanceToConsiderPartOfBase, 2); return(structures.Any(k => (k.Position - buildable.Position).sqrMagnitude <= distanceCheck)); }
private void TestLoad() { string path = Application.dataPath + "/Scripts/Editor/stairs.json"; string json = File.ReadAllText(path); buildings = JsonUtility.FromJson <Buildings>(json); selected = buildings.buildings[0]; Debug.Log(buildings.buildings.Count); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Class != null) { hashCode = hashCode * 59 + Class.GetHashCode(); } if (Actions != null) { hashCode = hashCode * 59 + Actions.GetHashCode(); } if (Blocked != null) { hashCode = hashCode * 59 + Blocked.GetHashCode(); } if (Buildable != null) { hashCode = hashCode * 59 + Buildable.GetHashCode(); } if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (InQueueSince != null) { hashCode = hashCode * 59 + InQueueSince.GetHashCode(); } if (Params != null) { hashCode = hashCode * 59 + Params.GetHashCode(); } if (Stuck != null) { hashCode = hashCode * 59 + Stuck.GetHashCode(); } if (Task != null) { hashCode = hashCode * 59 + Task.GetHashCode(); } if (Url != null) { hashCode = hashCode * 59 + Url.GetHashCode(); } if (Why != null) { hashCode = hashCode * 59 + Why.GetHashCode(); } if (BuildableStartMilliseconds != null) { hashCode = hashCode * 59 + BuildableStartMilliseconds.GetHashCode(); } return(hashCode); } }
public void UpdateCurrentBuilding() { Card card = CardController.cardController.GetSelectedCard(); if (card != null && card.IsBuildable()) { building = card.GetBuildable(); } }
public BuildDialogItem CreateBuildDialogItem(Buildable buildable, RectTransform parent) { BuildDialogItem item = this.fact_BuildDialogItem.Create(); item.transform.SetParent(parent); item.transform.localPosition = Vector3.zero; item.Init(buildable); return(item); }
public void CancelCurrent() { Destroy(current); current = null; IsBuilding = false; CurrentBuildable = Buildable.None; //Unfold all houses UnfoldDecorations(); }
private bool CreateBuildBlueprint(Node node, Buildable building) { GameObject buildingBlock = node.Build(building); if (!buildingBlock) { return(false); } return(true); }
private void Item_Clicked(Buildable buildable) { if (this.playerResources.Pay(buildable.Cost)) //if (Root.PlayerResources.Pay(buildable.Cost)) { //Root.BuildUI.Close(); //Root.BuildSystem.Build(buildable, this.slot); this.buildUI.Close(); this.buildSystem.Build(buildable, this.slot); } }
public Buildable InstantiateProject(Vector3 construction_site) { Buildable copy = GameObject.Instantiate(this, Scene.Main.World.transform); copy.transform.position = construction_site; copy.Foundation = new Pile(); copy.IsProject = true; return(copy); }
internal void removeGameObject(Buildable buildable) { if (buildable is SolarPanel) { Debug.Log("this.SolarPanels.count: " + this.SolarPanels.Count); var objectToRemove = this.SolarPanels.SingleOrDefault(c => c.Id == buildable.Id); this.SolarPanels.Remove(objectToRemove); } if (buildable is OxygenExtractor) { var objectToRemove = this.OxygenExtractors.SingleOrDefault(c => c.Id == buildable.Id); this.OxygenExtractors.Remove(objectToRemove); } if (buildable is MicrowaveAntenna) { var objectToRemove = this.MicrowaveAntennas.SingleOrDefault(c => c.Id == buildable.Id); this.MicrowaveAntennas.Remove(objectToRemove); } if (buildable is MineralExtractor) { var objectToRemove = this.MineralExtractors.SingleOrDefault(c => c.Id == buildable.Id); this.MineralExtractors.Remove(objectToRemove); } if (buildable is OxygenRefinery) { var objectToRemove = this.OxygenRefineries.SingleOrDefault(c => c.Id == buildable.Id); this.OxygenRefineries.Remove(objectToRemove); } if (buildable is SolarPanelFactory) { var objectToRemove = this.SolarPanelsFactory.SingleOrDefault(c => c.Id == buildable.Id); this.SolarPanelsFactory.Remove(objectToRemove); } var buildableToRemove = this.EnergyConsumers.SingleOrDefault(c => c.Id == buildable.Id && c is MicrowaveAntenna); if (buildableToRemove != null) { this.EnergyConsumers.Remove(buildableToRemove); } buildableToRemove = this.EnergyConsumers.SingleOrDefault(c => c.Id == buildable.Id && c is OxygenExtractor); if (buildableToRemove != null) { this.EnergyConsumers.Remove(buildableToRemove); } }