本文整理汇总了C#中Platform.SetPatrol方法的典型用法代码示例。如果您正苦于以下问题:C# Platform.SetPatrol方法的具体用法?C# Platform.SetPatrol怎么用?C# Platform.SetPatrol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Platform
的用法示例。
在下文中一共展示了Platform.SetPatrol方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: readPlatforms
/// <summary>
/// Read all the platform objects from the currentReadTarget file
/// </summary>
/// <returns></returns>
public static LinkedList<Platform> readPlatforms()
{
const int platformObjSize = 8;
string content;
if (currentReadTarget == null)
throw new Exception("File read target not set. LevelParser.readPlatforms");
using (System.Xml.XmlReader r = System.Xml.XmlReader.Create(currentReadTarget))
{
r.MoveToContent();
r.ReadToFollowing("objects");
r.ReadToDescendant("platforms");
content = r.ReadElementContentAsString();
r.Close();
}
LinkedList<Platform> platforms = new LinkedList<Platform>();
String[] PlatformString = CleanUp(content);
for (int i = 0; i < PlatformString.Length / platformObjSize; i++)
{
//create the rectangle for this platform
int[] rectangleValues = getNumbers(PlatformString[i*platformObjSize].Substring(4));
Rectangle r = new Rectangle(rectangleValues[0], rectangleValues[1], rectangleValues[2], rectangleValues[3]);
//determine whether or not this platform has gravitic properties
bool hasGravity = PlatformString[i*platformObjSize + 1].Equals("yesgravity", StringComparison.CurrentCultureIgnoreCase);
// check hazard status
bool isHazardous = PlatformString[i * platformObjSize + 3].Equals("hazardous", StringComparison.CurrentCultureIgnoreCase);
bool goThrough = PlatformString[i*platformObjSize+6].Equals("through", StringComparison.CurrentCultureIgnoreCase);
bool isTiled = PlatformString[i*platformObjSize+7].Equals("tile", StringComparison.CurrentCultureIgnoreCase);
bool isAnimated = PlatformString[i*platformObjSize+4].Contains("hplatform");
// parse texture
string texName = "Interactive/" + PlatformString[i * platformObjSize + 4];
Platform final = new Platform(r, texName, isHazardous, isAnimated, hasGravity, goThrough, isTiled);
//get the patrol values for this platform (out of parse order because it has to be created after the platform object)
if (!PlatformString[i * platformObjSize + 2].Equals("nopatrol"))
{
int[] patrolValues = getNumbers(PlatformString[i * platformObjSize + 2].Substring(4));
PatrolModel p = new PatrolModel();
for (int j = 0; j < patrolValues.Length / 3; j++)
{
p.addVector(new Vector2((float)patrolValues[j * 3], (float)patrolValues[j * 3 + 1]), patrolValues[j * 3 + 2]);
}
final.SetPatrol(p);
}
// read trigger
if (!PlatformString[i * platformObjSize + 5].Equals("notrigger"))
{
int [] triggerValues = getNumbers(PlatformString[i*platformObjSize+5].Substring(8));
for (int j = 0; j < triggerValues.Length; j+=4)
{
final.addTrigger(new Trigger(new Rectangle(triggerValues[j],triggerValues[j+1],triggerValues[j+2],triggerValues[j+3]), final));
}
}
platforms.AddFirst(final);
}
return platforms;
}