コード例 #1
0
ファイル: EnemyBase.cs プロジェクト: jl4312/halloweenJam
        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>();
                }
            }
        }
コード例 #2
0
        private void OnTriggerEnter(Collider other)
        {
            StructureBase structure = other.GetComponent <StructureBase>();

            if (structure != null && structure == parent.closestTarget)
            {
                parent.hasReachedTarget = true;
                parent.newTarget        = false;
            }
        }
コード例 #3
0
        public void LoadTorrentArcStructure()
        {
            GameObject child = GetInactiveChild(torrentArcPool);

            if (child != null)
            {
                structureToPlace          = child.GetComponent <StructureBase>();
                structureToPlace.isActive = false;
                groundManager.TurnOnTiles(structureToPlace.borderList);
            }
        }
コード例 #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);
            }
        }
コード例 #5
0
 void Awake()
 {
     parent         = transform.parent.GetComponent <StructureBase>();
     gameObjectList = new List <GameObject> ();
 }