Exemplo n.º 1
0
        public void FindNearestTower()
        {
            structuresPool = GameObject.FindGameObjectsWithTag("Structure");
            int numOfStructures = structuresPool.Length;
            //Debug.Log(numOfStructures);
            float closestDist = 999999;

            for (int i = 0; i < numOfStructures; i++)
            {
                GameObject structure = structuresPool[i];
                if (!structure.activeInHierarchy || !structure.GetComponent <StructureBase>().isActive)
                {
                    continue;
                }
                Vector3 dist2Structure = structure.transform.position - transform.position;
                float   magSquared     = dist2Structure.sqrMagnitude;

                if (magSquared < closestDist || i == 0)
                {
                    closestDist = magSquared;
                    //closestTarget = structure;
                    closestTarget = structure.GetComponent <StructureBase>();
                }
            }
        }
Exemplo n.º 2
0
        private void OnTriggerEnter(Collider other)
        {
            StructureBase structure = other.GetComponent <StructureBase>();

            if (structure != null && structure == parent.closestTarget)
            {
                parent.hasReachedTarget = true;
                parent.newTarget        = false;
            }
        }
Exemplo n.º 3
0
        public void LoadTorrentArcStructure()
        {
            GameObject child = GetInactiveChild(torrentArcPool);

            if (child != null)
            {
                structureToPlace          = child.GetComponent <StructureBase>();
                structureToPlace.isActive = false;
                groundManager.TurnOnTiles(structureToPlace.borderList);
            }
        }
Exemplo n.º 4
0
        void PlaceStructure(TileScript tile)
        {
            if (currentMoney >= structureToPlace.cost)
            {
                structureToPlace.isActive = true;

                currentMoney  -= structureToPlace.cost;
                moneyText.text = "" + currentMoney;

                structureToPlace.ResetStructure();
                structureToPlace.Build();

                structureToPlace = null;

                groundManager.SetTileSpace(tile);
                groundManager.TurnOffTiles();
            }
            else
            {
                Debug.Log("Not Enough Money" + currentMoney + "/" + structureToPlace.cost);
            }
        }
Exemplo n.º 5
0
 void Awake()
 {
     parent         = transform.parent.GetComponent <StructureBase>();
     gameObjectList = new List <GameObject> ();
 }