|
@@ -1,5 +1,7 @@
|
|
|
-using System.Linq;
|
|
|
+using System;
|
|
|
+using System.Linq;
|
|
|
using System.Numerics;
|
|
|
+using System.Text;
|
|
|
using System.Text.Json;
|
|
|
|
|
|
namespace ET.Server
|
|
@@ -42,29 +44,41 @@ namespace ET.Server
|
|
|
|
|
|
Struct.TriggerEventNotify notify = null;
|
|
|
|
|
|
- for (int i = 0; i < request.GiftNum; i++)
|
|
|
+ if (DouyinItem.GiftId_1.Equals(request.GiftId) || DouyinItem.GiftId_10.Equals(request.GiftId))
|
|
|
{
|
|
|
- int objId = 0;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- switch (request.GiftId)
|
|
|
- {
|
|
|
- case DouyinItem.GiftId_1:
|
|
|
-
|
|
|
+ StringBuilder objIds = new StringBuilder();
|
|
|
|
|
|
-
|
|
|
- objId = unitPlayerData.DeadState == 1? unitPlayerData.ObjId : map.DeadUnitPlayer.Count > 0? map.DeadUnitPlayer.First() : 0;
|
|
|
+ notify = new Struct.TriggerEventNotify();
|
|
|
|
|
|
+ if (unitPlayerData.DeadState == 1)
|
|
|
+ {
|
|
|
+ objIds.Append(unitPlayerData.ObjId);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ long cnt = request.GiftNum * (DouyinItem.GiftId_1.Equals(request.GiftId)? 1 : 3);
|
|
|
+
|
|
|
+ foreach (int objId in map.DeadUnitPlayer)
|
|
|
+ {
|
|
|
if (objId > 0)
|
|
|
{
|
|
|
- map.GetXmdsManager().notifyBattleServer(map.Id.ToString(), NotifyBSName.TriggerEvent, JsonSerializer.Serialize(new Struct.TriggerEventNotify()
|
|
|
- {
|
|
|
- message = BattleNotify.TiktokGift_1.ToString(),
|
|
|
- TriggerUnits = objId.ToString()
|
|
|
- })) ;
|
|
|
+ objIds.Append(objId).Append(',');
|
|
|
+ cnt -= 1;
|
|
|
}
|
|
|
- else
|
|
|
+ if (cnt <= 0)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cnt > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+ for (int i = 0; i < cnt; i++)
|
|
|
{
|
|
|
-
|
|
|
Vector2 pos = map.GetRandomPlayerPos();
|
|
|
|
|
|
Struct.MonsterUnit unit = new Struct.MonsterUnit();
|
|
@@ -73,103 +87,74 @@ namespace ET.Server
|
|
|
unit.x = pos.X;
|
|
|
unit.y = pos.Y;
|
|
|
unit.autoGuard = true;
|
|
|
- unit.name = "Nickname";
|
|
|
- unit.alias = "Url";
|
|
|
+ unit.name = map.GetRandomPlayerName();
|
|
|
|
|
|
int _objId = await map.AddUnits(unit, true);
|
|
|
+
|
|
|
+ string _openId = (10000 + new Random().Next(999)).ToString();
|
|
|
|
|
|
- map.AddUnitPlayer(request.OpenId, unit.id, _objId, 0, request.NickName, request.Url);
|
|
|
+ map.AddUnitPlayer(_openId, unit.id, _objId, 0, unit.name, "");
|
|
|
}
|
|
|
- break;
|
|
|
- case DouyinItem.GiftId_10:
|
|
|
-
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- objId = 0;
|
|
|
-
|
|
|
- if (unitPlayerData.DeadState == 1)
|
|
|
- {
|
|
|
- objId = unitPlayerData.ObjId;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- int index = 0;
|
|
|
- foreach (int deadObjId in map.DeadUnitPlayer.Where(deadObjId => deadObjId > 0 && index < 3))
|
|
|
+ notify.message = DouyinItem.GiftId_1.Equals(request.GiftId)? BattleNotify.TiktokGift_1.ToString() : BattleNotify.TiktokGift_10.ToString();
|
|
|
+ notify.TriggerUnits = objIds.ToString();
|
|
|
+ map.GetXmdsManager().notifyBattleServer(map.Id.ToString(), NotifyBSName.TriggerEvent, JsonSerializer.Serialize(notify));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for (int i = 0; i < request.GiftNum; i++)
|
|
|
+ {
|
|
|
+ switch (request.GiftId)
|
|
|
+ {
|
|
|
+ case DouyinItem.GiftId_52:
|
|
|
+
|
|
|
+ const long maxLevel = 3;
|
|
|
+ notify = new Struct.TriggerEventNotify();
|
|
|
+ if (unitPlayerData.Level < maxLevel)
|
|
|
{
|
|
|
- map.GetXmdsManager().notifyBattleServer(map.Id.ToString(), NotifyBSName.TriggerEvent, JsonSerializer.Serialize(new Struct.TriggerEventNotify()
|
|
|
- {
|
|
|
- message = BattleNotify.TiktokGift_10.ToString(),
|
|
|
- TriggerUnits = deadObjId.ToString()
|
|
|
- })) ;
|
|
|
- index += 1;
|
|
|
+ ++unitPlayerData.Level;
|
|
|
+ notify.message = BattleNotify.TiktokGift_52.ToString();
|
|
|
}
|
|
|
-
|
|
|
- if (3 - index > 0)
|
|
|
+ else
|
|
|
{
|
|
|
- for (int j = 0; j < 3 - index; j++)
|
|
|
- {
|
|
|
- Vector2 pos = map.GetRandomPlayerPos();
|
|
|
-
|
|
|
- Struct.MonsterUnit unit = new Struct.MonsterUnit();
|
|
|
- unit.id = RandomGenerator.RandomArray(units);
|
|
|
- unit.force = 1;
|
|
|
- unit.x = pos.X;
|
|
|
- unit.y = pos.Y;
|
|
|
- unit.autoGuard = true;
|
|
|
- unit.name = "Nickname";
|
|
|
- unit.alias = "Url";
|
|
|
-
|
|
|
- int _objId = await map.AddUnits(unit, true);
|
|
|
-
|
|
|
- map.AddUnitPlayer(request.OpenId, unit.id, _objId, 0, request.NickName, request.Url);
|
|
|
- }
|
|
|
+ notify.message = BattleNotify.TiktokGift_52_ext.ToString();
|
|
|
}
|
|
|
- }
|
|
|
- break;
|
|
|
- case DouyinItem.GiftId_52:
|
|
|
-
|
|
|
- const long maxLevel = 3;
|
|
|
- notify = new Struct.TriggerEventNotify();
|
|
|
- if (unitPlayerData.Level < maxLevel)
|
|
|
- {
|
|
|
- ++unitPlayerData.Level;
|
|
|
- notify.message = BattleNotify.TiktokGift_52.ToString();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- notify.message = BattleNotify.TiktokGift_52_ext.ToString();
|
|
|
- }
|
|
|
- notify.TriggerUnits = unitPlayerData.ObjId.ToString();
|
|
|
- break;
|
|
|
- case DouyinItem.GiftId_99:
|
|
|
-
|
|
|
- notify = new Struct.TriggerEventNotify();
|
|
|
- notify.message = BattleNotify.TiktokGift_99.ToString();
|
|
|
- notify.TriggerUnits = unitPlayerData.ObjId.ToString();
|
|
|
-
|
|
|
- map.AddContributeValue(request.OpenId, 99);
|
|
|
- break;
|
|
|
- case DouyinItem.GiftId_199:
|
|
|
-
|
|
|
- notify = new Struct.TriggerEventNotify();
|
|
|
- notify.message = BattleNotify.TiktokGift_199.ToString();
|
|
|
- notify.TriggerUnits = unitPlayerData.ObjId.ToString();
|
|
|
-
|
|
|
- map.AddContributeValue(request.OpenId, 199);
|
|
|
- break;
|
|
|
- case DouyinItem.GiftId_520:
|
|
|
-
|
|
|
- notify = new Struct.TriggerEventNotify();
|
|
|
- notify.message = BattleNotify.TiktokGift_520.ToString();
|
|
|
- notify.TriggerUnits = unitPlayerData.ObjId.ToString();
|
|
|
-
|
|
|
- map.AddContributeValue(request.OpenId, 520);
|
|
|
- break;
|
|
|
+ notify.TriggerUnits = unitPlayerData.ObjId.ToString();
|
|
|
+ break;
|
|
|
+ case DouyinItem.GiftId_99:
|
|
|
+
|
|
|
+ notify = new Struct.TriggerEventNotify();
|
|
|
+ notify.message = BattleNotify.TiktokGift_99.ToString();
|
|
|
+ notify.TriggerUnits = unitPlayerData.ObjId.ToString();
|
|
|
+
|
|
|
+ map.AddContributeValue(request.OpenId, 99);
|
|
|
+ break;
|
|
|
+ case DouyinItem.GiftId_199:
|
|
|
+
|
|
|
+ notify = new Struct.TriggerEventNotify();
|
|
|
+ notify.message = BattleNotify.TiktokGift_199.ToString();
|
|
|
+ notify.TriggerUnits = unitPlayerData.ObjId.ToString();
|
|
|
+
|
|
|
+ map.AddContributeValue(request.OpenId, 199);
|
|
|
+ break;
|
|
|
+ case DouyinItem.GiftId_520:
|
|
|
+
|
|
|
+ notify = new Struct.TriggerEventNotify();
|
|
|
+ notify.message = BattleNotify.TiktokGift_520.ToString();
|
|
|
+ notify.TriggerUnits = unitPlayerData.ObjId.ToString();
|
|
|
+
|
|
|
+ map.AddContributeValue(request.OpenId, 520);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ map.GetXmdsManager().notifyBattleServer(map.Id.ToString(), NotifyBSName.TriggerEvent, JsonSerializer.Serialize(notify));
|
|
|
+
|
|
|
+ await TimerComponent.Instance.WaitAsync(30);
|
|
|
}
|
|
|
-
|
|
|
- map.GetXmdsManager().notifyBattleServer(map.Id.ToString(), NotifyBSName.TriggerEvent, JsonSerializer.Serialize(notify));
|
|
|
-
|
|
|
- await TimerComponent.Instance.WaitAsync(30);
|
|
|
}
|
|
|
}
|
|
|
}
|