Forráskód Böngészése

Bare bones for running a recharging behavior

DasGewehr 9 éve
szülő
commit
663013eaaf

+ 2 - 2
game/Assets/Scripts/Enemy/Behavior.cs

@@ -3,9 +3,9 @@ using System.Collections.Generic;
 
 namespace EnemyAI
 {
-    public class Behavior
+    internal class Behavior
     {
-        public virtual Result Run()
+        internal virtual Result Run(ref Blackboard blackboard)
         {
             return Result.Failure;
         }

+ 23 - 0
game/Assets/Scripts/Enemy/BehaviorController.cs

@@ -0,0 +1,23 @@
+using System.Collections;
+using System.Collections.Generic;
+
+namespace EnemyAI
+{
+    public class BehaviorController
+    {
+        public Blackboard blackboard;
+
+        private EnemyAI.Behavior currentBehavior;
+
+        public BehaviorController()
+        {
+            blackboard = new Blackboard();
+            currentBehavior = new RechargeBehavior();
+        }
+
+        public void Update()
+        {
+            EnemyAI.Result result = currentBehavior.Run(ref blackboard);	
+        }
+    }
+}

+ 12 - 0
game/Assets/Scripts/Enemy/BehaviorController.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 5640c2ba48e829645b7bb4f6d5432bf9
+timeCreated: 1501344755
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 14 - 5
game/Assets/Scripts/Enemy/Enemy.cs

@@ -2,15 +2,24 @@
 using System.Collections.Generic;
 using UnityEngine;
 
-public class Enemy : MonoBehaviour {
+public class Enemy : MonoBehaviour 
+{
+    private float power;
+    private enum PowerLevels { VeryLow, Low, Medium, High, Full}
+    [SerializeField]
+    private PowerLevels powerLevel;
+    private EnemyAI.BehaviorController behaviorController;
 
 	// Use this for initialization
-	void Start () {
-		
+	void Start () 
+    {
+        behaviorController = new EnemyAI.BehaviorController();
 	}
 	
 	// Update is called once per frame
-	void Update () {
-		
+	void Update () 
+    {
+        behaviorController.blackboard.Night = true;
+        behaviorController.Update();
 	}
 }

+ 16 - 0
game/Assets/Scripts/Enemy/PersonalBlackboard.cs

@@ -0,0 +1,16 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+
+namespace EnemyAI
+{
+    public class Blackboard
+    {
+        public bool Night 
+        { 
+            get; 
+            set; 
+        }
+    }
+}

+ 12 - 0
game/Assets/Scripts/Enemy/PersonalBlackboard.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 73137ddab3f1f40459b115816a8f0341
+timeCreated: 1501344087
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 7 - 4
game/Assets/Scripts/Enemy/RechargeBehavior.cs

@@ -4,13 +4,16 @@ using UnityEngine;
 
 namespace EnemyAI
 {
-    public class RechargeBehavior : Behavior
+    internal class RechargeBehavior : Behavior
     {
-        public override Result Run()
+        internal override Result Run(ref Blackboard blackboard)
         {
+            if (blackboard.Night)
+            {
+                return Result.Success;
+            }
 
-
-            return Result.Failure;
+            return Result.Running;
         }
     }
 }