///<description>use IHealthable information to inflict damage</description> public void OnActorHit(IHealthable collidable) { if (collidable == null) { return; } healthModel.currentHealth -= collidable.inflictingDamageAmount; if (healthModel.currentHealth < 0) { healthModel.currentHealth = 0; } if (onHealthChange != null) { onHealthChange(healthModel.currentHealth, healthModel.maxHealth); } if (healthView != null) { healthView.SetHealthBarFillAmount(healthModel.currentHealth / healthModel.maxHealth); } if (healthModel.currentHealth <= 0) { OnDeath(); } }
public void ApplyMagicalShield(GameObject target) { var cols = Physics.OverlapSphere(target.transform.position, _damageRadius, (int)LayerMaskHelper.Entity); var gos = Triggers.Trigger.GetGameObjectFromColliders(cols); var targetCount = 0; foreach (var go in gos) { if (go == target) { continue; } // if(_teamable == null || teamable == null || teamable.Team == _teamable.Team) // continue; ITeamable teamable = target.GetComponent <ITeamable>(); IHealthable healthable = target.GetComponent <IHealthable>(); if (healthable == null) { continue; } targetCount++; var damage = new Damage(_damage, DamageType.Magical, _self); healthable.TakeDamage(damage); } //TODO apply damage block //Dont have any way to damage block outside of buffs }
void OnHit(IHealthable healthable) { if (onHit != null) { onHit(healthable); //event callback on Trigger Enter } }
public List <IHealthable> GetListHealthableInViewRadius() { List <IHealthable> healthableInViewRadius = new List <IHealthable>(); //Try get more that orig radius float oldView = vision.viewAngle; vision.viewAngle = 360f; vision.viewRadius *= 2f; List <Collider> objects = vision.FindVisibleColliders(); vision.viewAngle = oldView; vision.viewRadius /= 2f; for (int i = 0; i < objects.Count; i++) { IHealthable healthableObject = objects[i].GetComponent <IHealthable>(); if (healthableObject != null) { healthableInViewRadius.Add(healthableObject); } } return(healthableInViewRadius); }
public override void MeleeAttack() { if (dashing) { return; } float oldView = vision.viewAngle; vision.viewAngle = 360f; vision.viewRadius *= 2f; List <Collider> objects = vision.FindVisibleColliders(); vision.viewAngle = oldView; vision.viewRadius /= 2f; List <IHealthable> attack = new List <IHealthable>(); for (int i = 0; i < objects.Count; i++) { IHealthable healthableObject = objects[i].GetComponent <IHealthable>(); if (healthableObject != null) { attack.Add(healthableObject); } } combat.MeleeAttack(attack); }
protected void ApplyDamageOverTime(IHealthable target, Damage damage) { var performingTicks = TicksToPerform; for (var i = 0; i < performingTicks; i++) { target.TakeDamage(damage); } }
public NightmareInstance(Nightmare nightmare, GameObject self, GameObject target) : base(nightmare.TickInfo.TicksRequired, nightmare.TickInfo.Duration) { _self = self; _damage = nightmare.TotalDamage / nightmare.TickInfo.Duration; _target = target; _healthable = target.GetComponent <IHealthable>(); _fx = Instantiate(nightmare._nightmareFX, _target.transform); }
public override void Do() { base.Do(); tutorialFingerHud = GameController.instance.uiManager.GetTutorialFinger(); tutorialFingerHud.ShowAttack(); doing = true; healthable = objectTohit.GetComponent <IHealthable>(); healthable.OnHealthChange += OnGetHit; }
///<description>Setting Health and IHealthable params and callbacks for DeathEvent</description> public void InitParams(IHealthable actor, float maxHealth, System.Action OnDeathCallback) { this.actor = actor; this.maxHealth = maxHealth; this.currentHealth = maxHealth; this.actor.onHit += healthController.OnActorHit; healthController.InitParams(this); healthController.onDeath += OnDeathCallback; healthController.onDeath += OnDeath; }
public void SetHealthable(IHealthable target) { if (healthable != null) { healthable.OnHealthChange -= ChangeHeathBarValue; } healthable = target; healthable.OnHealthChange += ChangeHeathBarValue; SetHealth(healthable.GetHealth()); }
public override void MeleeAttack(IHealthable target) { if (combat.InMeleeRange(target.GetTransform())) { movement.FaceTarget(target.GetTransform().position); List <IHealthable> attackList = new List <IHealthable>(); attackList.Add(target); combat.MeleeAttack(attackList); } }
public override void Initialize(GameObject go) { base.Initialize(go); Level = 1;//This ability is 'innate' and starts off being leveled _nightmareAbility = go.GetComponent <IAbilitiable>().GetAbility <Nightmare>(); _attackable = go.GetComponent <IAttackable>(); _teamable = go.GetComponent <ITeamable>(); _healthable = go.GetComponent <IHealthable>(); _proc = new DynamicProc(0f); _attackable.IncomingAttackLanded += IncomingAttackLanded; }
private void Apply(GameObject go, IHealthable healthable) { if (healthable == null) { throw new Exception(); } if (_proc.Proc(CalculateChance(_healthable, healthable))) { _nightmareAbility.UnitCast(go); } }
public void Init() { worldUiCanvas = GameController.instance.sceneController.worldUiCanvas; stats = GetComponent <IHealthable>(); stats.OnHealthChange += ShowHealChange; stats.OnHealthChange += ShowDamageText; target = transform; Transform targetRend = GetComponentInChildren <Transform>(); if (targetRend != null) { target = targetRend.transform; } }
private void ManaModifiedCallback(ManaModifiedEventArgs args) { var amountSpent = Mathf.Max(0f, -args.Modified); var source = args.Source; var target = args.Owner; IHealthable healthable = (target != null) ? target.GetComponent <IHealthable>() : null; var backlashAmount = amountSpent * _backlashPercentage; if (healthable != null && source == target && backlashAmount > 0) { var damage = new Damage(backlashAmount, DamageType.Magical, _self); healthable.TakeDamage(damage); } }
public void Init() { stats = GetComponent <IHealthable>(); stats.OnHealthChange += ShowHealChange; target = transform; // TODO: WTF Transform targetRend = GetComponentInChildren <Transform>(); if (targetRend != null) { target = targetRend.transform; } }
public override void Do() { base.Do(); healthable = target.GetComponent <IHealthable>(); if (healthable == null) { Debug.LogWarning($"{name} action havent healthable target, skipping"); } doing = true; input.behavior.SetAttackTarget(healthable); }
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); }
public override void Init() { type = WorldUiType.Healthbars; base.Init(); stats = GetComponent <IHealthable>(); healthImage = curElement.transform.GetChild(0).GetComponent <Image>(); healthText = curElement.GetComponentInChildren <Text>(); levelGameObject = curElement.transform.GetChild(3).gameObject; if (stats.IsHasLevel()) { levelGameObject.SetActive(true); Text levelText = levelGameObject.GetComponentInChildren <Text>(); levelText.text = stats.GetLevel().ToString(); } stats.OnHealthChange += SetHealth; }
public void Init(Combat combat) { equipmentManager = PlayerManager.Instance().equipmentManager; player = PlayerManager.Instance().GetPlayer(); stats = GetComponent <IHealthable>(); this.combat = combat; RegisterEvents(); target = transform; Transform targetRend = GetComponentInChildren <Transform>(); if (targetRend != null) { target = targetRend.transform; } SpawnArrowPath(); inited = true; }
private void OnHealthableHit(GameObject hitted) { Actor targetActor = hitted.GetComponentInParent <Actor>(); if (targetActor != null && targetActor.IsFriend(damage.GetOwner())) { return; } Stop(); IHealthable healthable = hitted.GetComponentInParent <IHealthable>(); if (healthable == null) { return; } healthable.TakeDamage(damage); Destroy(gameObject); }
protected override void Awake() { _healthable = _target.GetComponent <IHealthable>(); base.Awake(); }
public Damageable(Actor actor, IHealthable healthable, IKillable killable, IArmorable armorable = default) : base(actor, killable) { _healthable = healthable; _armorable = armorable; }
public void SetAttackTarget(IHealthable target) { attackTarget = target; state = BehaviorState.Chasing; }
public virtual void MeleeAttack(IHealthable actor) { throw new NotImplementedException("Implement Melee Attack method!"); }
private float CalculateChance(IHealthable self, IHealthable target) { return(self.HealthPercentage * _selfHealthWeight + target.HealthPercentage * (1f - _selfHealthWeight)); }
public Healable(Actor self, IHealthable healthable) : base(self) { _healthable = healthable; }