Przeglądaj źródła

增加战斗单位可视化模型ModelViewComponent

大爷 2 lat temu
rodzic
commit
04a29d6b2a

+ 25 - 0
Unity/Assets/Scripts/Codes/HotfixView/Client/Scene/ModelViewComponentSystem.cs

@@ -0,0 +1,25 @@
+
+namespace ET.Client
+{
+    [FriendOf(typeof(ModelViewComponent))]
+    public static class ModelViewComponentSystem
+    {
+        [ObjectSystem]
+        public class ModelViewComponentAwakeSystem : AwakeSystem<ModelViewComponent>
+        {
+            protected override void Awake(ModelViewComponent self)
+            {
+                ModelViewComponent.Instance = self;
+            }
+        }
+
+        [ObjectSystem]
+        public class ModelViewComponentDestroySystem : DestroySystem<ModelViewComponent>
+        {
+            protected override void Destroy(ModelViewComponent self)
+            {
+                ModelViewComponent.Instance = null;
+            }
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/HotfixView/Client/Scene/ModelViewComponentSystem.cs.meta

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

+ 6 - 5
Unity/Assets/Scripts/Codes/HotfixView/Client/Unit/AnimatorComponentSystem.cs

@@ -1,17 +1,18 @@
 using CMDType = ET.Client.AnimatorComponent.CommandType;
 using AniType = Mono.AnimationData.AnimationType;
+using UnityEngine;
 
 namespace ET.Client
 {
-    [FriendOfAttribute(typeof(GameObjectComponent))]
     [FriendOf(typeof(AnimatorComponent))]
     public static class AnimatorComponentSystem
     {
         [ObjectSystem]
-        public class AnimatorComponentAwakeSystem : AwakeSystem<AnimatorComponent>
+        public class AnimatorComponentAwakeSystem : AwakeSystem<AnimatorComponent, GameObject>
         {
-            protected override void Awake(AnimatorComponent self)
+            protected override void Awake(AnimatorComponent self, GameObject go)
             {
+                self.GameObject = go;
                 self.Awake();
             }
         }
@@ -31,6 +32,7 @@ namespace ET.Client
             protected override void Destroy(AnimatorComponent self)
             {
                 self.AniData.Animancer.Stop();
+                UnityEngine.Object.Destroy(self.GameObject);
             }
         }
 
@@ -47,8 +49,7 @@ namespace ET.Client
 
         public static void Awake(this AnimatorComponent self)
         {
-            GameObjectComponent gameObjectComponent = self.GetParent<Unit>().GetComponent<GameObjectComponent>();
-            self.AniData = gameObjectComponent.GameObject.GetComponent<Mono.AnimationData>();
+            self.AniData = self.GameObject.GetComponent<Mono.AnimationData>();
 
             self.DoingType = AniType.Dead;
             self.ExeCommand(AnimatorComponent.CMDIdle);

+ 1 - 1
Unity/Assets/Scripts/Codes/ModelView/Client/Camera/CameraComponent.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Client
 {
-    [ComponentOf(typeof(Unit))]
+    [ComponentOf(typeof(ModelViewComponent))]
     public class CameraComponent : Entity, IAwake, ILateUpdate
 	{
 		// 战斗摄像机

+ 5 - 3
Unity/Assets/Scripts/Codes/ModelView/Client/Unit/AnimatorComponent.cs

@@ -1,10 +1,11 @@
-using Mono;
+using UnityEngine;
+using Mono;
 using System.Collections.Generic;
 
 namespace ET.Client
 {
-	[ComponentOf(typeof(Unit))]
-	public class AnimatorComponent : Entity, IAwake, IUpdate, IDestroy
+	[ChildOf(typeof(ModelViewComponent))]
+	public class AnimatorComponent : Entity, IAwake<GameObject>, IUpdate, IDestroy
 	{
         //状态指令
         public enum CommandType
@@ -39,6 +40,7 @@ namespace ET.Client
         //指令队列
         public List<Command> Commands = new List<Command>();
 
+        public GameObject GameObject { get; set; }
         public AnimationData AniData;
         public AnimationData.AnimationType DoingType;
     }

+ 12 - 0
Unity/Assets/Scripts/Codes/ModelView/Client/Unit/ModelViewComponent.cs

@@ -0,0 +1,12 @@
+using CommonLang;
+using UnityEngine;
+
+namespace ET.Client
+{
+    [ComponentOf(typeof(Scene))]
+    public class ModelViewComponent : Entity, IAwake, IDestroy
+    {
+        [StaticField]
+        public static ModelViewComponent Instance;
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/ModelView/Client/Unit/ModelViewComponent.cs.meta

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