void Update() { // Update available characters, could be done with some death event _targetCharacters = FindObjectOfType <CharacterPositioning>().InstantiatedCharacters; //Choose which skill to use AbilityType chosenAbility; if (Random.value < 0.10) { chosenAbility = AbilityType.Nuke; } else if (Random.value < 0.30) { chosenAbility = AbilityType.Stun; } else { chosenAbility = AbilityType.Poke; } _boss.SetAbility(chosenAbility); if (AbilityCast != null && _boss.CanCastAbility && _targetCharacters.Count > 0) { var targetEnemy = _targetCharacters[(++_iteration) % _targetCharacters.Count]; AbilityCast.Invoke(this, new AbilityCastEventArgs { //Position = Camera.main.ScreenToWorldPoint(Input.mousePosition), TargetEnemy = targetEnemy }); } }
private void CastAbility(AbilityKey key) { AbilityCast?.Invoke(this, key); if (AbilityCastModes[key].HasRecast) { StartRecastTimer(key); } else { StartCooldownTimer(key); } SelectedAbility = AbilityKey.None; }
public bool Cast(ICharacterFinder characterFinder, IAbility ability, Vector2 targetPosition) { if (ActionPoints < ability.ActionPoints) { return(false); } bool didCast = ability.Cast(characterFinder, this, targetPosition); if (didCast) { ActionPoints -= ability.ActionPoints; AbilityCast?.Invoke(this, ability, targetPosition); } return(didCast); }
private void CastAbility(AbilityKey key) { Task.Run(async() => { /*if (AbilityCastModes[key].IsPointAndClick) * { * // check if mana was substracted, right after casting the ability * * lastManaAmount = LeagueOfLegendsModule.CurrentGameState.ActivePlayer.Stats.ResourceValue; * // Debug.WriteLine("A: " + lastManaAmount); * // TODO: Find an alternative method for point and click * await Task.Delay(300); // This is very slow, but if you put less time, the mana change won't be detected. There seems to be about 300ms delay in stats. * // Debug.WriteLine("B: " + LeagueOfLegendsModule.CurrentGameState.ActivePlayer.Stats.ResourceValue); * * if (LeagueOfLegendsModule.CurrentGameState.ActivePlayer.Stats.ResourceValue >= lastManaAmount) * { * // mana wasn't consumed, so no ability was cast. Maybe this trick doesn't always work. E.g. Anivia E while having R enabled? * SelectedAbility = AbilityKey.None; * return; * } * }*/ AbilityCast?.Invoke(this, key); if (AbilityCastModes[key].HasRecast) { StartRecastTimer(key); } else { if (!AbilityCastModes[key].IsPointAndClick) // no cooldown for point and clicks { StartCooldownTimer(key); } } if (AbilityCastModes[key].RecastMode != null && AbilityCastModes[key].RecastMode.RecastOnKeyUp) { SelectedAbility = key; } else { SelectedAbility = AbilityKey.None; } }); }
private void CastAbility(AbilityKey key) { AbilityCast?.Invoke(this, key); if (AbilityCastModes[key].HasRecast) { StartRecastTimer(key); } else { StartCooldownTimer(key); } if (AbilityCastModes[key].RecastMode != null && AbilityCastModes[key].RecastMode.RecastOnKeyUp) { SelectedAbility = key; } else { SelectedAbility = AbilityKey.None; } }