示例#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));
        }
示例#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.");
        }