Пример #1
0
    ///<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();
        }
    }
Пример #2
0
        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
        }
Пример #3
0
 void OnHit(IHealthable healthable)
 {
     if (onHit != null)
     {
         onHit(healthable);                    //event callback on Trigger Enter
     }
 }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        protected void ApplyDamageOverTime(IHealthable target, Damage damage)
        {
            var performingTicks = TicksToPerform;

            for (var i = 0; i < performingTicks; i++)
            {
                target.TakeDamage(damage);
            }
        }
Пример #7
0
 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);
 }
Пример #8
0
        public override void Do()
        {
            base.Do();
            tutorialFingerHud = GameController.instance.uiManager.GetTutorialFinger();
            tutorialFingerHud.ShowAttack();

            doing      = true;
            healthable = objectTohit.GetComponent <IHealthable>();
            healthable.OnHealthChange += OnGetHit;
        }
Пример #9
0
 ///<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;
 }
Пример #10
0
        public void SetHealthable(IHealthable target)
        {
            if (healthable != null)
            {
                healthable.OnHealthChange -= ChangeHeathBarValue;
            }

            healthable = target;
            healthable.OnHealthChange += ChangeHeathBarValue;
            SetHealth(healthable.GetHealth());
        }
Пример #11
0
        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);
            }
        }
Пример #12
0
        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;
        }
Пример #13
0
        private void Apply(GameObject go, IHealthable healthable)
        {
            if (healthable == null)
            {
                throw new Exception();
            }

            if (_proc.Proc(CalculateChance(_healthable, healthable)))
            {
                _nightmareAbility.UnitCast(go);
            }
        }
Пример #14
0
        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;
            }
        }
Пример #15
0
        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);
            }
        }
Пример #16
0
        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);
        }
Пример #18
0
        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);
        }
Пример #19
0
        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;
        }
Пример #20
0
        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;
        }
Пример #21
0
        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);
        }
Пример #22
0
 protected override void Awake()
 {
     _healthable = _target.GetComponent <IHealthable>();
     base.Awake();
 }
Пример #23
0
 public Damageable(Actor actor, IHealthable healthable, IKillable killable, IArmorable armorable = default) : base(actor, killable)
 {
     _healthable = healthable;
     _armorable  = armorable;
 }
Пример #24
0
 public void SetAttackTarget(IHealthable target)
 {
     attackTarget = target;
     state        = BehaviorState.Chasing;
 }
Пример #25
0
 public virtual void MeleeAttack(IHealthable actor)
 {
     throw new NotImplementedException("Implement Melee Attack method!");
 }
Пример #26
0
 private float CalculateChance(IHealthable self, IHealthable target)
 {
     return(self.HealthPercentage * _selfHealthWeight +
            target.HealthPercentage * (1f - _selfHealthWeight));
 }
Пример #27
0
 public Healable(Actor self, IHealthable healthable) : base(self)
 {
     _healthable = healthable;
 }