KerelOlivier
3 years ago
23 changed files with 374 additions and 5 deletions
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 70818c4860429eaa189725cc9bb46cfc |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
using System; |
||||
using Enemies.States; |
||||
|
||||
namespace Enemies |
||||
{ |
||||
public class BaseEnemy :Enemy |
||||
{ |
||||
private void Awake() |
||||
{ |
||||
state = new IdleState(this); |
||||
} |
||||
|
||||
private void Update() |
||||
{ |
||||
HandleStates(); |
||||
state.Execute(); |
||||
} |
||||
|
||||
private void HandleStates() |
||||
{ |
||||
if (health <= 0) |
||||
{ |
||||
state = new DieState(this); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 637e76a880a1496a9bd4bb5256bc41a2 |
||||
timeCreated: 1648903519 |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
using Enemies.States; |
||||
using UnityEngine; |
||||
|
||||
namespace Enemies |
||||
{ |
||||
public class Enemy : MonoBehaviour |
||||
{ |
||||
public float health = 10f; |
||||
public float attackPower = 1; |
||||
|
||||
public GameObject target { get; set; } |
||||
private float speed = 2f; |
||||
|
||||
public IState state { get; set; } |
||||
|
||||
|
||||
// Start is called before the first frame update |
||||
void Start() |
||||
{ |
||||
Destroy(gameObject, 10f); |
||||
|
||||
} |
||||
|
||||
// Update is called once per frame |
||||
void Update() |
||||
{ |
||||
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 24e36874f702ad7eeb7b31559803fa68 |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: ff96e8a80d18490aa2d832b89efc879b |
||||
timeCreated: 1648900365 |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
using Enemies.States; |
||||
|
||||
namespace Enemies |
||||
{ |
||||
public class AttackState: IState |
||||
{ |
||||
private Enemy context; |
||||
public AttackState(Enemy context) |
||||
{ |
||||
this.context = context; |
||||
} |
||||
public void Enter() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
|
||||
public void Execute() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
|
||||
public void Exit() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: b599a154939544318719e918c1119e69 |
||||
timeCreated: 1648900308 |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
using UnityEngine; |
||||
namespace Enemies.States |
||||
{ |
||||
public class DieState:IState |
||||
{ |
||||
private Enemy context; |
||||
public DieState(Enemy context) |
||||
{ |
||||
this.context = context; |
||||
} |
||||
public void Enter() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
|
||||
public void Execute() |
||||
{ |
||||
Object.Destroy(context.gameObject); |
||||
} |
||||
|
||||
public void Exit() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 12afa5570dd440a089cd2e73d7657ff6 |
||||
timeCreated: 1648905635 |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
using Enemies.States; |
||||
|
||||
namespace Enemies |
||||
{ |
||||
public class FollowState: IState |
||||
{ |
||||
private Enemy context; |
||||
public FollowState(Enemy context) |
||||
{ |
||||
this.context = context; |
||||
} |
||||
public void Enter() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
|
||||
public void Execute() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
|
||||
public void Exit() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: bf69b9658d394c9c865d69a41522240a |
||||
timeCreated: 1648903253 |
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
namespace Enemies.States |
||||
{ |
||||
public interface IState |
||||
{ |
||||
public void Enter(); |
||||
public void Execute(); |
||||
public void Exit(); |
||||
} |
||||
} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 5015856b4dd585466a0d6d0a0e3d1661 |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
using Enemies.States; |
||||
|
||||
namespace Enemies |
||||
{ |
||||
public class IdleState: IState |
||||
{ |
||||
private Enemy context; |
||||
public IdleState(Enemy context) |
||||
{ |
||||
this.context = context; |
||||
} |
||||
|
||||
public void Enter() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
|
||||
public void Execute() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
|
||||
public void Exit() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 26eeda0ae91e421f94c4453960894cea |
||||
timeCreated: 1648900414 |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
using Enemies.States; |
||||
|
||||
namespace Enemies |
||||
{ |
||||
public class PathState: IState |
||||
{ |
||||
private Enemy context; |
||||
public PathState(Enemy context) |
||||
{ |
||||
this.context = context; |
||||
} |
||||
public void Enter() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
|
||||
public void Execute() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
|
||||
public void Exit() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: b85849d4caf94ce9888c4c34a07ef1bc |
||||
timeCreated: 1648900334 |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
using Enemies.States; |
||||
|
||||
namespace Enemies |
||||
{ |
||||
public class TargetingState: IState |
||||
{ |
||||
private Enemy context; |
||||
public TargetingState(Enemy context) |
||||
{ |
||||
this.context = context; |
||||
} |
||||
|
||||
public void Enter() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
|
||||
public void Execute() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
|
||||
public void Exit() |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: c0d6af1e1a6143d9ad5b7fac796bda71 |
||||
timeCreated: 1648900434 |
Loading…
Reference in new issue