当前位置: 首页>>代码示例>>C#>>正文


C# Sim.inVis方法代码示例

本文整理汇总了C#中Sim.inVis方法的典型用法代码示例。如果您正苦于以下问题:C# Sim.inVis方法的具体用法?C# Sim.inVis怎么用?C# Sim.inVis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sim的用法示例。


在下文中一共展示了Sim.inVis方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: apply

 public override void apply(Sim g)
 {
     if (player.mapHack) return;
     // remove visibility from specified tiles
     for (int i = 0; i < tiles.Count; i++) {
         if (tiles[i].playerVisLatest(player) && !tiles[i].playerDirectVisLatest(player)) {
             tiles[i].playerVis[player.id].Add(time);
             player.unseenTiles++;
         } else {
             tiles[i] = null;
         }
     }
     // add events to remove visibility from surrounding tiles
     foreach (Tile tile in tiles) {
         if (tile != null) {
             for (int tX = Math.Max(0, tile.x - 1); tX <= Math.Min(g.tileLen() - 1, tile.x + 1); tX++) {
                 for (int tY = Math.Max(0, tile.y - 1); tY <= Math.Min(g.tileLen() - 1, tile.y + 1); tY++) {
                     if ((tX != tile.x || tY != tile.y) && g.tiles[tX, tY].playerVisLatest(player)) {
                         // ISSUE #29: lose visibility in a circle instead of a square
                         g.tiles[tX, tY].playerVisRemove(player, time + (1 << FP.precision) / g.maxSpeed);
                     }
                 }
             }
         }
     }
     if (Sim.enableNonLivePaths) {
         // check if a tile stopped being exclusive to this player, or became exclusive to another player
         Tile prevTile = null;
         foreach (Tile tile in tiles) {
             if (tile != null) {
                 int tXMax = Math.Min(g.tileLen() - 1, tile.x + g.tileVisRadius());
                 int tYMax = Math.Min(g.tileLen() - 1, tile.y + g.tileVisRadius());
                 for (int tX = Math.Max(0, tile.x - g.tileVisRadius()); tX <= tXMax; tX++) {
                     for (int tY = Math.Max(0, tile.y - g.tileVisRadius()); tY <= tYMax; tY++) {
                         if (g.inVis(tX - tile.x, tY - tile.y) && (prevTile == null || !g.inVis(tX - prevTile.x, tY - prevTile.y))) {
                             foreach (Player player2 in g.players) {
                                 if (player2 == player && g.tiles[tX, tY].exclusiveLatest(player2)) {
                                     g.tiles[tX, tY].exclusiveRemove(player2, time);
                                 } else if (player2 != player && !g.tiles[tX, tY].exclusiveLatest(player2) && g.tiles[tX, tY].calcExclusive(player2)) {
                                     g.tiles[tX, tY].exclusiveAdd(player2, time);
                                 }
                             }
                         }
                     }
                 }
                 prevTile = tile;
             }
         }
     }
 }
开发者ID:ad510,项目名称:plausible-deniability,代码行数:50,代码来源:PlayerVisRemoveEvt.cs

