Ejemplo n.º 1
0
        public void Damage(Vector3 pos, AttackData attackData)
        {
            if (isDead == true)
                return;
            DamageMessage msg = attackData.AttackProcessor.ProcessAttack(attackData.AttackDataStat, characterStatController);
            msg.SetDamagePosition(pos);

            if (OnHit != null) OnHit.Invoke(msg);

            shakeSprite.Shake(0.05f, 0.2f);
            if (characterStatController.Hp <= 0)
            {
                //Death(attackData);
                Destroy(this.gameObject);
                return;
            }
            float hpMax = characterStatController.GetHPMax();
            for (int i = 0; i < healthPercentage.Length; i++)
            {
                if ((characterStatController.Hp / hpMax) >= healthPercentage[i])
                {
                    objectAtHealth[i].gameObject.SetActive(true);
                    return;
                }
                else
                {
                    objectAtHealth[i].gameObject.SetActive(false);
                }
            }
        }
Ejemplo n.º 2
0
        public DamageMessage Damage(AttackData attackData, Transform enemyDirection)
        {
            // Calcul de la position de l'impact
            // -> Si la position est supérieur à l'ennemi, ça touche les partis aerienne en prio, sinon random
            directionEnemy = new Vector2(enemyDirection.up.x, enemyDirection.up.z);
            directionPlayer = new Vector2(enemyDirection.position.x - attackData.AttackDataStat.UserPosition.x, enemyDirection.position.z - attackData.AttackDataStat.UserPosition.z);
            attackAngle = Vector2.SignedAngle(directionEnemy, directionPlayer) + 180f;

            // Check parmis les bodyPart lequel correspond
            DamageMessage damageMessage = new DamageMessage();
            bool hitBody = true;
            for (int i = bodyPart.Count-1; i >= 0; i--)
            {
                if(bodyPart[i].CheckHit(attackAngle) == true)
                {
                    // Enlève des points de vies au bodyPart correspondant
                    hitBody = false;
                    damageMessage = bodyPart[i].Damage(attackData);
                    // Check si la partie est détruite et on la vire de la liste
                    if(bodyPart[i].StatController.Hp <= 0)
                    {
                        bodyPart[i].PartDestroy();
                        bodyPart.RemoveAt(i);
                        if(OnPartDestroy != null) OnPartDestroy.Invoke();
                    }
                    break;
                }
            }
            if(hitBody == true) // On a touché aucune partie donc go taper le body
                damageMessage = attackData.AttackProcessor.ProcessAttack(attackData.AttackDataStat, mainBodyStatController);


            return damageMessage;
        }
Ejemplo n.º 3
0
 public void GainExp(DamageMessage damageMessage)
 {
     CharacterEquipementController c = partyManager.GetCharacter().CharacterEquipement;
     int oldLevel = c.CharacterStatController.Level; // pas opti
     if (c.GainWeaponExp(damageMessage.exp) == true)
     {
         LevelUp(c, oldLevel);
     }
 }
        public override DamageMessage ProcessAttack(AttackDataStat attack, CharacterStatController target)
        {
            DamageMessage res;
            float finalDamage = target.GetHPMax() / 4f;
            res = new DamageMessage(attack.AttackType, 0, (int)finalDamage);
            target.Scratch += finalDamage;

            if (ProcessKnockback(attack, target) == true)
                res.knockback = true;
            if (ProcessLaunch(attack, target) == true)
                res.launch = true;
            return res;
        }
Ejemplo n.º 5
0
 public void DrawDamagePopup(DamageMessage damage)
 {
     if (damage.damageRaw > 0 && damage.damageScratch > 0) 
     {
         popupDamageRaw.text = damage.damageRaw.ToString() + "+";
         popupDamageScratch.text = damage.damageScratch.ToString();
         transformDamageRawScratch.gameObject.SetActive(true);
         AddPopup(damage.damagePosition, transformDamageRawScratch, 90f);
         return;
     }
     else if (damage.damageRaw > 0)
         DrawPopup(damage.damagePosition, damage.damageRaw.ToString(), damageType.GetColorType(damage.damageType));
     else if (damage.damageScratch > 0)
         DrawPopup(damage.damagePosition, damage.damageScratch.ToString(), damageType.GetColorType(damage.damageType));
     AddPopup(damage.damagePosition);
 }
