本文整理汇总了C#中Scene.getTrajectory方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.getTrajectory方法的具体用法?C# Scene.getTrajectory怎么用?C# Scene.getTrajectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scene
的用法示例。
在下文中一共展示了Scene.getTrajectory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fixSingleNode
/** If a trajectory has only one node, the player is not displayed. To fix that situation, the node is duplicated with a slightly different location.
* Both old and new nodes are linked through a side.
*
* @param scene
*/
public static void fixSingleNode(Scene scene)
{
Trajectory trajectory = scene.getTrajectory();
if (trajectory != null)
{
if (trajectory.getNodes().Count == 1)
{
Trajectory.Node node1 = trajectory.getNodes()[0];
trajectory.addNode(node1.getID() + "Dupl", node1.getX() + 1, node1.getY(), node1.getScale());
trajectory.addSide(node1.getID(), node1.getID() + "Dupl", 1);
}
}
}
示例2: fixMissingNodes
/**
* Checks consistency between nodes and references in sides. If a node is referenced to but does not exist, it is created on position 400,300.
* @param scene
*/
private static void fixMissingNodes(Scene scene)
{
Trajectory trajectory = scene.getTrajectory();
if (trajectory != null)
{
List<string> nodeIds = new List<string>();
// Put all node ids referenced in sides in a single array list
foreach (Trajectory.Side side in trajectory.getSides())
{
if (!nodeIds.Contains(side.getIDStart()))
{
nodeIds.Add(side.getIDStart());
}
if (!nodeIds.Contains(side.getIDEnd()))
{
nodeIds.Add(side.getIDEnd());
}
}
// Remove all ids belonging to an existing nodes. The result is a list containing the strings of
// all missing nodes
foreach (Trajectory.Node node in trajectory.getNodes())
{
if (nodeIds.Contains(node.getID()))
{
nodeIds.Remove(node.getID());
}
}
// Add all missing nodes to the trajectory
foreach (string missingNodeId in nodeIds)
{
if (trajectory.getNodes().Count > 0)
{
trajectory.addNode(missingNodeId, 400, 300, 1);
}
}
}
}
示例3: fixDuplicateNodes
/**
* Checks pairs of nodes with duplicate ids. One of the nodes is removed.
* @param nodes
*/
private static void fixDuplicateNodes(Scene scene)
{
Trajectory trajectory = scene.getTrajectory();
if (trajectory != null)
{
// Iterate through nodes.
for (int i = 0; i < trajectory.getNodes().Count; i++)
{
Trajectory.Node node1 = trajectory.getNodes()[i];
for (int j = 0; j < trajectory.getNodes().Count; j++)
{
Trajectory.Node node2 = trajectory.getNodes()[j];
if (i != j && node1.getID().Equals(node2.getID()))
{
trajectory.getNodes().RemoveAt(j);
i--; j--;
}
}
}
}
}
示例4: fixNodesWithSameLocation
/**
* Ensures that all nodes in a trajectory have a different location. If two nodes are found in the same position, first's x coordinate
* is incremented by 1 px. This is important as nodes with equal position makes the trajectory algorithm to crash.
* @param scene
*/
private static void fixNodesWithSameLocation(Scene scene)
{
Trajectory trajectory = scene.getTrajectory();
if (trajectory != null)
{
// Iterate through nodes.
for (int i = 0; i < trajectory.getNodes().Count; i++)
{
Trajectory.Node node1 = trajectory.getNodes()[i];
for (int j = 0; j < trajectory.getNodes().Count; j++)
{
Trajectory.Node node2 = trajectory.getNodes()[j];
if (i != j && node1.getX() == node2.getX() && node1.getY() == node2.getY())
{
node1.setValues(node1.getX() + 1, node1.getY(), node1.getScale());
j = 0;
}
}
}
}
}