Example #1
0
        public static void PreBuildTower(UnitTower tower)
        {
            PlatformTD platform = null;
            LayerMask  mask     = 1 << LayerManager.LayerPlatform();

            Collider[] cols = Physics.OverlapSphere(tower.thisT.position, _gridSize, mask);
            if (cols.Length > 0)
            {
                platform = cols[0].gameObject.GetComponent <PlatformTD>();
            }


            if (platform != null)
            {
                Vector3 buildPos = GetTilePos(platform.thisT, tower.thisT.position);
                tower.thisT.position = buildPos;
                tower.thisT.rotation = platform.thisT.rotation;
                platform.BuildTower(buildPos, tower);
            }
            else
            {
                Debug.Log("no platform found for pre-placed tower");
            }

            tower.InitTower(instance.towerCount += 1);
        }