本文整理汇总了C#中Sim.tileAt方法的典型用法代码示例。如果您正苦于以下问题:C# Sim.tileAt方法的具体用法?C# Sim.tileAt怎么用?C# Sim.tileAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sim
的用法示例。
在下文中一共展示了Sim.tileAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: scnOpen
//.........这里部分代码省略.........
// unit types
jsonA = jsonArray(json, "unitTypes");
if (jsonA != null) {
foreach (Hashtable jsonO in jsonA) {
Hashtable jsonO2 = jsonObject(jsonO, "rscCost");
Hashtable jsonO3 = jsonObject(jsonO, "rscCollectRate");
UnitType unitT = new UnitType {
id = g.unitT.Length,
name = jsonString(jsonO, "name"),
imgPath = jsonString(jsonO, "imgPath"),
imgOffset = jsonFPVector (jsonO, "imgOffset"),
imgHalfHeight = jsonFP (jsonO, "imgHalfHeight"),
maxHealth = (int)jsonDouble(jsonO, "maxHealth"),
speed = jsonFP(jsonO, "speed"),
reload = (long)jsonDouble(jsonO, "reload"),
range = jsonFP(jsonO, "range"),
tightFormationSpacing = jsonFP(jsonO, "tightFormationSpacing"),
seePrecedence = (int)jsonDouble (jsonO, "seePrecedence"),
makeUnitMinDist = jsonFP(jsonO, "makeUnitMinDist"),
makeUnitMaxDist = jsonFP(jsonO, "makeUnitMaxDist"),
makePathMinDist = jsonFP(jsonO, "makePathMinDist"),
makePathMaxDist = jsonFP(jsonO, "makePathMaxDist"),
rscCost = new long[g.rscNames.Length],
rscCollectRate = new long[g.rscNames.Length],
};
unitT.selMinPos = jsonFPVector (jsonO, "selMinPos", new FP.Vector(unitT.imgOffset.x - unitT.imgHalfHeight, unitT.imgOffset.y - unitT.imgHalfHeight));
unitT.selMaxPos = jsonFPVector (jsonO, "selMaxPos", new FP.Vector(unitT.imgOffset.x + unitT.imgHalfHeight, unitT.imgOffset.y + unitT.imgHalfHeight));
unitT.laserPos = jsonFPVector (jsonO, "laserPos", unitT.imgOffset);
if (unitT.speed > g.maxSpeed) g.maxSpeed = unitT.speed;
for (int i = 0; i < g.rscNames.Length; i++) {
unitT.rscCost[i] = (jsonO2 != null) ? jsonFP(jsonO2, g.rscNames[i]) : 0;
unitT.rscCollectRate[i] = (jsonO3 != null) ? jsonFP(jsonO3, g.rscNames[i]) : 0;
}
Array.Resize(ref g.unitT, g.unitT.Length + 1);
g.unitT[g.unitT.Length - 1] = unitT;
}
foreach (Hashtable jsonO in jsonA) {
Hashtable jsonO2 = jsonObject(jsonO, "damage");
ArrayList jsonA2 = jsonArray(jsonO, "canMake");
UnitType unitT = g.unitTypeNamed(jsonString(jsonO, "name"));
unitT.makeOnUnitT = g.unitTypeNamed(jsonString(jsonO, "makeOnUnitT"));
unitT.damage = new int[g.unitT.Length];
for (int i = 0; i < g.unitT.Length; i++) {
unitT.damage[i] = (jsonO2 != null) ? (int)jsonDouble(jsonO2, g.unitT[i].name) : 0;
}
unitT.canMake = new bool[g.unitT.Length];
for (int i = 0; i < g.unitT.Length; i++) {
unitT.canMake[i] = false;
}
if (jsonA2 != null) {
foreach (string s in jsonA2) {
if (g.unitTypeNamed(s) != null) {
unitT.canMake[g.unitTypeNamed(s).id] = true;
}
}
}
}
}
// tiles
g.tiles = new Tile[g.tileLen(), g.tileLen()];
for (int i = 0; i < g.tileLen(); i++) {
for (int j = 0; j < g.tileLen(); j++) {
g.tiles[i, j] = new Tile(g, i, j);
}
}
foreach (Player player in g.players) {
if (player.mapHack) {
player.mapHack = false;
new MapHackCmdEvt(g.timeSim, player.id, true).apply (g);
}
}
// units
jsonA = jsonArray(json, "units");
if (jsonA != null) {
foreach (Hashtable jsonO in jsonA) {
if (g.playerNamed(jsonString(jsonO, "player")) != null) {
ArrayList jsonA2 = jsonArray (jsonO, "types");
List<Unit> units = new List<Unit>();
if (jsonA2 != null) {
foreach (string type in jsonA2) {
if (g.unitTypeNamed(type) != null) {
Unit unit = new Unit(g, g.units.Count, g.unitTypeNamed(type), g.playerNamed(jsonString(jsonO, "player")));
g.units.Add (unit);
units.Add (unit);
}
}
}
FP.Vector startPos = jsonFPVector(jsonO, "startPos", new FP.Vector((long)(UnityEngine.Random.value * g.mapSize), (long)(UnityEngine.Random.value * g.mapSize)));
g.paths.Add (new Path(g, g.paths.Count, units, (long)jsonDouble(jsonO, "startTime"), startPos, false, int.MaxValue, g.tileAt(startPos).x, g.tileAt(startPos).y));
}
}
}
g.nRootPaths = g.paths.Count;
// start game
loadUI ();
g.timeGame = 0;
timeSpeedChg = (long)(Time.time * 1000) - 1000;
timeNow = (long)(Time.time * 1000);
return true;
}