Browse Source

UnitInfo带上MoveInfo

tanghai 4 years ago
parent
commit
90eef7e574

+ 1 - 1
Config/UnitConfigCategory.bytes

@@ -1,2 +1,2 @@
 
-/é	米克尔"带有强力攻击技能(0²8D
+1é"	米克尔*带有强力攻击技能08²@D

BIN
Excel/UnitConfig.xlsx


+ 23 - 5
Proto/OuterMessage.proto

@@ -45,15 +45,33 @@ message G2C_EnterMap // IResponse
 	int64 MyId = 1;
 }
 
+message MoveInfo
+{
+	repeated float X = 1;
+	repeated float Y = 2;
+	repeated float Z = 3;
+
+	float A = 4;
+	float B = 5;
+	float C = 6;
+	float W = 7;
+	int32 TurnSpeed = 8;
+}
+
 message UnitInfo
 {
 	int64 UnitId = 1;
 	int32 ConfigId = 2;
-	float X = 3;
-	float Y = 4;
-	float Z = 5;
-	repeated int32 Ks = 6;
-	repeated int64 Vs = 7;
+	int32 Type = 3;
+	float X = 4;
+	float Y = 5;
+	float Z = 6;
+	float ForwardX = 7;
+	float ForwardY = 8;
+	float ForwardZ = 9;
+	repeated int32 Ks = 10;
+	repeated int64 Vs = 11;
+	MoveInfo MoveInfo = 12;
 }
 
 message M2C_CreateUnits // IActorMessage

+ 0 - 1
Server/Hotfix/Demo/G2M_CreateUnitHandler.cs