Ejemplo n.º 6
0
        public override DamageMessage ProcessAttack(AttackDataStat attack, CharacterStatController target)
        {
            DamageMessage res;
            float variance = attack.Damage * (attack.DamageVariance * 0.01f);
            int rawHeal = (int)(attack.Damage + Random.Range(-variance, variance + 1));

            if (attack.ScratchDamage == true)
            {
                target.Scratch -= rawHeal;
                res = new DamageMessage(attack.AttackType, 0, rawHeal);
            }
            else
            {
                target.Hp += rawHeal;
                res = new DamageMessage(attack.AttackType, rawHeal, 0);
            }
            return res;
        }
Ejemplo n.º 7
0
        public void Damage(Vector3 pos, AttackData attackData)
        {
            if (isDead == true)
                return;
            DamageMessage msg = attackData.AttackProcessor.ProcessAttack(attackData.AttackDataStat, characterStatController);
            msg.SetDamagePosition(pos);

            if (OnHit != null) OnHit.Invoke(msg);

            //shakeSprite.Shake(0.05f, 0.2f);
            if (characterStatController.Hp <= 0 || characterStatController.Scratch == characterStatController.Hp)
            {
                characterStatController.Hp = 0;
                Death();
                //Destroy(this.gameObject);
                return;
            }
        }
        public override DamageMessage ProcessAttack(AttackDataStat attack, CharacterStatController target)
        {
            DamageMessage res;
            float variance = attack.Damage * (attack.DamageVariance * 0.01f);
            int damage = (int)(attack.Damage + Random.Range(-variance, variance + 1));

            if (attack.ScratchDamage == true)
            {
                target.Scratch -= damage;
                res = new DamageMessage(attack.AttackType, 0, damage);
            }
            else
            {
                target.Hp -= damage;
                res = new DamageMessage(attack.AttackType, damage, 0);
            }
            res.knockback = ProcessKnockback(attack, target);
            res.launch = ProcessLaunch(attack, target);
            return res;
        }
Ejemplo n.º 9
0
        public void Damage(Vector3 pos, AttackData attackData)
        {
            if (isDead == true || isInvulnerable == true)
                return;

            /*if (characterAnimation.State == CharacterState.Dash)
            {
                OnInterrupt.Invoke();
            }*/

            DamageMessage msg = characterBodyPartController.Damage(attackData, characterMovement.CharacterDirection.DirectionTransform);
            //DamageMessage msg = attackData.AttackProcessor.ProcessAttack(attackData.AttackDataStat, characterStatController);
            msg.SetDamagePosition(pos);

            if (OnHit != null) OnHit.Invoke(msg);

            if(characterStatController.Hp <= 0)
            {
                Death(attackData);
                return;
            }
            if(msg.damageRaw + msg.damageScratch > 0)
                shakeSprite.Shake(0.05f, 0.2f);

            if(isInterruptable == true)
            {
                if (airborneClip != null)
                    AudioManager.Instance.PlaySound(airborneClip);
                Knockback();
                if(OnInterrupt != null) OnInterrupt.Invoke();
                isInterruptable = false;
            }

            if (isKnockback == false && msg.knockback == true)
                Knockback();
            else if (isKnockback == true)
                Knockback();

            if (isKnockback == true && msg.launch == true)
                CheckLaunch(attackData);
        }
Ejemplo n.º 10
0
        public override DamageMessage ProcessAttack(AttackDataStat attack, CharacterStatController target)
        {
            DamageMessage res;
            int finalDamage = 0;
            float variance = attack.Damage * (attack.DamageVariance * 0.01f);
            int rawDamage = (int) (attack.Damage + Random.Range(-variance, variance+1));
            rawDamage = (int)(rawDamage * target.GetStat(statDefense));

            if (attack.ScratchDamage == true)
            {
                finalDamage = rawDamage;
                res = new DamageMessage(attack.AttackType, 0, finalDamage);
                // Exp
                if (target.Scratch + finalDamage > target.Hp)
                    res.exp = (int)(target.Hp - target.Scratch);
                else
                    res.exp = finalDamage;
                // Exp
                target.Scratch += finalDamage;
            }
            else
            {
                finalDamage = rawDamage + (int)target.Scratch;
                res = new DamageMessage(attack.AttackType, rawDamage, (int)target.Scratch);
                // Exp
                if (target.Hp - finalDamage < 0)
                    res.exp = (int)target.Hp;
                else
                    res.exp = finalDamage;
                // Exp
                target.Hp -= finalDamage;
                target.Scratch = 0;
            }
            if (ProcessKnockback(attack, target) == true)
                res.knockback = true;
            if (ProcessLaunch(attack, target) == true)
                res.launch = true;
            return res;
        }
Ejemplo n.º 11
0
 public virtual DamageMessage ProcessAttack(AttackDataStat attack, CharacterStatController target)
 {
     DamageMessage res = new DamageMessage();
     return res;
 }