本文整理汇总了C#中Sim.playerNamed方法的典型用法代码示例。如果您正苦于以下问题:C# Sim.playerNamed方法的具体用法?C# Sim.playerNamed怎么用?C# Sim.playerNamed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sim
的用法示例。
在下文中一共展示了Sim.playerNamed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: scnOpen
/// <summary>
/// loads scenario from json file and returns whether successful
/// </summary>
private bool scnOpen(string path, int user, bool multiplayer)
{
Hashtable json;
ArrayList jsonA;
bool b = false;
// ISSUE #17: in multiplayer games, host should load file & send data to other players, otherwise json double parsing may not match
if (!File.Exists(path)) return false;
json = (Hashtable)Procurios.Public.JSON.JsonDecode(File.ReadAllText(path), ref b);
if (!b) return false;
// base scenario
g = new Sim {
// not stored in scenario file
selUser = user,
networkView = multiplayer ? networkView : null,
events = new List<SimEvt>(),
cmdPending = new List<SimEvt>(),
checksum = 0,
synced = true,
timeSim = 0,
timeUpdateEvt = long.MinValue,
maxSpeed = 0,
deleteLines = new List<MoveLine>(),
keepLines = new List<MoveLine>(),
alternatePaths = new List<Path>(),
// stored in scenario file
mapSize = jsonFP(json, "mapSize"),
updateInterval = (long)jsonDouble(json, "updateInterval"),
tileInterval = (long)jsonDouble (json, "tileInterval"),
visRadius = jsonFP(json, "visRadius"),
camSpeed = jsonFP(json, "camSpeed"),
zoom = (float)jsonDouble(json, "zoom"),
zoomMin = (float)jsonDouble(json, "zoomMin"),
zoomMax = (float)jsonDouble(json, "zoomMax"),
zoomSpeed = (float)jsonDouble (json, "zoomSpeed"),
zoomMouseWheelSpeed = (float)jsonDouble (json, "zoomMouseWheelSpeed"),
uiBarHeight = (float)jsonDouble (json, "uiBarHeight"),
healthBarSize = jsonVector2(json, "healthBarSize"),
healthBarYOffset = (float)jsonDouble(json, "healthBarYOffset"),
stackRadius = jsonFP(json, "stackRadius"),
stackRotSpeed = (float)jsonDouble(json, "stackRotSpeed"),
backCol = jsonColor(json, "backCol"),
borderCol = jsonColor(json, "borderCol"),
noVisCol = jsonColor(json, "noVisCol"),
playerVisCol = jsonColor(json, "playerVisCol"),
unitVisCol = jsonColor(json, "unitVisCol"),
exclusiveCol = jsonColor(json, "exclusiveCol"),
waypointCol = jsonColor (json, "waypointCol"),
pathCol = jsonColor(json, "pathCol"),
healthBarBackCol = jsonColor(json, "healthBarBackCol"),
healthBarFullCol = jsonColor(json, "healthBarFullCol"),
healthBarEmptyCol = jsonColor(json, "healthBarEmptyCol"),
rscNames = new string[0],
players = new Player[0],
unitT = new UnitType[0],
units = new List<Unit>(),
paths = new List<Path>(),
};
if (g.updateInterval > 0) g.events.addEvt(new UpdateEvt(0));
if (g.tileInterval > 0) g.events.addEvt (new TileUpdateEvt(0));
g.camPos = jsonFPVector(json, "camPos", new FP.Vector(g.mapSize / 2, g.mapSize / 2));
// resources
jsonA = jsonArray(json, "resources");
if (jsonA != null) {
foreach (string rscName in jsonA) {
Array.Resize(ref g.rscNames, g.rscNames.Length + 1);
g.rscNames[g.rscNames.Length - 1] = rscName;
}
}
// players
jsonA = jsonArray(json, "players");
if (jsonA != null) {
foreach (Hashtable jsonO in jsonA) {
Hashtable jsonO2 = jsonObject(jsonO, "startRsc");
Player player = new Player {
g = this.g,
id = g.players.Length,
name = jsonString(jsonO, "name"),
isUser = jsonBool(jsonO, "isUser"),
user = (int)jsonDouble(jsonO, "user"),
populationLimit = (int)jsonDouble (jsonO, "populationLimit", -1),
startRsc = new long[g.rscNames.Length],
mapHack = jsonBool (jsonO, "mapHack"),
hasNonLivePaths = false,
timeGoLiveFailedAttempt = long.MinValue,
goLiveStackPaths = new Dictionary<int, HashSet<Path>>(),
unseenTiles = g.tileLen () * g.tileLen (),
};
for (int i = 0; i < g.rscNames.Length; i++) {
player.startRsc[i] = (jsonO2 != null) ? jsonFP(jsonO2, g.rscNames[i]) : 0;
}
Array.Resize(ref g.players, g.players.Length + 1);
g.players[g.players.Length - 1] = player;
}
foreach (Hashtable jsonO in jsonA) {
ArrayList jsonA2 = jsonArray(jsonO, "canAttack");
Player player = g.playerNamed(jsonString(jsonO, "name"));
player.canAttack = new bool[g.players.Length];
//.........这里部分代码省略.........