|
@@ -234,7 +234,7 @@ namespace ET.Server
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- public static async ETTask<int> AddUnits(this Map self, List<Struct.MonsterUnit> data, bool needReturn)
|
|
+ private static async ETTask<int> AddUnits(this Map self, List<Struct.MonsterUnit> data, bool needReturn)
|
|
{
|
|
{
|
|
if (data.Count <= 0)
|
|
if (data.Count <= 0)
|
|
{
|
|
{
|
|
@@ -256,7 +256,7 @@ namespace ET.Server
|
|
return addUnitsResult;
|
|
return addUnitsResult;
|
|
}
|
|
}
|
|
|
|
|
|
- public static async ETTask<int> AddUnits(this Map self, Struct.MonsterUnit data, bool needReturn)
|
|
+ private static async ETTask<int> AddUnits(this Map self, Struct.MonsterUnit data, bool needReturn)
|
|
{
|
|
{
|
|
List<Struct.MonsterUnit> listData = new List<Struct.MonsterUnit>();
|
|
List<Struct.MonsterUnit> listData = new List<Struct.MonsterUnit>();
|
|
listData.Add(data);
|
|
listData.Add(data);
|
|
@@ -274,22 +274,6 @@ namespace ET.Server
|
|
await ETTask.CompletedTask;
|
|
await ETTask.CompletedTask;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public static string ReliveData(this Map self, ReliveType type)
|
|
|
|
- {
|
|
|
|
- JObject jsonObject = new ();
|
|
|
|
- jsonObject.Add("type", (int)type);
|
|
|
|
- jsonObject.Add("qty", 0);
|
|
|
|
- jsonObject.Add("itemType", "diamond");
|
|
|
|
- jsonObject.Add("hp", 8);
|
|
|
|
- jsonObject.Add("mp", 0);
|
|
|
|
- return JsonConvert.SerializeObject(jsonObject, Formatting.Indented);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -306,22 +290,61 @@ namespace ET.Server
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
+
|
|
-
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
- public static Struct.UnitPlayerData AddUnitPlayer(this Map self, string openId, int templateId, int objId, long likes, string name, string url)
|
|
+
|
|
|
|
+ public static async ETTask<Struct.UnitPlayerData> AddUnitPlayer(this Map self, string openId, int templateId, int force, string flag, float x, float y, string name, string url)
|
|
{
|
|
{
|
|
- if (string.IsNullOrEmpty(openId) || templateId <= 0 || objId <= 0 || self.IsGameOver())
|
|
+ if (self.IsGameOver())
|
|
{
|
|
{
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (templateId <= 0)
|
|
|
|
+ {
|
|
|
|
+ int[] units = new int[] { 101, 121, 111, 131 };
|
|
|
|
+
|
|
|
|
+ templateId = RandomGenerator.RandomArray(units);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Struct.MonsterUnit unit = new Struct.MonsterUnit();
|
|
|
|
+ unit.id = templateId;
|
|
|
|
+ unit.force = force;
|
|
|
|
+ if (!string.IsNullOrEmpty(flag))
|
|
|
|
+ {
|
|
|
|
+ unit.flag = flag;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ unit.x = x;
|
|
|
|
+ unit.y = y;
|
|
|
|
+ }
|
|
|
|
+ unit.autoGuard = true;
|
|
|
|
+ unit.name = string.IsNullOrEmpty(name)? self.GetRandomPlayerName() : name;
|
|
|
|
+ unit.alias = url;
|
|
|
|
+
|
|
|
|
+ int objId = await self.AddUnits(unit, true);
|
|
|
|
+
|
|
Struct.UnitPlayerData unitPlayerData = null;
|
|
Struct.UnitPlayerData unitPlayerData = null;
|
|
|
|
|
|
|
|
+ if (string.IsNullOrEmpty(openId))
|
|
|
|
+ {
|
|
|
|
+ openId = (10000 + new Random().Next(999)).ToString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
if (self.UnitPlayers.ContainsKey(openId))
|
|
if (self.UnitPlayers.ContainsKey(openId))
|
|
{
|
|
{
|
|
unitPlayerData = self.UnitPlayers[openId];
|
|
unitPlayerData = self.UnitPlayers[openId];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ self.RemovePointUnit(unitPlayerData.ObjId).Coroutine();
|
|
|
|
+
|
|
unitPlayerData.TemplateId = templateId;
|
|
unitPlayerData.TemplateId = templateId;
|
|
unitPlayerData.ObjId = objId;
|
|
unitPlayerData.ObjId = objId;
|
|
unitPlayerData.Name = name;
|
|
unitPlayerData.Name = name;
|