本文整理汇总了C#中Game.AddUsing方法的典型用法代码示例。如果您正苦于以下问题:C# Game.AddUsing方法的具体用法?C# Game.AddUsing怎么用?C# Game.AddUsing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.AddUsing方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddComponentWithExistingDefine
public void AddComponentWithExistingDefine()
{
Game game = new Game("Test Game");
Using use = new Using() { File = Path.GetFileName(typeof(TransformComponent).Assembly.Location) };
game.AddUsing(use);
Define define = new Define(TransformComponentShort, TransformComponentType);
use.AddDefine(define);
Entity entity = new Entity() { Name = "entity" };
Component component = new Component(game.GetPlugin(TransformComponentShort));
entity.AddComponent(component);
game.AddPrototype(entity);
Assert.AreEqual(1, game.Usings.Count);
Assert.AreEqual(1, game.Usings.Single().Defines.Count(x => x.Name == TransformComponentShort && x.Class == TransformComponentType));
Assert.AreEqual(TransformComponentShort, component.Type);
}
示例2: AddDefaultUsings
public static void AddDefaultUsings(Game game)
{
//TODO add functions here as well later
Using defaults = new Using();
defaults.File = null;
List<string> defaultEvts = new List<string>()
{
"AttributeChanges",
"SceneStarts",
"TriggerOccurs",
"OnCreate"
};
addDefaults(defaults, defaultEvts, "Event");
List<string> defaultComponents = new List<string>()
{
"Transform"
};
addDefaults(defaults, defaultComponents, "Component");
List<string> defaultActions = new List<string>()
{
"PushScene",
"PopScene",
"ChangeScene",
"PopScene",
"FireTrigger",
"CreateEntity",
"Destroy",
"CreateTimer",
"PauseTimers",
"ResumeTimers",
"Quit",
"PointTowards"
};
addDefaults(defaults, defaultActions, "Action");
List<string> defaultManagers = new List<string>()
{
"Time"
};
addDefaults(defaults, defaultManagers, "Manager");
game.AddUsing(defaults);
}
示例3: LoadGame
public Game LoadGame()
{
Parser parser = new Parser(grammar);
src = File.ReadAllText(FileName.FullName);
ParseTree parseTree = parser.Parse(src, FileName.FullName);
if (parseTree.HasErrors())
{
throw new StorageException(BuildErrorMessage(parseTree.ParserMessages, FileName.Name));
}
root = parseTree.Root;
var nameProperty = GetProperties(root).First(x => x.Item1 == "Name");
var name = getStrVal((ParseTreeNode)nameProperty.Item2);
game = new Game(new Value(name).GetStringValue());
AddDefaultUsings(game);
IEnumerable<ParseTreeNode> usings = grammar.GetOfType(root, grammar.Uses);
foreach(ParseTreeNode node in usings)
{
Using use = CreateUsing(node);
game.AddUsing(use);
}
foreach (Tuple<string, object> attribute in GetProperties(root))
{
ParseTreeNode attributeNode = (ParseTreeNode)attribute.Item2;
if (attribute.Item1 != "Name")
{
game.AddAttribute(new Attribute(attribute.Item1) { Value = new Value(getStrVal(attributeNode)) });
}
}
foreach (ParseTreeNode prototype in grammar.GetOfType(root, grammar.Prototype))
{
Entity entity = CreateEntity(prototype, null, true);
game.AddPrototype(entity);
}
foreach (ParseTreeNode serviceNode in grammar.GetOfType(root, grammar.Service))
{
Service service = CreateService(serviceNode);
game.AddService(service);
}
foreach (ParseTreeNode sceneNode in grammar.GetOfType(root, grammar.Scene))
{
Scene scene = CreateScene(sceneNode);
game.AddScene(scene);
}
var firstScene = game.GetAttribute("FirstScene");
game.FirstScene = game.GetScene(firstScene.Value.GetStringValue());
game.RemoveAttribute(firstScene);
return game;
}
示例4: RemoveUsing
public void RemoveUsing()
{
int eventsFired = 0;
Game game = new Game("Test Game");
game.Usings.CollectionChanged += (o, e) => eventsFired++;
Using use = new Using() { File = "Test.dll" };
game.AddUsing(use);
game.RemoveUsing(use);
Assert.AreEqual(2, eventsFired);
Assert.AreEqual(game.Usings.Count(), 0);
}
示例5: GetDefinedPlugin
public void GetDefinedPlugin()
{
Game game = new Game("Test Game");
Using use = new Using() { File = "Kinectitude.Core.dll" };
use.AddDefine(new Define(TransformComponentShort, TransformComponentType));
game.AddUsing(use);
Plugin plugin = game.GetPlugin(TransformComponentShort);
Assert.IsNotNull(plugin);
Assert.AreEqual(TransformComponentType, plugin.ClassName);
}
示例6: AddUsing
public void AddUsing()
{
bool collectionChanged = false;
Game game = new Game("Test Game");
game.Usings.CollectionChanged += (o, e) => collectionChanged = true;
Using use = new Using() { File = "Test.dll" };
game.AddUsing(use);
Assert.IsTrue(collectionChanged);
Assert.AreEqual(game.Usings.Count(), 1);
Assert.AreEqual(game.Usings.First().File, "Test.dll");
}