public void SetAbilityUiCoolDown(WeaponClass.AbilityIndex index, float amount) { if (TryGetAbility(index, out AbilityUi ui)) { ui.SetCoolDown(amount); } }
public void SetAbilityUiComboIndex(WeaponClass.AbilityIndex index, int comboIndex) { if (TryGetAbility(index, out AbilityUi ui)) { ui.SetAbility(comboIndex); } }
private void ResetCooldown(WeaponClass.AbilityIndex index) { combo = 0; comboCoolDown = 0; currentAbilityIndex = WeaponClass.AbilityIndex.None; isComboActive = false; _uiManager.HudElements.SetAbilityUiComboIndex(index, 0); }
public void SetUp(PlayerCombat combatController, WeaponClass.AbilityIndex abilityIndex, AbilityBase[] abilities) { playerCombat = combatController; index = abilityIndex; this.abilities = abilities; SetAbility(0); }
public void ExecuteAbility(WeaponClass.AbilityIndex index) { if (actionCoolDown > Time.time) { return; } StartCoroutine(Attack(index)); }
public bool TryGetAbility(WeaponClass.AbilityIndex index, out AbilityUi abilityUi) { abilityUi = index switch { WeaponClass.AbilityIndex.Abilities1 => abilityUi1, WeaponClass.AbilityIndex.Abilities2 => abilityUi2, WeaponClass.AbilityIndex.Abilities3 => abilityUi3, _ => throw new ArgumentOutOfRangeException(nameof(index), index, null) }; return(abilityUi != null); }
private IEnumerator Attack(WeaponClass.AbilityIndex index) { if (currentAbilityIndex != index) { // NotificationSystem.Instance.Log("Ability Change. Resetting."); ResetAllCooldown(); currentAbilityIndex = index; } if (abilities[(int)index].Length <= 0) { yield return(null); } if (combo >= abilities[(int)index].Length) { // NotificationSystem.Instance.Error("Combo out of bounds, resetting to safer state"); ResetAllCooldown(); } AbilityBase ability = abilities[(int)index][combo]; if (ability == null) { yield return(null); } _uiManager.HudElements.SetAbilityUiCoolDown(index, ability.CoolDown); actionCoolDown = Time.time + ability.CoolDown; yield return(animator.PlayAttackAnimation(ability.AttackAnimationName)); yield return(new WaitForSeconds(animator.GetAnimationLength)); if (ability.IsProjectile) { if (ability.ProjectilePreFab == null) { yield return(null); } GameObject projectileObj = Instantiate(ability.ProjectilePreFab, CombatUtils.GetAttackDirection(ability, transform, playerEntity.Stats.GetCenterPos, animator.CurrentDirection), quaternion.identity); if (!projectileObj.TryGetComponent(out ProjectileEntity projectile)) { yield return(null); } projectile.Direction = animator.CurrentDirection; projectile.Caster = playerEntity; yield return(null); } // todo: allow for weapons to affect damage calculations. if (!ability.Execute(playerEntity, CombatUtils.GetHitList(ability, transform, playerEntity.Stats.GetCenterPos, animator.CurrentDirection))) { yield return(null); } combo++; if (combo >= abilities[(int)index].Length) { ResetCooldown(index); } comboCoolDown = Time.time + 5f; isComboActive = true; _uiManager.HudElements.SetAbilityUiComboIndex(index, combo); }