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