Esempio n. 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));
        }
Esempio n. 2
0
        //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.");
        }
Esempio n. 3
0
        //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");
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 public static void EndMoveMode()
 {
     mode       = Mode.NONE;
     activeTeam = null;
 }
Esempio n. 6
0
 public static void MoveMode(BuildTeam team)
 {
     mode       = Mode.MOVE;
     activeTeam = team;
 }
Esempio n. 7
0
 public static void EndDestructionMode()
 {
     mode       = Mode.NONE;
     activeTeam = null;
 }
Esempio n. 8
0
 public static void DestructionMode(BuildTeam team)
 {
     mode       = Mode.DESTROY;
     activeTeam = team;
 }
Esempio n. 9
0
 public static void EndMoveMode()
 {
     moveMode   = false;
     activeTeam = null;
 }
Esempio n. 10
0
 public static void StartMoveMode(BuildTeam team)
 {
     moveMode   = true;
     activeTeam = team;
 }
Esempio n. 11
0
 public static void EndBuildMode()
 {
     buildMode  = false;
     activeTeam = null;
 }
Esempio n. 12
0
 public static void StartBuildMode(BuildTeam team)
 {
     buildMode  = true;
     activeTeam = team;
 }