public void DestroyBodyPart(BodyPartController part) { part.PartDestroy(); bodyPart.Remove(part); if (OnPartDestroy != null) OnPartDestroy.Invoke(); }
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; }