@@ -10,7 +10,6 @@ namespace ET
 		{
 			UnitComponent unitComponent = scene.GetComponent<UnitComponent>();
 			Unit unit = unitComponent.AddChildWithId<Unit, int>(IdGenerater.Instance.GenerateId(), 1001);
-			unit.Type = UnitType.Player;
 			unit.AddComponent<MoveComponent>();
 			unit.AddComponent<PathfindingComponent, string>("solo");
 			unit.Position = new Vector3(-10, 0, -10);

+ 26 - 3
Server/Hotfix/Demo/Unit/UnitHelper.cs

@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using UnityEngine;
 
 namespace ET
 {
@@ -8,11 +9,33 @@ namespace ET
         {
             UnitInfo unitInfo = new UnitInfo();
             NumericComponent nc = unit.GetComponent<NumericComponent>();
-            unitInfo.X = unit.Position.x;
-            unitInfo.Y = unit.Position.y;
-            unitInfo.Z = unit.Position.z;
             unitInfo.UnitId = unit.Id;
             unitInfo.ConfigId = unit.ConfigId;
+            unitInfo.Type = (int)unit.Type;
+            Vector3 position = unit.Position;
+            unitInfo.X = position.x;
+            unitInfo.Y = position.y;
+            unitInfo.Z = position.z;
+            Vector3 forward = unit.Forward;
+            unitInfo.ForwardX = forward.x;
+            unitInfo.ForwardY = forward.y;
+            unitInfo.ForwardZ = forward.z;
+
+            MoveComponent moveComponent = unit.GetComponent<MoveComponent>();
+            if (moveComponent != null)
+            {
+                if (!moveComponent.IsArrived())
+                {
+                    unitInfo.MoveInfo = new MoveInfo();
+                    for (int i = moveComponent.N; i < moveComponent.Targets.Count; ++i)
+                    {
+                        Vector3 pos = moveComponent.Targets[i];
+                        unitInfo.MoveInfo.X.Add(pos.x);
+                        unitInfo.MoveInfo.Y.Add(pos.y);
+                        unitInfo.MoveInfo.Z.Add(pos.z);
+                    }
+                }
+            }
 
             foreach ((int key, long value) in nc.NumericDic)
             {

+ 2 - 1
Server/Model/Demo/Unit/Unit.cs

@@ -8,7 +8,8 @@ namespace ET
     {
         public int ConfigId; //配置表id
 
-        public UnitType Type;
+        [BsonIgnore]
+        public UnitType Type => (UnitType)this.Config.Type;
 
         [BsonIgnore]
         public UnitConfig Config => UnitConfigCategory.Instance.Get(this.ConfigId);

+ 7 - 5
Server/Model/Generate/Config/UnitConfig.cs

@@ -71,15 +71,17 @@ namespace ET
 	{
 		[ProtoMember(1)]
 		public int Id { get; set; }
-		[ProtoMember(3)]
-		public string Name { get; set; }
+		[ProtoMember(2)]
+		public int Type { get; set; }
 		[ProtoMember(4)]
-		public string Desc { get; set; }
+		public string Name { get; set; }
 		[ProtoMember(5)]
-		public int Position { get; set; }
+		public string Desc { get; set; }
 		[ProtoMember(6)]
-		public int Height { get; set; }
+		public int Position { get; set; }
 		[ProtoMember(7)]
+		public int Height { get; set; }
+		[ProtoMember(8)]
 		public int Weight { get; set; }
 
 	}

+ 49 - 4
Server/Model/Generate/Message/OuterMessage.cs

@@ -91,6 +91,36 @@ namespace ET
 
 	}
 
+	[Message(OuterOpcode.MoveInfo)]
+	[ProtoContract]
+	public partial class MoveInfo: Object
+	{
+		[ProtoMember(1)]
+		public List<float> X = new List<float>();
+
+		[ProtoMember(2)]
+		public List<float> Y = new List<float>();
+
+		[ProtoMember(3)]
+		public List<float> Z = new List<float>();
+
+		[ProtoMember(4)]
+		public float A { get; set; }
+
+		[ProtoMember(5)]
+		public float B { get; set; }
+
+		[ProtoMember(6)]
+		public float C { get; set; }
+
+		[ProtoMember(7)]
+		public float W { get; set; }
+
+		[ProtoMember(8)]
+		public int TurnSpeed { get; set; }
+
+	}
+
 	[Message(OuterOpcode.UnitInfo)]
 	[ProtoContract]
 	public partial class UnitInfo: Object
@@ -102,20 +132,35 @@ namespace ET
 		public int ConfigId { get; set; }
 
 		[ProtoMember(3)]
-		public float X { get; set; }
+		public int Type { get; set; }
 
 		[ProtoMember(4)]
-		public float Y { get; set; }
+		public float X { get; set; }
 
 		[ProtoMember(5)]
-		public float Z { get; set; }
+		public float Y { get; set; }
 
 		[ProtoMember(6)]
-		public List<int> Ks = new List<int>();
+		public float Z { get; set; }
 
 		[ProtoMember(7)]
+		public float ForwardX { get; set; }
+
+		[ProtoMember(8)]
+		public float ForwardY { get; set; }
+
+		[ProtoMember(9)]
+		public float ForwardZ { get; set; }
+
+		[ProtoMember(10)]
+		public List<int> Ks = new List<int>();
+
+		[ProtoMember(11)]
 		public List<long> Vs = new List<long>();
 
+		[ProtoMember(12)]
+		public MoveInfo MoveInfo { get; set; }
+
 	}
 
 	[Message(OuterOpcode.M2C_CreateUnits)]

+ 20 - 19
Server/Model/Generate/Message/OuterOpcode.cs

@@ -8,24 +8,25 @@ namespace ET
 		 public const ushort Actor_TransferResponse = 10005;
 		 public const ushort C2G_EnterMap = 10006;
 		 public const ushort G2C_EnterMap = 10007;
-		 public const ushort UnitInfo = 10008;
-		 public const ushort M2C_CreateUnits = 10009;
-		 public const ushort M2C_RemoveUnits = 10010;
-		 public const ushort C2M_PathfindingResult = 10011;
-		 public const ushort C2M_Stop = 10012;
-		 public const ushort M2C_PathfindingResult = 10013;
-		 public const ushort M2C_Stop = 10014;
-		 public const ushort C2G_Ping = 10015;
-		 public const ushort G2C_Ping = 10016;
-		 public const ushort G2C_Test = 10017;
-		 public const ushort C2M_Reload = 10018;
-		 public const ushort M2C_Reload = 10019;
-		 public const ushort C2R_Login = 10020;
-		 public const ushort R2C_Login = 10021;
-		 public const ushort C2G_LoginGate = 10022;
-		 public const ushort G2C_LoginGate = 10023;
-		 public const ushort G2C_TestHotfixMessage = 10024;
-		 public const ushort C2M_TestRobotCase = 10025;
-		 public const ushort M2C_TestRobotCase = 10026;
+		 public const ushort MoveInfo = 10008;
+		 public const ushort UnitInfo = 10009;
+		 public const ushort M2C_CreateUnits = 10010;
+		 public const ushort M2C_RemoveUnits = 10011;
+		 public const ushort C2M_PathfindingResult = 10012;
+		 public const ushort C2M_Stop = 10013;
+		 public const ushort M2C_PathfindingResult = 10014;
+		 public const ushort M2C_Stop = 10015;
+		 public const ushort C2G_Ping = 10016;
+		 public const ushort G2C_Ping = 10017;
+		 public const ushort G2C_Test = 10018;
+		 public const ushort C2M_Reload = 10019;
+		 public const ushort M2C_Reload = 10020;
+		 public const ushort C2R_Login = 10021;
+		 public const ushort R2C_Login = 10022;
+		 public const ushort C2G_LoginGate = 10023;
+		 public const ushort G2C_LoginGate = 10024;
+		 public const ushort G2C_TestHotfixMessage = 10025;
+		 public const ushort C2M_TestRobotCase = 10026;
+		 public const ushort M2C_TestRobotCase = 10027;
 	}
 }

+ 1 - 1
Unity/Assets/Bundles/Config/UnitConfigCategory.bytes

@@ -1,2 +1,2 @@
 
-/é	米克尔"带有强力攻击技能(0²8D
+1é"	米克尔*带有强力攻击技能08²@D

+ 8 - 0
Unity/Codes/Hotfix/Demo/Move/MoveHelper.cs

@@ -20,5 +20,13 @@ namespace ET
             WaitType.Wait_UnitStop waitUnitStop = await objectWait.Wait<WaitType.Wait_UnitStop>(cancellationToken);
             return waitUnitStop.Error;
         }
