本文整理汇总了C#中Urho.Node.AddComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Node.AddComponent方法的具体用法?C# Node.AddComponent怎么用?C# Node.AddComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Urho.Node
的用法示例。
在下文中一共展示了Node.AddComponent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowStartMenu
public async Task ShowStartMenu(bool gameOver)
{
var cache = Application.ResourceCache;
bigAircraft = Node.CreateChild();
var model = bigAircraft.CreateComponent<StaticModel>();
if (gameOver)
{
model.Model = cache.GetModel(Assets.Models.Enemy1);
model.SetMaterial(cache.GetMaterial(Assets.Materials.Enemy1).Clone(""));
bigAircraft.SetScale(0.3f);
bigAircraft.Rotate(new Quaternion(180, 90, 20), TransformSpace.Local);
}
else
{
model.Model = cache.GetModel(Assets.Models.Player);
model.SetMaterial(cache.GetMaterial(Assets.Materials.Player).Clone(""));
bigAircraft.SetScale(1f);
bigAircraft.Rotate(new Quaternion(0, 40, -50), TransformSpace.Local);
}
bigAircraft.Position = new Vector3(10, 2, 10);
bigAircraft.RunActions(new RepeatForever(new Sequence(new RotateBy(1f, 0f, 0f, 5f), new RotateBy(1f, 0f, 0f, -5f))));
//TODO: rotor should be defined in the model + animation
rotor = bigAircraft.CreateChild();
var rotorModel = rotor.CreateComponent<Box>();
rotorModel.Color = Color.White;
rotor.Scale = new Vector3(0.1f, 1.5f, 0.1f);
rotor.Position = new Vector3(0, 0, -1.3f);
var rotorAction = new RepeatForever(new RotateBy(1f, 0, 0, 360f*6)); //RPM
rotor.RunActions(rotorAction);
menuLight = bigAircraft.CreateChild();
menuLight.Position = new Vector3(-3, 6, 2);
menuLight.AddComponent(new Light { LightType = LightType.Point, Brightness = 0.3f });
await bigAircraft.RunActionsAsync(new EaseIn(new MoveBy(1f, new Vector3(-10, -2, -10)), 2));
textBlock = new Text();
textBlock.HorizontalAlignment = HorizontalAlignment.Center;
textBlock.VerticalAlignment = VerticalAlignment.Bottom;
textBlock.Value = gameOver ? "GAME OVER" : "TAP TO START";
textBlock.SetFont(cache.GetFont(Assets.Fonts.Font), Application.Graphics.Width / 15);
Application.UI.Root.AddChild(textBlock);
menuTaskSource = new TaskCompletionSource<bool>();
finished = false;
await menuTaskSource.Task;
}