summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XSuperRiskMap.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-01-25 14:28:30 +0800
committerchai <chaifix@163.com>2021-01-25 14:28:30 +0800
commit6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch)
tree7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XMainClient/XSuperRiskMap.cs
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/XSuperRiskMap.cs')
-rw-r--r--Client/Assets/Scripts/XMainClient/XSuperRiskMap.cs100
1 files changed, 100 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/XSuperRiskMap.cs b/Client/Assets/Scripts/XMainClient/XSuperRiskMap.cs
new file mode 100644
index 00000000..ac8d8408
--- /dev/null
+++ b/Client/Assets/Scripts/XMainClient/XSuperRiskMap.cs
@@ -0,0 +1,100 @@
+using System;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal class XSuperRiskMap
+ {
+ public XSuperRiskMapStaticInfo StaticInfo;
+
+ public XSuperRiskMapDynamicInfo DynamicInfo;
+
+ public Coordinate PlayerCoord;
+
+ public Direction PlayerMoveDirection;
+
+ public XSuperRiskMapRenderer renderer = new XSuperRiskMapRenderer();
+
+ public void Clear()
+ {
+ this.StaticInfo = null;
+ this.DynamicInfo = null;
+ this.PlayerCoord = Coordinate.Invalid;
+ this.PlayerMoveDirection = Direction.Up;
+ }
+
+ public Direction StartMoveNext(ref Coordinate targetCoord)
+ {
+ this.PlayerMoveDirection = this.GetNextTryDirection(this.PlayerMoveDirection, 3);
+ for (int i = 0; i < 4; i++)
+ {
+ Coordinate coordinate = this.GoWithDirection(this.PlayerCoord, this.PlayerMoveDirection);
+ bool flag = this.StaticInfo.FindMapNode(coordinate) != null;
+ if (flag)
+ {
+ targetCoord = coordinate;
+ break;
+ }
+ this.PlayerMoveDirection = this.GetNextTryDirection(this.PlayerMoveDirection, 1);
+ }
+ return this.PlayerMoveDirection;
+ }
+
+ protected Direction GetNextTryDirection(Direction dir, int offset)
+ {
+ return (Direction)((XFastEnumIntEqualityComparer<Direction>.ToInt(dir) + offset) % 4);
+ }
+
+ public void MoveNext()
+ {
+ this.PlayerCoord = this.GoWithDirection(this.PlayerCoord, this.PlayerMoveDirection);
+ bool flag = this.StaticInfo.FindMapNode(this.PlayerCoord) == null;
+ if (flag)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog("SuperRisk: why do I go to a null place??", null, null, null, null, null);
+ }
+ }
+
+ protected Coordinate GoWithDirection(Coordinate c, Direction dir)
+ {
+ Coordinate result;
+ switch (dir)
+ {
+ case Direction.Right:
+ result = new Coordinate(c.x + 1, c.y);
+ break;
+ case Direction.Down:
+ result = new Coordinate(c.x, c.y + 1);
+ break;
+ case Direction.Left:
+ result = new Coordinate(c.x - 1, c.y);
+ break;
+ case Direction.Up:
+ result = new Coordinate(c.x, c.y - 1);
+ break;
+ default:
+ result = new Coordinate(-1, -1);
+ break;
+ }
+ return result;
+ }
+
+ public bool GetNodeGroup(Coordinate c, out char group)
+ {
+ XSuperRiskMapNode xsuperRiskMapNode = this.StaticInfo.FindMapNode(c);
+ bool flag = xsuperRiskMapNode != null;
+ bool result;
+ if (flag)
+ {
+ group = xsuperRiskMapNode.group;
+ result = true;
+ }
+ else
+ {
+ group = ' ';
+ result = false;
+ }
+ return result;
+ }
+ }
+}