+        
+        public static async ETTask<bool> MoveToAsync(this Unit unit, List<Vector3> path)
+        {
+            float speed = unit.GetComponent<NumericComponent>().GetAsFloat(NumericType.Speed);
+            MoveComponent moveComponent = unit.GetComponent<MoveComponent>();
+            bool ret = await moveComponent.MoveToAsync(path, speed);
+            return ret;
+        }
     }
 }

+ 19 - 1
Unity/Codes/Hotfix/Demo/Unit/UnitFactory.cs

@@ -11,13 +11,31 @@ namespace ET
 	        unitComponent.Add(unit);
 	        
 	        unit.Position = new Vector3(unitInfo.X, unitInfo.Y, unitInfo.Z);
+	        unit.Forward = new Vector3(unitInfo.ForwardX, unitInfo.ForwardY, unitInfo.ForwardZ);
 	        
-	        unit.AddComponent<MoveComponent>();
 	        NumericComponent numericComponent = unit.AddComponent<NumericComponent>();
 	        for (int i = 0; i < unitInfo.Ks.Count; ++i)
 	        {
 		        numericComponent.Set((NumericType)unitInfo.Ks[i], unitInfo.Vs[i]);
 	        }
+	        
+	        unit.AddComponent<MoveComponent>();
+	        if (unitInfo.MoveInfo != null)
+	        {
+		        if (unitInfo.MoveInfo.X.Count > 0)
+		        {
+			        using (ListComponent<Vector3> list = ListComponent<Vector3>.Create())
+			        {
+				        list.Add(unit.Position);
+				        for (int i = 0; i < unitInfo.MoveInfo.X.Count; ++i)
+				        {
+					        list.Add(new Vector3(unitInfo.MoveInfo.X[i], unitInfo.MoveInfo.Y[i], unitInfo.MoveInfo.Z[i]));
+				        }
+
+				        unit.MoveToAsync(list).Coroutine();
+			        }
+		        }
+	        }
 
 	        unit.AddComponent<ObjectWait>();
 

+ 7 - 5
Unity/Codes/Model/Generate/Config/UnitConfig.cs

@@ -71,15 +71,17 @@ namespace ET
 	{
 		[ProtoMember(1)]
 		public int Id { get; set; }
-		[ProtoMember(3)]
-		public string Name { get; set; }
+		[ProtoMember(2)]
+		public int Type { get; set; }
 		[ProtoMember(4)]
-		public string Desc { get; set; }
+		public string Name { get; set; }
 		[ProtoMember(5)]
-		public int Position { get; set; }
+		public string Desc { get; set; }
 		[ProtoMember(6)]
-		public int Height { get; set; }
+		public int Position { get; set; }
 		[ProtoMember(7)]
+		public int Height { get; set; }
+		[ProtoMember(8)]
 		public int Weight { get; set; }
 
 	}

+ 49 - 4
Unity/Codes/Model/Generate/Message/OuterMessage.cs

@@ -91,6 +91,36 @@ namespace ET
 
 	}
 
