blob: cd5b2bceeee81760fde905aa1d0ad14a29b8fa08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
using System;
using System.Collections.Generic;
using System.IO;
using XUtliPoolLib;
namespace XMainClient
{
internal class XSuperRiskMapMgr : XSingleton<XSuperRiskMapMgr>
{
private Dictionary<string, XSuperRiskMapStaticInfo> AllMapStaticInfo = new Dictionary<string, XSuperRiskMapStaticInfo>();
public XSuperRiskMap CurrentMap = new XSuperRiskMap();
public void Clear()
{
this.CurrentMap.Clear();
}
public void SetCurrentMap(string MapID)
{
this.CurrentMap.Clear();
bool flag = this.AllMapStaticInfo.ContainsKey(MapID);
if (flag)
{
this.CurrentMap.StaticInfo = this.AllMapStaticInfo[MapID];
}
else
{
XSuperRiskMapStaticInfo xsuperRiskMapStaticInfo = this.ReadMapConfig(MapID);
bool flag2 = xsuperRiskMapStaticInfo != null;
if (flag2)
{
this.AllMapStaticInfo.Add(MapID, xsuperRiskMapStaticInfo);
this.CurrentMap.StaticInfo = this.AllMapStaticInfo[MapID];
}
}
}
public void SetPlayerPosDirection(int x, int y, int dir)
{
this.CurrentMap.PlayerCoord = new Coordinate(x, y);
this.CurrentMap.PlayerMoveDirection = (Direction)dir;
}
protected XSuperRiskMapStaticInfo ReadMapConfig(string MapID)
{
XSuperRiskMapStaticInfo xsuperRiskMapStaticInfo = new XSuperRiskMapStaticInfo();
Stream stream = XSingleton<XResourceLoaderMgr>.singleton.ReadText("Table/SuperRisk/" + MapID, ".txt", true);
StreamReader streamReader = new StreamReader(stream);
int num = 0;
int width = 0;
string text;
while ((text = streamReader.ReadLine()) != null)
{
width = text.Length;
for (int i = 0; i < text.Length; i++)
{
bool flag = text[i] == '0' || text[i] == ' ';
if (!flag)
{
XSuperRiskMapNode xsuperRiskMapNode = new XSuperRiskMapNode
{
coord = new Coordinate(i, num)
};
xsuperRiskMapNode.group = text[i];
bool flag2 = i > 0;
if (flag2)
{
XSuperRiskMapNode xsuperRiskMapNode2 = xsuperRiskMapStaticInfo.FindMapNode(new Coordinate(i - 1, num));
bool flag3 = xsuperRiskMapNode2 != null;
if (flag3)
{
xsuperRiskMapNode2.neighbour[0] = xsuperRiskMapNode;
xsuperRiskMapNode.neighbour[2] = xsuperRiskMapNode2;
}
}
bool flag4 = num > 0;
if (flag4)
{
XSuperRiskMapNode xsuperRiskMapNode3 = xsuperRiskMapStaticInfo.FindMapNode(new Coordinate(i, num - 1));
bool flag5 = xsuperRiskMapNode3 != null;
if (flag5)
{
xsuperRiskMapNode3.neighbour[1] = xsuperRiskMapNode;
xsuperRiskMapNode.neighbour[3] = xsuperRiskMapNode3;
}
}
xsuperRiskMapStaticInfo.Nodes.Add(xsuperRiskMapNode);
}
}
num++;
}
xsuperRiskMapStaticInfo.Width = width;
xsuperRiskMapStaticInfo.Height = num;
XSingleton<XResourceLoaderMgr>.singleton.ClearStream(stream);
return xsuperRiskMapStaticInfo;
}
}
}
|