private Cell AddCellAt(Vector3 pos) { var newCell = Instantiate(Prefabs.Get <Cell>(), pos, Prefabs.Get <Cell>().transform.rotation); newCell.transform.parent = transform; return(newCell); }
public void AddBuilding <T>() where T : Building { if (building != null) { DestroyImmediate(building.gameObject); } building = Instantiate(Prefabs.Get <T>(), transform.position, Quaternion.identity, transform); building.OnAddedToTile(this); }
public void MakeCorruptionNode() { // Don't duplicate corruption. if (this.corruption != null) { return; } var corruption = Instantiate(Prefabs.Get <Corruption>(), transform.position + new Vector3(0, 0.65f, 0), Quaternion.identity); corruption.cell = this; this.corruption = corruption; }
public bool HandleBuildingPlacement(HexGridController hex, Cell buildOn) { // If starting selection with a new cell, populate Hex Menu if (buildingCell != buildOn) { Reset(); buildingCell = buildOn; var toCamera = Vector3.Normalize(Camera.main.transform.position - buildingCell.transform.position); hexMenu = Object.Instantiate(Prefabs.Get <HexMenu>(), buildOn.transform.position, Quaternion.identity); hexMenu.Populate(); hex.RaiseTile(buildingCell); } if (state == PlacingState.SelectBuildingType) { if (!ValidBuildingPlacementKeyPressed()) { return(false); } if (Input.GetKeyDown(KeyCode.Alpha1)) { buildingCell.AddBuilding <ExpansionTower>(); } else if (Input.GetKeyDown(KeyCode.Alpha2)) { buildingCell.AddBuilding <Cleanser>(); } else if (Input.GetKeyDown(KeyCode.Alpha3)) { buildingCell.AddBuilding <Enricher>(); } else if (Input.GetKeyDown(KeyCode.Alpha4)) { buildingCell.AddBuilding <Foundation>(); } else if (Input.GetKeyDown(KeyCode.Alpha5)) { buildingCell.AddBuilding <Spire>(); } hexMenu.Clear(); return(true); } return(false); }
public Cell TickFillCorruption() { if (isSpreading) { corruptionLevel += fillRate; Vector3 newOrbPos = transform.position + new Vector3(0, 0.15f + (orbs.Count * 0.15f), 0); var newOrb = Instantiate(Prefabs.Get <CorruptionOrb>(), newOrbPos, Quaternion.identity); orbs.Add(newOrb); if (corruptionLevel >= fillThreshold) { isSpreading = false; return(SpreadCorruptionToNeighbours(cell)); } } return(null); }
private HexMenuCell AddCellAt(Vector3 pos) { var newCell = Object.Instantiate(Prefabs.Get <HexMenuCell>(), pos, Quaternion.Euler(90, 0, 0)); var offset = Vector3.zero; //offset.x = (HexSize * 1.5f) * -1; //offset.y = 0.2f; //offset.z = 0f; offset.x = (HexSize * 1.5f) * -1; offset.y = 0.5f; offset.z = 0; newCell.transform.Translate(offset); return(newCell); }
public void SetElement <T>() where T : Element { element = Instantiate(Prefabs.Get <T>(), transform.position, Quaternion.identity, transform); }