public override void Initialize(GameObject go) { Self = go; Magicable = go.GetComponent <IMagicable>(); _level = 0; StopChannel(); //You can stop a channel, ResetCooldown(); //but stopping a cooldown sounds like pausing; so we Reset it instead }
public static bool TrySpendMagic(this IMagicable magicable, float mana) { if (!magicable.HasMagic(mana)) { return(false); } magicable.SpendMagic(mana); return(true); }
public void ApplyInfusion(GameObject target) { var cols = Physics.OverlapSphere(target.transform.position, _manaStealSearchRadius, (int)LayerMaskHelper.Entity); var gos = Triggers.Trigger.GetGameObjectFromColliders(cols); ITeamable teamable = target.GetComponent <ITeamable>(); IMagicable magicable = target.GetComponent <IMagicable>(); IHealthable healthable = target.GetComponent <IHealthable>(); var totalManaStolen = 0f; foreach (var go in gos) { if (go == target) { continue; } if (_teamable == null || teamable == null || teamable.Team == _teamable.Team) { continue; } var enemyMagicable = go.GetComponent <IMagicable>(); if (enemyMagicable == null) { continue; } var enemyManaPoints = enemyMagicable.ManaPoints; var stolen = Mathf.Min(enemyManaPoints, _manaSteal); enemyMagicable.ModifyMana(-stolen, _self); totalManaStolen += stolen; } magicable.ModifyMana(totalManaStolen, _self); // //If allied, dont deal damage // if(_teamable != null && teamable != null && _teamable.Team == teamable.Team) // return; var damage = new Damage(totalManaStolen, DamageType.Magical, _self); healthable.TakeDamage(damage); }
protected override void Awake() { _magicable = _target.GetComponent <IMagicable>(); base.Awake(); }
public static bool TrySpendMagic(IStatCostAbilityView abilityView, IMagicable magicable) => magicable.TrySpendMagic(abilityView.Cost);
public override void Initialize(GameObject go) { _self = go; _teamable = go.GetComponent <ITeamable>(); _magicable = go.GetComponent <IMagicable>(); }
public override void Initialize(GameObject go) { base.Initialize(go); _movable = Self.GetComponent <IMovable>(); _magicable = Self.GetComponent <IMagicable>(); }
public MagicCost(IMagicable magicable, float cost = default) { _magicable = magicable; Cost = cost; }