Example #1
0
        public void OnMouseUp()
        {
            if (moveMode && TowerConstructionHandler.selectedMoveTower != null)
            {
                StartCoroutine(TowerConstructionHandler.selectedMoveTower.MoveTower(activeTeam, this));
                return;
            }
            if (!buildMode)
            {
                return;
            }
            if (towerExists || !this.buildable || EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }
            BuildTeam team = activeTeam;
            //maybe not pass this, but pass the construction site. that really makes more sense.

            //TODO this should do something else to handle the construction site.
            TowerConstructionHandler tower = Instantiate(towers.RandomPrefab(), this.gameObject.transform.parent).GetComponent <TowerConstructionHandler>();

            team.BeginConstruction(tower);

            StartCoroutine(tower.ConstructTower(team, this));
        }
        //TODO: Fix the thing where towers have to be destroied after the new ne is active.
        public IEnumerator MoveTower(BuildTeam team, TowerBuildSite newSite)
        {
            team.busy = true;
            //save refrence to tower
            //destroy tower
            StartCoroutine(DestroyTower(null));

            //call construction on new site
            TowerConstructionHandler newTower = Instantiate(thisTowerPrefab, newSite.gameObject.transform).GetComponent <TowerConstructionHandler>();

            team.BeginConstruction(newTower);
            StartCoroutine(newTower.ConstructTower(team, newSite));
            yield return(new WaitForSeconds(0));

            Debug.Log("Tower Move in progress.");
        }
        //Building Script
        public IEnumerator ConstructTower(BuildTeam team, TowerBuildSite location)
        {
            Debug.Log("Tower Construction in Progress...");
            team.busy = true;
            myTile    = location; //for use with deconstruction
            location.BuildTower();

            //disable targeting
            //TODO: run construction animation
            GetComponent <TargetAcquisition>().enabled = false;

            //Wait for it to end
            yield return(new WaitForSeconds(activationTime));

            //Reenable the build team and activate targeting.
            team.EndJob();
            GetComponent <TargetAcquisition>().enabled = true;
            Debug.Log("Tower built... Targeting active");
        }
        public IEnumerator DestroyTower(BuildTeam team)
        {
            if (team != null)
            {
                team.busy = true;
            }
            //disable targeting
            GetComponent <TargetAcquisition>().enabled = false;
            //run animation
            yield return(new WaitForSeconds(destroyTime));

            //clear this buildSite
            myTile.RemoveTower();
            //destroy model
            if (team != null)
            {
                team.EndJob();
            }
            Debug.Log("Tower Destroyed");
            Destroy(this.gameObject);
        }
 public static void EndMoveMode()
 {
     mode       = Mode.NONE;
     activeTeam = null;
 }
 public static void MoveMode(BuildTeam team)
 {
     mode       = Mode.MOVE;
     activeTeam = team;
 }
 public static void EndDestructionMode()
 {
     mode       = Mode.NONE;
     activeTeam = null;
 }
 public static void DestructionMode(BuildTeam team)
 {
     mode       = Mode.DESTROY;
     activeTeam = team;
 }
Example #9
0
 public static void EndMoveMode()
 {
     moveMode   = false;
     activeTeam = null;
 }
Example #10
0
 public static void StartMoveMode(BuildTeam team)
 {
     moveMode   = true;
     activeTeam = team;
 }
Example #11
0
 public static void EndBuildMode()
 {
     buildMode  = false;
     activeTeam = null;
 }
Example #12
0
 public static void StartBuildMode(BuildTeam team)
 {
     buildMode  = true;
     activeTeam = team;
 }