本文整理汇总了C#中Unit.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.Select方法的具体用法?C# Unit.Select怎么用?C# Unit.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.Select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectUnit
// Selecting Units
public void SelectUnit(Unit unit)
{
// Select Target?
if (CurrentUnit != null && CurrentUnit.IsWaitingForActionAccept() && CurrentUnit.InAttackRangeList(unit))
{
if (CurrentUnit.GetAttackTarget() == unit)
{
CurrentUnit.AcceptAttack();
UnselectCurrentUnit();
}
else
CurrentUnit.SetAttackTarget(unit);
return;
}
// Select Friendly Unit
if (Game.CurrentTeam != unit.Team || (CurrentUnit != null && CurrentUnit != unit) || unit.HasMoved())
return;
UnselectCurrentBuilding();
UnselectCurrentUnit();
CurrentUnit = unit;
SelectTile(CurrentUnit.TilePosition());
CurrentUnit.Select();
}
示例2: SetX_Unit
public void SetX_Unit(Unit xUnit, string defaultXUnit)
{
this.XUnit = xUnit; DefaultXUnit = defaultXUnit; xUnit.Select(defaultXUnit);
}
示例3: XliffElement_SelectElement
public void XliffElement_SelectElement()
{
File file;
Group group;
Unit unit;
Segment segment;
Ignorable ignorable;
TestXliffElement element;
element = new TestXliffElement();
element.Document = new XliffDocument();
Console.WriteLine("Test with no items.");
Assert.IsNull(element.CallSelectElement("#/file"));
Console.WriteLine("Test with file items.");
file = new File("file");
element.Document.Files.Add(file);
Assert.AreEqual(file, element.CallSelectElement("#/f=file"));
Console.WriteLine("Test with relative path to file item.");
Assert.AreEqual(file, element.Document.Select("#f=file"));
Console.WriteLine("Test with many items.");
group = new Group("group");
file.Containers.Add(new Group());
file.Containers.Add(group);
unit = new Unit("unit");
group.Containers.Add(unit);
group.Containers.Add(new Group());
group.Containers.Add(new Unit());
Assert.AreEqual(unit, element.CallSelectElement("#/f=file/g=group/u=unit"));
Console.WriteLine("Test with segment.");
segment = new Segment("segment");
unit.Resources.Add(segment);
Assert.AreEqual(segment, element.CallSelectElement("#/f=file/g=group/u=unit/segment"));
Console.WriteLine("Test with relative path to segment.");
Assert.AreEqual(segment, group.Select("#u=unit/segment"));
Console.WriteLine("Test with invalid relative path to segment.");
try
{
group.Select("u=unit/segment");
Assert.Fail("Expected ArgumentException to be thrown.");
}
catch (ArgumentException)
{
}
Console.WriteLine("Test with ignorable.");
ignorable = new Ignorable("ignorable");
unit.Resources.Add(ignorable);
Assert.AreEqual(ignorable, element.CallSelectElement("#/f=file/g=group/u=unit/ignorable"));
Console.WriteLine("Test with data.");
unit.OriginalData = new OriginalData();
unit.OriginalData.AddData("data", "text");
Assert.AreEqual(unit.OriginalData.DataElements[0],
element.CallSelectElement("#/f=file/g=group/u=unit/d=data"));
Console.WriteLine("Test with note.");
file.AddNote("note").Id = "note";
Assert.AreEqual(file.Notes[0], element.CallSelectElement("#/f=file/n=note"));
//
// This test should still work even though it's an invalid document.
//
Console.WriteLine("Test with duplicate names.");
element.Document.Files.Add(new File("file"));
Assert.AreEqual(file, element.CallSelectElement("#/f=file"), "Found wrong item.");
Console.WriteLine("Test with bogus names.");
Assert.IsNull(element.CallSelectElement("#/f=foo"), "Item should not have been found.");
Console.WriteLine("Test with bogus path.");
Assert.IsNull(element.CallSelectElement("#/blah"), "Item should not have been found.");
Console.WriteLine("Test with empty string.");
// This returns null because SelectElement is called directly which doesn't search for the leading '#'.
Assert.IsNull(element.CallSelectElement(String.Empty));
Console.WriteLine("Test with empty path.");
Assert.IsNull(element.CallSelectElement("/"), "Item should not have been found.");
Console.WriteLine("Test with inline element.");
segment.Source = new Source();
segment.Source.Text.Add(new MarkedSpan("ms1"));
Assert.AreEqual(segment.Source.Text[0],
element.CallSelectElement("#/f=file/g=group/u=unit/ms1"),
"Item should have been found.");
Console.WriteLine("Test with inline element.");
segment.Target = new Target();
segment.Target.Text.Add(new MarkedSpan("ms2"));
Assert.AreEqual(segment.Target.Text[0],
element.CallSelectElement("#/f=file/g=group/u=unit/t=ms2"),
//.........这里部分代码省略.........
示例4: SetUnit
/* PUBLIC METHODS */
public void SetUnit(Unit unit, string defaultUnit)
{
Unit = unit; DefaultUnit = defaultUnit; Unit.Select(DefaultUnit);
}