|
@@ -4,13 +4,13 @@ using System.Linq;
|
|
|
|
|
|
namespace ET.Server
|
|
|
{
|
|
|
- [FriendOf(typeof (HGHHMainCheckerComponent))]
|
|
|
- public static class HGHHMainCheckerComponentSystem
|
|
|
+ [FriendOf(typeof (HGHuangHuangComponent))]
|
|
|
+ public static class HGHuangHuangComponentSystem
|
|
|
{
|
|
|
[ObjectSystem]
|
|
|
- public class HGHHMainCheckerComponentAwakeSystem: AwakeSystem<HGHHMainCheckerComponent>
|
|
|
+ public class HGHuangHuangComponentAwakeSystem: AwakeSystem<HGHuangHuangComponent>
|
|
|
{
|
|
|
- protected override void Awake(HGHHMainCheckerComponent self)
|
|
|
+ protected override void Awake(HGHuangHuangComponent self)
|
|
|
{
|
|
|
Room room = self.GetParent<Room>();
|
|
|
if (room == null)
|
|
@@ -25,7 +25,10 @@ namespace ET.Server
|
|
|
self.State = 0;
|
|
|
self.Players = new Player[4];
|
|
|
self.CurrentRound = 0;
|
|
|
+ self.ZhuangPos = 0;
|
|
|
+ self.Rand = new[] { 0, 0 };
|
|
|
self.CardList = new List<int>();
|
|
|
+ self.NextUpdateTime = 0;
|
|
|
|
|
|
int index = 0;
|
|
|
foreach (Player player in room.GetAllPlayers().Values)
|
|
@@ -49,19 +52,27 @@ namespace ET.Server
|
|
|
}
|
|
|
|
|
|
[ObjectSystem]
|
|
|
- public class HGHHMainCheckerComponentDestroySystem: DestroySystem<HGHHMainCheckerComponent>
|
|
|
+ public class HGHuangHuangComponentDestroySystem: DestroySystem<HGHuangHuangComponent>
|
|
|
{
|
|
|
- protected override void Destroy(HGHHMainCheckerComponent self)
|
|
|
+ protected override void Destroy(HGHuangHuangComponent self)
|
|
|
{
|
|
|
Log.Info($"销毁黄冈晃晃主逻辑组件...");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
[ObjectSystem]
|
|
|
- public class HGHHMainCheckerComponentUpdateSystem: UpdateSystem<HGHHMainCheckerComponent>
|
|
|
+ public class HGHuangHuangComponentUpdateSystem: UpdateSystem<HGHuangHuangComponent>
|
|
|
{
|
|
|
- protected override void Update(HGHHMainCheckerComponent self)
|
|
|
+ protected override void Update(HGHuangHuangComponent self)
|
|
|
{
|
|
|
+ long timeNow = TimeHelper.ClientNow();
|
|
|
+
|
|
|
+ if (timeNow - self.NextUpdateTime <= 1000)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ self.NextUpdateTime = timeNow;
|
|
|
+
|
|
|
Room room = self.GetParent<Room>();
|
|
|
if (room == null)
|
|
|
{
|
|
@@ -69,80 +80,67 @@ namespace ET.Server
|
|
|
return;
|
|
|
}
|
|
|
Log.Debug($"检测: 黄冈晃晃-房间号:{room.RoomId}, 状态:{self.State}...");
|
|
|
-
|
|
|
- try
|
|
|
- {
|
|
|
- self.Check(room);
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
+
|
|
|
+ switch (self.State)
|
|
|
{
|
|
|
- Log.Error($"move timer error: {self.Id}\n{e}");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private static void Check(this HGHHMainCheckerComponent self, Room room)
|
|
|
- {
|
|
|
- Log.Debug($"检测: 黄冈晃晃-房间号:{room.RoomId}...");
|
|
|
- switch (self.State)
|
|
|
- {
|
|
|
- case 0:
|
|
|
-
|
|
|
- Log.Debug($"检测: 黄冈晃晃-房间号:{room.RoomId}, 状态:检测是否可开局...");
|
|
|
- if (self.CheckReadySatrt(room))
|
|
|
- {
|
|
|
- self.State = 1;
|
|
|
- self.Flag = false;
|
|
|
- self.Time = 0;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 1:
|
|
|
-
|
|
|
- if (!self.Flag)
|
|
|
- {
|
|
|
- if (self.Time >= 3)
|
|
|
+ case 0:
|
|
|
+
|
|
|
+ Log.Debug($"检测: 黄冈晃晃-房间号:{room.RoomId}, 状态:检测是否可开局...");
|
|
|
+ if (self.CheckReadySatrt(room))
|
|
|
{
|
|
|
- self.Start(room);
|
|
|
- self.Flag = true;
|
|
|
+ self.State = 1;
|
|
|
+ self.Flag = false;
|
|
|
self.Time = 0;
|
|
|
- Log.Debug($"检测: 黄冈晃晃-房间号:{room.RoomId}, 状态:开局...VS动画...");
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (self.Time > 0)
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+
|
|
|
+ if (!self.Flag)
|
|
|
{
|
|
|
- self.State = 2;
|
|
|
- self.Flag = false;
|
|
|
+ if (self.Time >= 3)
|
|
|
+ {
|
|
|
+ self.Start(room);
|
|
|
+ self.Flag = true;
|
|
|
+ self.Time = 0;
|
|
|
+ Log.Debug($"检测: 黄冈晃晃-房间号:{room.RoomId}, 状态:开局...VS动画...");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (self.Time > 0)
|
|
|
+ {
|
|
|
+ self.State = 2;
|
|
|
+ self.Flag = false;
|
|
|
+ self.Time = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+
|
|
|
+ if (!self.Flag)
|
|
|
+ {
|
|
|
+ self.Flag = true;
|
|
|
self.Time = 0;
|
|
|
+
|
|
|
+ self.DrawCard(room);
|
|
|
}
|
|
|
- }
|
|
|
- break;
|
|
|
- case 2:
|
|
|
-
|
|
|
- if (!self.Flag)
|
|
|
- {
|
|
|
- self.Flag = true;
|
|
|
- self.Time = 0;
|
|
|
-
|
|
|
- self.DrawCard(room);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- if (self.Time > 30)
|
|
|
+ else
|
|
|
{
|
|
|
+
|
|
|
+ if (self.Time > 30)
|
|
|
+ {
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- break;
|
|
|
- case 3:
|
|
|
-
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+
|
|
|
|
|
|
- break;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ self.Time++;
|
|
|
}
|
|
|
-
|
|
|
- self.Time++;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -151,7 +149,7 @@ namespace ET.Server
|
|
|
|
|
|
|
|
|
|
|
|
- private static bool CheckReadySatrt(this HGHHMainCheckerComponent self, Room room)
|
|
|
+ private static bool CheckReadySatrt(this HGHuangHuangComponent self, Room room)
|
|
|
{
|
|
|
if (!room.IsStart() || self.State != 0)
|
|
|
{
|
|
@@ -167,12 +165,36 @@ namespace ET.Server
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private static void SendCard(this HGHuangHuangComponent self, Room room)
|
|
|
+ {
|
|
|
+ foreach (Player player in room.GetAllPlayers().Values)
|
|
|
+ {
|
|
|
+ if (player == null)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < 13; i++)
|
|
|
+ {
|
|
|
+ int card = self.CardList[0];
|
|
|
+ player.RemainCards.Add(card);
|
|
|
+ self.CardList.RemoveAt(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- private static void Start(this HGHHMainCheckerComponent self, Room room)
|
|
|
+ private static void Start(this HGHuangHuangComponent self, Room room)
|
|
|
{
|
|
|
self.CurrentRound += 1;
|
|
|
|
|
@@ -187,7 +209,7 @@ namespace ET.Server
|
|
|
self.DrawCardPlayer = room.GetAllPlayers()[self.ZhuangPos];
|
|
|
|
|
|
self.SendCard(room);
|
|
|
-
|
|
|
+
|
|
|
foreach (Player player in room.GetAllPlayers().Values)
|
|
|
{
|
|
|
if (player != null)
|
|
@@ -201,35 +223,12 @@ namespace ET.Server
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private static void SendCard(this HGHHMainCheckerComponent self, Room room)
|
|
|
- {
|
|
|
- foreach (Player player in room.GetAllPlayers().Values)
|
|
|
- {
|
|
|
- if (player == null)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- for (int i = 0; i < 13; i++)
|
|
|
- {
|
|
|
- int card = self.CardList[0];
|
|
|
- player.RemainCards.Add(card);
|
|
|
- self.CardList.RemoveAt(0);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- private static void DrawCard(this HGHHMainCheckerComponent self, Room room)
|
|
|
+ private static void DrawCard(this HGHuangHuangComponent self, Room room)
|
|
|
{
|
|
|
|
|
|
}
|