public override void Activate() { myProperties.myStatus = GoalProps.goalStatus.ACTIVE; //If we can't guard //Assign a Random tower to the enemy //it doesn't matter if it is already guarded, //we want him to figure that out himself when he is towerArrival distance away from that tower. if (canGuard == false) { tower = this.myProperties.myOwner.myGameInstance.GetRandomTower(); this.myProperties.myOwner.MyTarget = tower.gameObject; this.AddSubGoal(this.GetComponent<Goal_Defend>()); } else //we have a place to guard { if (!isGuarding) { if (HasGoal(this.GetComponent<Goal_Defend>())) { // this.ActivateSubGoal(this.GetComponent<Goal_Defend>()); // print("we got it"); // if(this.GetComponent<Goal_Defend>().ClearSubG) } this.AddSubGoal(this.GetComponent<Goal_Defend>()); isGuarding = true; } } }
IEnumerator CloseTowerUI() { float elapsedTime = 0f; float t; Vector3 startScale = towerUI.localScale; while (elapsedTime < towerGrowTime) { if (PauseManager.instance.CheckPauseOff(myGameInstance.instanceIndex)) { elapsedTime += Time.deltaTime; t = elapsedTime / towerGrowTime; towerUI.localScale = Vector3.Lerp(startScale, Vector3.zero, t); } yield return null; } towerUI.localScale = Vector3.zero; currentTower = null; }
/// <summary> /// initiates the tower UI for activating a charged tower /// </summary> public void StartTowerUI(float towerTimer, BuildingTower newTower) { // TODO need to close old targeting jawn before resetting? maybe? if (currentTower != null) { currentTower.Deactivate(false); } currentTower = newTower; towerActivateRoutine = OpenTowerUI(towerTimer); StartCoroutine(towerActivateRoutine); }
public void Init(BuildingTower tower) { myTower = tower; }
/// <summary> /// StartTargeting overload that takes a specific sprite for the reticle image /// </summary> public void StartTargeting(int playerIndex, BuildingTower tower, Sprite newReticleSprite, float targetingTime) { if (newReticleSprite != null) { reticleTops[playerIndex].sprite = newReticleSprite; reticleBottoms[playerIndex].sprite = newReticleSprite; } StartTargeting(playerIndex, tower, targetingTime); }
/// <summary> /// starts the targetting system /// </summary> /// <param name="playerIndex"> the index of the player using the targeting system </param> public void StartTargeting(int playerIndex, BuildingTower tower, float targetingTime) { // get tower currentTowers[playerIndex] = tower; // pause that instance PauseManager.instance.InstancePauseOn(playerIndex); PauseManager.instance.towerPause[playerIndex] = true; // position and turn on reticle TurnOnReticle(playerIndex); // turn on system SubscribeReticleToMove(playerIndex); // force a button up before they can interact canInteract[playerIndex] = false; SubscribeWaitForUp(playerIndex); activeTargeting[playerIndex] = true; targetingRoutines[playerIndex] = TargetingTimerRoutine(playerIndex, targetingTime); StartCoroutine(targetingRoutines[playerIndex]); }