示例2: apply

 public override void apply(Sim g)
 {
     bool anyoneMoved = false;
     foreach (Path path in g.paths) {
         int tXPrev, tYPrev;
         if (path.timeSimPast == long.MaxValue && path.tileX != Sim.offMap && path.updateTilePos(time, out tXPrev, out tYPrev)) {
             anyoneMoved = true;
             int exclusiveMinX = g.tileLen() - 1;
             int exclusiveMaxX = 0;
             int exclusiveMinY = g.tileLen() - 1;
             int exclusiveMaxY = 0;
             // add path to visibility tiles
             for (int tX = Math.Max (0, path.tileX - g.tileVisRadius()); tX <= Math.Min (g.tileLen () - 1, path.tileX + g.tileVisRadius()); tX++) {
                 for (int tY = Math.Max (0, path.tileY - g.tileVisRadius()); tY <= Math.Min (g.tileLen () - 1, path.tileY + g.tileVisRadius()); tY++) {
                     if (!g.inVis(tX - tXPrev, tY - tYPrev) && g.inVis(tX - path.tileX, tY - path.tileY)) {
                         if (!g.tiles[tX, tY].playerVisLatest(path.player)) {
                             // make tile visible to this player
                             g.tiles[tX, tY].playerVis[path.player.id].Add(time);
                             path.player.unseenTiles--;
                             if (Sim.enableNonLivePaths) {
                                 if (tX < exclusiveMinX) exclusiveMinX = tX;
                                 if (tX > exclusiveMaxX) exclusiveMaxX = tX;
                                 if (tY < exclusiveMinY) exclusiveMinY = tY;
                                 if (tY > exclusiveMaxY) exclusiveMaxY = tY;
                             }
                         }
                         // check if this tile stopped being exclusive to another player
                         if (Sim.enableNonLivePaths && !path.player.immutable) {
                             foreach (Player player in g.players) {
                                 if (player != path.player && g.tiles[tX, tY].exclusiveLatest(player)) {
                                     g.tiles[tX, tY].exclusiveRemove(player, time);
                                 }
                             }
                         }
                     }
                 }
             }
             // remove path from visibility tiles
             for (int tX = Math.Max (0, tXPrev - g.tileVisRadius()); tX <= Math.Min (g.tileLen () - 1, tXPrev + g.tileVisRadius()); tX++) {
                 for (int tY = Math.Max (0, tYPrev - g.tileVisRadius()); tY <= Math.Min (g.tileLen () - 1, tYPrev + g.tileVisRadius()); tY++) {
                     if (g.inVis(tX - tXPrev, tY - tYPrev) && !g.inVis(tX - path.tileX, tY - path.tileY)) {
                         // check if player can't directly see this tile anymore
                         if (g.tiles[tX, tY].playerVisLatest(path.player) && !g.tiles[tX, tY].playerDirectVisLatest(path.player)) {
                             long timePlayerVis = long.MaxValue;
                             // find lowest time that surrounding tiles lost visibility
                             for (int tX2 = Math.Max(0, tX - 1); tX2 <= Math.Min(g.tileLen() - 1, tX + 1); tX2++) {
                                 for (int tY2 = Math.Max(0, tY - 1); tY2 <= Math.Min(g.tileLen() - 1, tY + 1); tY2++) {
                                     if ((tX2 != tX || tY2 != tY) && !g.tiles[tX2, tY2].playerVisLatest(path.player)) {
                                         if (g.tiles[tX2, tY2].playerVis[path.player.id].Count == 0) {
                                             timePlayerVis = long.MinValue;
                                         } else if (g.tiles[tX2, tY2].playerVis[path.player.id].Last () < timePlayerVis) {
                                             timePlayerVis = g.tiles[tX2, tY2].playerVis[path.player.id].Last ();
                                         }
                                     }
                                 }
                             }
                             // if player can't see all neighboring tiles, they won't be able to tell if another player's unit moves into this tile
                             // so remove this tile's visibility for this player
                             if (timePlayerVis != long.MaxValue) {
                                 timePlayerVis = Math.Max(time, timePlayerVis + (1 << FP.precision) / g.maxSpeed); // ISSUE #29: lose visibility in a circle instead of a square
                                 g.tiles[tX, tY].playerVisRemove(path.player, timePlayerVis);
                             }
                         }
                         // check if this tile became exclusive to a player using map hack
                         if (Sim.enableNonLivePaths && !path.player.immutable) {
                             foreach (Player player in g.players) {
                                 if (player != path.player && player.mapHack && !g.tiles[tX, tY].exclusiveLatest (player) && g.tiles[tX, tY].calcExclusive (player)) {
                                     g.tiles[tX, tY].exclusiveAdd(player, time);
                                 }
                             }
                         }
                     }
                 }
             }
             if (Sim.enableNonLivePaths) {
                 // apply PlayerVisRemoveEvts that occur immediately
                 foreach (SimEvt evt in g.events) {
                     if (evt.time > time) break;
                     if (evt is PlayerVisRemoveEvt) {
                         PlayerVisRemoveEvt visEvt = evt as PlayerVisRemoveEvt;
                         if (visEvt.player == path.player) {
                             visEvt.apply (g);
                             g.events.Remove (evt);
                             break;
                         }
                     }
                 }
                 // check if tiles became exclusive to this player
                 exclusiveMinX = Math.Max(0, exclusiveMinX - g.tileVisRadius());
                 exclusiveMaxX = Math.Min(g.tileLen() - 1, exclusiveMaxX + g.tileVisRadius());
                 exclusiveMinY = Math.Max(0, exclusiveMinY - g.tileVisRadius());
                 exclusiveMaxY = Math.Min(g.tileLen() - 1, exclusiveMaxY + g.tileVisRadius());
                 for (int tX = exclusiveMinX; tX <= exclusiveMaxX; tX++) {
                     for (int tY = exclusiveMinY; tY <= exclusiveMaxY; tY++) {
                         if (!g.tiles[tX, tY].exclusiveLatest(path.player) && g.tiles[tX, tY].calcExclusive(path.player)) {
                             g.tiles[tX, tY].exclusiveAdd(path.player, time);
                         }
                     }
                 }
                 // add waypoints for units
//.........这里部分代码省略.........
开发者ID:ad510,项目名称:plausible-deniability,代码行数:101,代码来源:TileUpdateEvt.cs


注:本文中的Sim.inVis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。