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


C# Sim.deleteOtherPaths方法代码示例

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


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

示例1: apply

 public override void apply(Sim g)
 {
     List<SegmentUnit> units = new List<SegmentUnit>();
     // convert paths list into valid deleteOtherPaths() argument (this is a bit ugly)
     foreach (KeyValuePair<int, int[]> path in paths) {
         Segment segment = g.paths[path.Key].segmentWhen (timeCmd);
         if (segment != null) {
             foreach (int unit in path.Value) {
                 units.Add (new SegmentUnit(segment, g.units[unit]));
             }
         }
     }
     g.deleteOtherPaths (units, true, false);
 }
开发者ID:ad510,项目名称:plausible-deniability,代码行数:14,代码来源:DeleteOtherPathsCmdEvt.cs

示例2: apply


//.........这里部分代码省略.........
                                 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
                 foreach (Unit unit in path.segmentWhen (time).units) {
                     unit.addWaypoint (time, path);
                 }
             }
             if (tXPrev >= 0 && tXPrev < g.tileLen() && tYPrev >= 0 && tYPrev < g.tileLen()) {
                 // if this path moved out of another player's direct visibility, remove that player's visibility here
                 if (path.tileX >= 0 && path.tileX < g.tileLen() && path.tileY >= 0 && path.tileY < g.tileLen()) {
                     if (!path.player.immutable) {
                         foreach (Player player in g.players) {
                             if (player != path.player && g.tiles[tXPrev, tYPrev].playerDirectVisLatest(player) && !g.tiles[path.tileX, path.tileY].playerDirectVisLatest(player)) {
                                 for (int tX = Math.Max(0, path.tileX - 1); tX <= Math.Min(g.tileLen() - 1, path.tileX + 1); tX++) {
                                     for (int tY = Math.Max(0, path.tileY - 1); tY <= Math.Min(g.tileLen() - 1, path.tileY + 1); tY++) {
                                         // ISSUE #30: perhaps use more accurate time at tiles other than (path.tileX, path.tileY)
                                         g.tiles[tX, tY].playerVisRemove(player, time);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // if this player can no longer directly see another player's path, remove this player's visibility there
                 foreach (int i in g.tiles[tXPrev, tYPrev].pathVis.Keys) {
                     Tile iTile = g.paths[i].tileWhen (time);
                     if (g.paths[i].player != path.player && !g.paths[i].player.immutable && g.paths[i].segments.Last ().units.Count > 0
                         && g.inVis(iTile.x - tXPrev, iTile.y - tYPrev) && !iTile.playerDirectVisLatest(path.player)) {
                         for (int tX = Math.Max(0, iTile.x - 1); tX <= Math.Min(g.tileLen() - 1, iTile.x + 1); tX++) {
                             for (int tY = Math.Max(0, iTile.y - 1); tY <= Math.Min(g.tileLen() - 1, iTile.y + 1); tY++) {
                                 // ISSUE #30: perhaps use more accurate time at tiles other than (paths[i].tileX, paths[i].tileY)
                                 g.tiles[tX, tY].playerVisRemove(path.player, time);
                             }
                         }
                     }
                 }
             }
         }
     }
     if (anyoneMoved) {
         // update which paths are known to be unseen
         foreach (Path path in g.paths) {
             if (path.tileX >= 0 && path.tileX < g.tileLen() && path.tileY >= 0 && path.tileY < g.tileLen()) {
                 if (!path.segments.Last ().unseen && g.tiles[path.tileX, path.tileY].exclusiveLatest(path.player)) {
                     // path is now unseen
                     Segment segment = path.insertSegment(time);
                     segment.unseen = true;
                     foreach (Unit unit in segment.units) {
                         unit.addWaypoint (time, path);
                     }
                 } else if (path.segments.Last ().unseen && !g.tiles[path.tileX, path.tileY].exclusiveLatest(path.player)) {
                     // path is now seen
                     Segment segment = path.insertSegment(time);
                     foreach (Unit unit in segment.units.OrderByDescending (u => u.type.seePrecedence)) {
                         if (segment.units.Count <= path.nSeeUnits) break;
                         new SegmentUnit(segment, unit).delete ();
                     }
                     path.nSeeUnits = int.MaxValue;
                     if (!g.deleteOtherPaths (segment.segmentUnits(), false, true)) throw new SystemException("failed to delete other paths of seen path");
                     segment.unseen = false;
                     foreach (Unit unit in segment.units) {
                         unit.clearWaypoints (time);
                     }
                 }
             }
         }
     }
     g.events.addEvt (new TileUpdateEvt(time + g.tileInterval));
 }
开发者ID:ad510,项目名称:plausible-deniability,代码行数:101,代码来源:TileUpdateEvt.cs


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