本文整理汇总了C#中Mocks.Game方法的典型用法代码示例。如果您正苦于以下问题:C# Mocks.Game方法的具体用法?C# Mocks.Game怎么用?C# Mocks.Game使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mocks
的用法示例。
在下文中一共展示了Mocks.Game方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetImplementors
public static IEnumerable<IObject> GetImplementors(Mocks mocks, Mock<IGameState> stateMock, IGameState state = null)
{
if (state == null && stateMock != null) state = stateMock.Object;
mocks.Game().Setup(g => g.State).Returns(state);
if (stateMock != null)
{
stateMock.Setup(s => s.UI).Returns(new AGSConcurrentHashSet<IObject>());
}
Mock<IInput> input = new Mock<IInput>();
Resolver resolver = GetResolver();
input.Setup(i => i.KeyUp).Returns(new Mock<IEvent<KeyboardEventArgs>>().Object);
input.Setup(i => i.KeyDown).Returns(new Mock<IEvent<KeyboardEventArgs>>().Object);
if (stateMock != null) stateMock.Setup(s => s.Cutscene).Returns(mocks.Cutscene().Object);
Mock<IUIEvents> uiEvents = new Mock<IUIEvents>();
Mock<IEvent<MouseButtonEventArgs>> buttonEvent = new Mock<IEvent<MouseButtonEventArgs>>();
Mock<IEvent<MousePositionEventArgs>> mouseEvent = new Mock<IEvent<MousePositionEventArgs>>();
uiEvents.Setup(u => u.MouseClicked).Returns(buttonEvent.Object);
uiEvents.Setup(u => u.MouseDown).Returns(buttonEvent.Object);
uiEvents.Setup(u => u.MouseUp).Returns(buttonEvent.Object);
uiEvents.Setup(u => u.LostFocus).Returns(buttonEvent.Object);
uiEvents.Setup(u => u.MouseEnter).Returns(mouseEvent.Object);
uiEvents.Setup(u => u.MouseLeave).Returns(mouseEvent.Object);
uiEvents.Setup(u => u.MouseMove).Returns(mouseEvent.Object);
Mock<IGraphicsFactory> graphicsFactory = new Mock<IGraphicsFactory>();
Func<ISprite> getSprite = () => new AGSSprite(resolver, mocks.MaskLoader().Object);
graphicsFactory.Setup(g => g.GetSprite()).Returns(() => getSprite());
AGSAnimationContainer animationContainer = new AGSAnimationContainer();
Mock<IImage> image = new Mock<IImage>();
Mock<IButtonComponent> buttonComponent = new Mock<IButtonComponent>();
buttonComponent.Setup(b => b.HoverAnimation).Returns(new AGSSingleFrameAnimation(getSprite()));
buttonComponent.Setup(b => b.IdleAnimation).Returns(new AGSSingleFrameAnimation(getSprite()));
buttonComponent.Setup(b => b.PushedAnimation).Returns(new AGSSingleFrameAnimation(getSprite()));
Mock<IAudioSystem> audioSystem = new Mock<IAudioSystem>();
Mock<IRuntimeSettings> settings = mocks.Settings();
resolver.Builder.RegisterInstance(input.Object);
resolver.Builder.RegisterInstance(state);
resolver.Builder.RegisterInstance(uiEvents.Object);
resolver.Builder.RegisterInstance(animationContainer).As<IAnimationContainer>();
resolver.Builder.RegisterInstance(buttonComponent.Object);
resolver.Builder.RegisterInstance(audioSystem.Object);
resolver.Builder.RegisterInstance(new Mock<IMessagePump>().Object);
resolver.Builder.RegisterInstance(new Mock<ILabelRenderer>().Object);
resolver.Builder.RegisterInstance(new Mock<ITexture>().Object);
resolver.Builder.RegisterInstance(mocks.MaskLoader().Object).As<IMaskLoader>();
resolver.Builder.RegisterInstance(settings.Object).As<IGameSettings>();
resolver.Builder.RegisterInstance(settings.Object).As<IRuntimeSettings>();
resolver.Builder.RegisterInstance(mocks.Game().Object);
resolver.Build();
Func<IObject> baseObj = () => new AGSObject("Test", resolver);
mocks.Game().Setup(g => g.Events).Returns(resolver.Container.Resolve<IGameEvents>());
mocks.Game().Setup(g => g.Factory).Returns(resolver.Container.Resolve<IGameFactory>());
Mock<IOutfit> outfit = new Mock<IOutfit>();
Func<IPanel> basePanel = () => new AGSPanel("Panel", resolver, image.Object);
Func<ILabel> baseLabel = () => new AGSLabel("Label", resolver) { LabelRenderSize = new AGS.API.SizeF(100f, 50f) };
var button = new AGSButton("Button", resolver) { LabelRenderSize = new AGS.API.SizeF(100f, 50f) };
List<IObject> implmentors = new List<IObject>
{
baseObj().Hotspot("Object"),
new AGSCharacter("Character", resolver, outfit.Object).Hotspot("Character"),
basePanel().Hotspot("Panel"),
baseLabel().Hotspot("Label"),
button.Hotspot("Button"),
new AGSInventoryWindow("Inventory", resolver, image.Object).Hotspot("Inventory"),
new AGSSlider("Slider", resolver, image.Object).Hotspot("Slider"),
new AGSCheckBox("Checkbox", resolver),
new AGSTextbox("Textbox", resolver),
new AGSComboBox("Combobox", resolver),
};
return implmentors;
}