Example #1
0
        /// <summary>
        /// Will damage (change negatively health) of the amount of damage stored in the attackData. If the damage are
        /// negative, this heal instead.
        ///
        /// This will also notify the DamageUI so a damage number is displayed.
        /// </summary>
        /// <param name="attackData"></param>
        public void Damage(Weapon.AttackData attackData)
        {
            int totalDamage = attackData.GetFullDamage();

            ChangeHealth(-totalDamage);
            DamageUI.Instance.NewDamage(totalDamage, m_Owner.transform.position);
        }
Example #2
0
 private void OnTriggerEnter(Collider coll)
 {
     Debug.Log(coll.tag);
     if (coll.tag.Equals("Enemy"))
     {
         CreatorKitCode.CharacterData     target = coll.GetComponent <CreatorKitCode.CharacterData>();
         CreatorKitCode.Weapon.AttackData daño   = new CreatorKitCode.Weapon.AttackData(target);
         daño.AddDamage(CreatorKitCode.StatSystem.DamageType.Electric, 2);
         target.Damage(daño);
         Destroy(gameObject);
     }
 }
Example #3
0
        /// <summary>
        /// Damage the Character by the AttackData given as parameter. See the documentation for that class for how to
        /// add damage to that attackData. (this will be done automatically by weapons, but you may need to fill it
        /// manually when writing special elemental effect)
        /// </summary>
        /// <param name="attackData"></param>
        public void Damage(Weapon.AttackData attackData)
        {
            if (HitClip.Length != 0)
            {
                SFXManager.PlaySound(SFXManager.Use.Player, new SFXManager.PlayData()
                {
                    Clip     = HitClip[Random.Range(0, HitClip.Length)],
                    PitchMax = 1.1f,
                    PitchMin = 0.8f,
                    Position = transform.position
                });
            }

            Stats.Damage(attackData);

            OnDamage?.Invoke();
        }
Example #4
0
        public override void Update(StatSystem statSystem)
        {
            base.Update(statSystem);

            m_SinceLastDamage += Time.deltaTime;

            if (m_SinceLastDamage > m_DamageSpeed)
            {
                m_SinceLastDamage = 0;

                Weapon.AttackData data = new Weapon.AttackData(m_Target);

                data.AddDamage(m_DamageType, m_Damage);

                statSystem.Damage(data);
            }

            //we do not parent as if the original object is destroy it would destroy the instance
            m_FireInstance.Effect.transform.position = m_Target.transform.position + Vector3.up;
        }