本文整理汇总了C#中Path.posWhen方法的典型用法代码示例。如果您正苦于以下问题:C# Path.posWhen方法的具体用法?C# Path.posWhen怎么用?C# Path.posWhen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.posWhen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addWaypoint
public void addWaypoint(long time, Path path)
{
if (Sim.enableNonLivePaths && type.speed > 0) {
if (!new SegmentUnit(path.segmentWhen(time), this).canBeUnambiguousParent(time)) time++;
Tile tile = path.tileWhen (time);
if (!Waypoint.active (tile.waypointLatest (this))) {
List<UnitSelection> start = new List<UnitSelection> { new UnitSelection(path, this, time) };
SegmentUnit prev = start[0].segmentUnit();
do {
// remember segments that unit was previously on in case unit is later removed from them
SegmentUnit cur = prev;
prev = cur.prev ().FirstOrDefault ();
if (prev.g == null || prev.segment.path != cur.segment.path || !prev.segment.unseen) {
start.Add (new UnitSelection(cur.segment.path, this, cur.segment.timeStart));
}
} while (prev.g != null && prev.segment.unseen);
g.events.addEvt (new WaypointAddEvt(time + (tile.centerPos() - path.posWhen(time)).length () / type.speed,
this, tile, null, start));
}
}
}
示例2: pathDrawPos
// methods above involve commanding selected units
/// <summary>
/// sets pos to where base of path should be drawn at, and returns whether it should be drawn
/// </summary>
private bool pathDrawPos(Path path, ref Vector3 pos)
{
if (g.timeGame < path.moves[0].timeStart) return false;
if (selPlayer != path.player) {
if (path.timeSimPast != long.MaxValue) return false;
if (!path.tileWhen (g.timeGame).playerVisWhen(selPlayer, g.timeGame)) return false;
}
pos = simToDrawPos(path.posWhen(g.timeGame), unitDepth);
return true;
}
示例3: makeUnitMovePos
/// <summary>
/// returns where new unit of specified type can move out of the way after specified path makes it
/// </summary>
/// <remarks>chooses a random location between makeUnitMinDist and makeUnitMaxDist away from path</remarks>
private FP.Vector makeUnitMovePos(long time, Path path, UnitType type)
{
FP.Vector ret;
do {
ret = new FP.Vector((long)((UnityEngine.Random.value - 0.5) * type.makeUnitMaxDist * 2),
(long)((UnityEngine.Random.value - 0.5) * type.makeUnitMaxDist * 2));
} while (ret.lengthSq() < type.makeUnitMinDist * type.makeUnitMinDist
|| ret.lengthSq() > type.makeUnitMaxDist * type.makeUnitMaxDist);
return ret + path.posWhen(time);
}
示例4: makePathMovePos
/// <summary>
/// returns where new path with specified units can move out of the way after specified path makes it
/// </summary>
/// <remarks>chooses a random location between makePathMinDist() and makePathMaxDist() away from path</remarks>
private FP.Vector makePathMovePos(long time, Path path, List<Unit> units)
{
long makePathMinDist = path.makePathMinDist (time, units);
long makePathMaxDist = path.makePathMaxDist (time, units);
FP.Vector ret;
do {
ret = new FP.Vector((long)((UnityEngine.Random.value - 0.5) * makePathMaxDist * 2),
(long)((UnityEngine.Random.value - 0.5) * makePathMaxDist * 2));
} while (ret.lengthSq() < makePathMinDist * makePathMinDist
|| ret.lengthSq() > makePathMaxDist * makePathMaxDist);
return ret + path.posWhen(time);
}