void Start() { state = TargetingState.None; textui = GameObject.Find("Text").GetComponent <Text>(); transform.GetChild(0).gameObject.SetActive(false); ImageTracker.TargetLoad += ImageTracker_TargetLoad; ImageTracker.TargetUnload += ImageTracker_TargetUnload; }
void HotKeys() { // Cancelling skill targeting. if (Input.GetMouseButtonDown(1)) { CancelSkill(); } // Selecting a skill with the number keys. for (int i = 0; i < m_AbilityHotkeys.Length; i++) { if (Input.GetKeyDown(m_AbilityHotkeys[i])) { // Make sure the player can use the skill before selecting it. if (m_SelectedUnit.GetSkill(i).GetCurrentCooldown() == 0 && m_SelectedUnit.GetActionPoints() >= m_SelectedUnit.GetSkill(i).m_Cost) { SkillSelection(i); break; } } } // Show health bars of player units and active enemies. if (Input.GetKey(KeyCode.Tab)) { foreach (Unit u in UnitsManager.m_Instance.m_PlayerUnits) { u.GetHealthBar().Reset(); } foreach (Unit u in UnitsManager.m_Instance.m_ActiveEnemyUnits) { u.GetHealthBar().Reset(); } } if (Input.GetKeyDown(KeyCode.Space)) { // If the turn ended, forget things for the next turn. if (BattleManager.m_Instance.TryEndTurn()) { m_TargetingState = TargetingState.Move; // Remove all the highlights if (m_SelectedUnit) { foreach (Node n in m_SelectedUnit.m_MovableNodes) { n.m_NodeHighlight.ChangeHighlight(TileState.None); } } foreach (Node n in m_maxSkillRange) { n.m_NodeHighlight.ChangeHighlight(TileState.None); } m_SelectedUnit = null; } } }
public TowerTargeting(Tower tower, CreepsManager creepsManager) { _tower = tower; _creepsManager = creepsManager; Target = null; _targetingState = TargetingState.NeedNewTarget; }
public void StartTarget(TargetingState tempState, int tempDistance, GameObject objectControl) { TargetState = tempState; Distance = tempDistance; ObjectControl = objectControl; Player.GetComponent <InputAction>().enabled = false; MessageWindow.GetComponent <MessageWindow>().AddText("Please select a target."); TargetReady = true; }
/// <summary> /// Select a skill. /// </summary> /// <param name="skill"> The skill being selected. </param> public void SkillSelection(BaseSkill skill, SkillButton button) { if (ParticlesManager.m_Instance.m_ActiveSkill != null) // || (ParticlesManager.m_Instance.m_ActiveSkill.m_Skill != null && ParticlesManager.m_Instance.m_ActiveSkill.m_Targets != null)) { Debug.LogWarning($"<color=#9c4141>[Skill]</color> {ParticlesManager.m_Instance.m_ActiveSkill.m_Skill.m_SkillName} is currently active!"); return; } // Don't allow progress if the character is an enemy (player can mouse over for info, but not use the skill) if (m_SelectedUnit.GetAllegiance() == Allegiance.Enemy) { return; } // Make sure the player has a unit selected. if (m_SelectedUnit != null) { // Check if the skill being cast is the heal skill. HealSkill hs = skill as HealSkill; if (hs != null) { // Check if this unit has Pestilence's passive (should be Pestilence but you never know). PestilencePassive pesPassive = m_SelectedUnit.GetPassiveSkill() as PestilencePassive; if (pesPassive != null) { // If there is no heal resource remaining, output warning about it and leave function. if (pesPassive.GetHealResource() < pesPassive.m_HealResourceCastCost) { Debug.LogWarning("Not enough heal resource for Pestilence to heal with."); return; } } } // Make sure the unit can afford to cast the skill and the skill isn't on cooldown before selecting it. // Just in case. if (m_SelectedUnit.GetActionPoints() >= skill.m_Cost && skill.GetCurrentCooldown() == 0) { foreach (SkillButton b in UIManager.m_Instance.m_SkillSlots) { b.m_LightningImage.materialForRendering.SetFloat("_UIVerticalPan", 0); } button.m_LightningImage.materialForRendering.SetFloat("_UIVerticalPan", 1); // Update the GameManager's fields m_SelectedSkill = skill; m_TargetingState = TargetingState.Skill; // Get the new affectable area. m_maxSkillRange = Grid.m_Instance.GetNodesWithinRadius(m_SelectedSkill.m_CastableDistance + m_SelectedSkill.m_AffectedRange, Grid.m_Instance.GetNode(m_SelectedUnit.transform.position), true); UpdateSkillPreview(null); } } }
private void SetState() { if (RobotObject.transform.position == FirstLocation.transform.position) { state = TargetingState.First; } else if (RobotObject.transform.position == SecondLocation.transform.position) { state = TargetingState.Second; } else if (RobotObject.transform.position == ThirdLocation.transform.position) { state = TargetingState.Three; } }
void FindNewTarget() { float shortestDistance = Mathf.Infinity; Creep nearestEnemy = null; foreach (Creep creep in _creepsManager.CreepsAlive) { float distanceToEnemy = Vector3.Distance(_tower.transform.position, creep.transform.position); if (distanceToEnemy < shortestDistance) { shortestDistance = distanceToEnemy; nearestEnemy = creep; } } if (nearestEnemy != null && shortestDistance <= _tower.TowerParameters.Range) { Target = nearestEnemy.transform; _targetingState = TargetingState.TargetDefined; } }
void CancelSkill() { if (m_TargetingState == TargetingState.Skill) { foreach (SkillButton button in UIManager.m_Instance.m_SkillSlots) { button.m_LightningImage.materialForRendering.SetFloat("_UIVerticalPan", 0); } m_TargetingState = TargetingState.Move; UpdateMoveablePreview(null); m_SelectedSkill = null; foreach (Unit unaffectedUnit in m_AffectedUnits) // No longer affected units { unaffectedUnit.m_Healthbar.m_KeepFocus = false; unaffectedUnit.m_Healthbar.ChangeFill((float)unaffectedUnit.GetCurrentHealth() / unaffectedUnit.GetStartingHealth(), HealthbarContainer.Heathbars.Both); } } }
void TargetNoLongerAvailable() { Target = null; _targetingState = TargetingState.NeedNewTarget; _tower.TargetIsUnavailable(); }
/// <summary> /// Initialize reticle and targeting state to default /// </summary> private void Reinitialize () { if (Controller.playerTurn) { MoveablePlayerUnits = new UnitsCollection(Controller.PlayerUnits.Living()); Currently = TargetingState.Selecting; } }
/// <summary> /// Called on target acquired /// </summary> private void TargetAcquired () { Target = Reticle.SelectedUnit; EventSystem.Trigger<TargetAcquired, Unit, Unit>(Targeter, Target); MoveablePlayerUnits.Remove(Targeter); if (MoveablePlayerUnits.Count == 0) { EventSystem.Trigger<TurnOver>(); } else { Currently = TargetingState.Selecting; } }
/// <summary> /// Called when targeter selected /// </summary> private void TargeterSelected () { Targeter = Reticle.SelectedUnit; Currently = TargetingState.Targeting; }