Пример #1
0
        private Cell AddCellAt(Vector3 pos)
        {
            var newCell = Instantiate(Prefabs.Get <Cell>(), pos, Prefabs.Get <Cell>().transform.rotation);

            newCell.transform.parent = transform;
            return(newCell);
        }
Пример #2
0
 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);
 }
Пример #3
0
        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;
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
 public void SetElement <T>() where T : Element
 {
     element = Instantiate(Prefabs.Get <T>(), transform.position, Quaternion.identity, transform);
 }