Basic Dodging Enemy Creation #12

Merged
MaximilienBB merged 5 commits from feature/DodgingEnemy into main 2025-07-27 20:30:08 +00:00
8 changed files with 1454 additions and 5 deletions

View File

@ -103,6 +103,8 @@ MonoBehaviour:
_speed: 0.15
_attack_damage: 1
_attack_interval: 2
_enemy: {fileID: 0}
OpponentTraits: 00000000
--- !u!114 &5416582167583119277
MonoBehaviour:
m_ObjectHideFlags: 0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 07ebda7671039dc4b9a1d1b4eabb5aa9
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -56,7 +56,13 @@ public class Detection : MonoBehaviour
Entity otherEntity = other.gameObject.GetComponent<Entity>();
if (otherEntity == _entityLinked)
{
_entityLinked.Hit(_projectileDamage);
GhostOpponent isGhost = EntityLinked.gameObject.GetComponent<GhostOpponent>();
if (isGhost != null)
{
if(!isGhost.dodgedProjectile()) _entityLinked.Hit(_projectileDamage);
}
else _entityLinked.Hit(_projectileDamage);
// Kill if no hp
if (otherEntity.Hp <= 0)
{

View File

@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditorInternal;
using UnityEngine;
[CreateAssetMenu(menuName = project_name + "/Global Config")]

View File

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GhostOpponent : Opponent
{
[SerializeField]
//Le taux de chance, en pourcantage (un chiffre entre 0 et 99) que l'ennemie a d'eviter un projectile.
private int dodgePercent;
public bool dodgedProjectile()
{
System.Random random = new System.Random();
if(random.Next(0, 99) > dodgePercent) return false;
else return true;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9accc3bbf43ac664d99f80d0f5302897
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditorInternal;
using UnityEngine;
public class Opponent : Entity
@ -42,10 +43,6 @@ public class Opponent : Entity
Move();
}
}
void AttackEnemy()