+	[Message(OuterOpcode.MoveInfo)]
+	[ProtoContract]
+	public partial class MoveInfo: Object
+	{
+		[ProtoMember(1)]
+		public List<float> X = new List<float>();
+
+		[ProtoMember(2)]
+		public List<float> Y = new List<float>();
+
+		[ProtoMember(3)]
+		public List<float> Z = new List<float>();
+
+		[ProtoMember(4)]
+		public float A { get; set; }
+
+		[ProtoMember(5)]
+		public float B { get; set; }
+
+		[ProtoMember(6)]
+		public float C { get; set; }
+
+		[ProtoMember(7)]
+		public float W { get; set; }
+
+		[ProtoMember(8)]
+		public int TurnSpeed { get; set; }
+
+	}
+
 	[Message(OuterOpcode.UnitInfo)]
 	[ProtoContract]
 	public partial class UnitInfo: Object
@@ -102,20 +132,35 @@ namespace ET
 		public int ConfigId { get; set; }
 
 		[ProtoMember(3)]
-		public float X { get; set; }
+		public int Type { get; set; }
 
 		[ProtoMember(4)]
-		public float Y { get; set; }
+		public float X { get; set; }
 
 		[ProtoMember(5)]
-		public float Z { get; set; }
+		public float Y { get; set; }
 
 		[ProtoMember(6)]
-		public List<int> Ks = new List<int>();
+		public float Z { get; set; }
 
 		[ProtoMember(7)]
+		public float ForwardX { get; set; }
+
+		[ProtoMember(8)]
+		public float ForwardY { get; set; }
+
+		[ProtoMember(9)]
+		public float ForwardZ { get; set; }
+
+		[ProtoMember(10)]
+		public List<int> Ks = new List<int>();
+
+		[ProtoMember(11)]
 		public List<long> Vs = new List<long>();
 
+		[ProtoMember(12)]
+		public MoveInfo MoveInfo { get; set; }
+
 	}
 
 	[Message(OuterOpcode.M2C_CreateUnits)]

+ 20 - 19
Unity/Codes/Model/Generate/Message/OuterOpcode.cs

@@ -8,24 +8,25 @@ namespace ET
 		 public const ushort Actor_TransferResponse = 10005;
 		 public const ushort C2G_EnterMap = 10006;
 		 public const ushort G2C_EnterMap = 10007;
-		 public const ushort UnitInfo = 10008;
-		 public const ushort M2C_CreateUnits = 10009;
-		 public const ushort M2C_RemoveUnits = 10010;
-		 public const ushort C2M_PathfindingResult = 10011;
-		 public const ushort C2M_Stop = 10012;
-		 public const ushort M2C_PathfindingResult = 10013;
-		 public const ushort M2C_Stop = 10014;
-		 public const ushort C2G_Ping = 10015;
-		 public const ushort G2C_Ping = 10016;
-		 public const ushort G2C_Test = 10017;
-		 public const ushort C2M_Reload = 10018;
-		 public const ushort M2C_Reload = 10019;
-		 public const ushort C2R_Login = 10020;
-		 public const ushort R2C_Login = 10021;
-		 public const ushort C2G_LoginGate = 10022;
-		 public const ushort G2C_LoginGate = 10023;
-		 public const ushort G2C_TestHotfixMessage = 10024;
-		 public const ushort C2M_TestRobotCase = 10025;
-		 public const ushort M2C_TestRobotCase = 10026;
+		 public const ushort MoveInfo = 10008;
+		 public const ushort UnitInfo = 10009;
+		 public const ushort M2C_CreateUnits = 10010;
+		 public const ushort M2C_RemoveUnits = 10011;
+		 public const ushort C2M_PathfindingResult = 10012;
+		 public const ushort C2M_Stop = 10013;
+		 public const ushort M2C_PathfindingResult = 10014;
+		 public const ushort M2C_Stop = 10015;
+		 public const ushort C2G_Ping = 10016;
+		 public const ushort G2C_Ping = 10017;
+		 public const ushort G2C_Test = 10018;
+		 public const ushort C2M_Reload = 10019;
+		 public const ushort M2C_Reload = 10020;
+		 public const ushort C2R_Login = 10021;
+		 public const ushort R2C_Login = 10022;
+		 public const ushort C2G_LoginGate = 10023;
+		 public const ushort G2C_LoginGate = 10024;
+		 public const ushort G2C_TestHotfixMessage = 10025;
+		 public const ushort C2M_TestRobotCase = 10026;
+		 public const ushort M2C_TestRobotCase = 10027;
 	}
 }

+ 1 - 1
Unity/Codes/Model/Module/Numeric/NumericType.cs

@@ -10,7 +10,7 @@
 	    SpeedPct = Speed * 10 + 3,
 	    SpeedFinalAdd = Speed * 10 + 4,
 	    SpeedFinalPct = Speed * 10 + 5,
-
+ 
 	    Hp = 1001,
 	    HpBase = Hp * 10 + 1,