当前位置: 首页>>代码示例>>C#>>正文


C# Game.AddScene方法代码示例

本文整理汇总了C#中Game.AddScene方法的典型用法代码示例。如果您正苦于以下问题:C# Game.AddScene方法的具体用法?C# Game.AddScene怎么用?C# Game.AddScene使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Game的用法示例。


在下文中一共展示了Game.AddScene方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public static void Main(string[] args)
        {
            String title = String.Format("{0} {1}", Resources.GameTitle, Resources.Version);

            Game game = new Game(title, 1280, 720);

            List<Scene> sceneCollection = new List<Scene>() { new BasicSpellingScene(), new MenuScene() };

            game.AddScene(sceneCollection.ToArray());

            game.Start();
        }
开发者ID:GaryTheLlama,项目名称:LilTyping,代码行数:12,代码来源:Program.cs

示例2: GameViewModel

        public GameViewModel(Game game)
        {
            this.game = game;

            game.PropertyChanged += Game_PropertyChanged;

            Prototypes = new ComputedObservableCollection<Entity, EntityViewModel>(game.Prototypes, (prototype) => new EntityViewModel(prototype));
            Scenes = new ComputedObservableCollection<Scene, SceneViewModel>(game.Scenes, (scene) => new SceneViewModel(scene));

            AddPrototypeCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    Entity prototype = new Entity();

                    DialogService.ShowDialog(DialogService.Constants.EntityDialog, prototype,
                        (result) =>
                        {
                            if (result == true)
                            {
                                game.AddPrototype(prototype);
                            }
                        }
                    );
                }
            );

            RemovePrototypeCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    Entity prototype = parameter as Entity;
                    game.RemovePrototype(prototype);
                }
            );

            AddSceneCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    Scene scene = game.CreateScene();

                    DialogService.ShowDialog(DialogService.Constants.SceneDialog, scene,
                        (result) =>
                        {
                            if (result == true)
                            {
                                game.AddScene(scene);
                            }
                        }
                    );
                }
            );

            RemoveSceneCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    Scene scene = parameter as Scene;
                    game.RemoveScene(scene);
                }
            );

            AddAttributeCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    game.CreateAttribute();
                }
            );

            RemoveAttributeCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    Attribute attribute = parameter as Attribute;
                    game.RemoveAttribute(attribute);
                }
            );

            AddAssetCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    // TODO: File Chooser
                    Asset asset = new Asset("An Asset");
                    game.AddAsset(asset);
                }
            );

            RemoveAssetCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    Asset asset = parameter as Asset;
                    game.RemoveAsset(asset);
                }
            );

            RemoveItemCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    Entity prototype = parameter as Entity;
                    if (null != prototype)
                    {
                        game.RemovePrototype(prototype);
                    }
                    else
//.........这里部分代码省略.........
开发者ID:kinectitude,项目名称:kinectitude,代码行数:101,代码来源:GameViewModel.cs

示例3: Workspace

        private Workspace()
        {
            Plugins = new ObservableCollection<Plugin>();

            Services = new FilteredObservableCollection<Plugin>(Plugins, p => p.Type == PluginType.Service);
            Managers = new FilteredObservableCollection<Plugin>(Plugins, p => p.Type == PluginType.Manager);
            Components = new FilteredObservableCollection<Plugin>(Plugins, p => p.Type == PluginType.Component);

            Events = new ObservableCollection<StatementFactory>();
            Actions = new ObservableCollection<StatementFactory>();
            Statements = new ObservableCollection<StatementFactory>();

            NewProjectCommand = new DelegateCommand(null, p =>
            {
                var create = true;

                if (null != Project && CommandHistory.HasUnsavedChanges)
                {
                    DialogService.Warn(Messages.NewProject, Messages.UnsavedMessage, MessageBoxButton.YesNoCancel, r =>
                    {
                        if (r == MessageBoxResult.Yes)
                        {
                            SaveProject();
                        }
                        else if (r == MessageBoxResult.Cancel)
                        {
                            create = false;
                        }
                    });
                }

                if (create)
                {
                    Game game = new Game("Untitled Game");
                    KglGameStorage.AddDefaultUsings(game);

                    var service = new Service(GetPlugin(typeof(RenderService)));
                    service.SetProperty("Width", new Value(800, true));
                    service.SetProperty("Height", new Value(600, true));
                    game.AddService(service);

                    var scene = new Scene("Scene1");

                    var manager = new Manager(GetPlugin(typeof(RenderManager)));
                    scene.AddManager(manager);

                    game.AddScene(scene);
                    game.FirstScene = scene;

                    Project project = new Project();
                    project.Game = game;

                    DialogService.ShowDialog<ProjectDialog>(project, (result) =>
                    {
                        if (result == true)
                        {
                            ProjectStorage.CreateProject(project);
                            Project = project;
                        }
                    });
                }
            });

            LoadProjectCommand = new DelegateCommand(null, p =>
            {
                var load = true;

                if (null != Project && CommandHistory.HasUnsavedChanges)
                {
                    DialogService.Warn(Messages.LoadProject, Messages.UnsavedMessage, MessageBoxButton.YesNoCancel, r =>
                    {
                        if (r == MessageBoxResult.Yes)
                        {
                            SaveProject();
                        }
                        else if (r == MessageBoxResult.Cancel)
                        {
                            load = false;
                        }
                    });
                }

                if (load)
                {
                    DialogService.ShowLoadDialog((result, fileName) =>
                    {
                        if (result == true)
                        {
                            try
                            {
                                LoadProject(fileName);
                            }
                            catch (EditorException e)
                            {
                                DialogService.Warn(Messages.FailedToLoad, e.Message, MessageBoxButton.OK);
                            }
                        }
                    });
                }
            });
//.........这里部分代码省略.........
开发者ID:kinectitude,项目名称:kinectitude,代码行数:101,代码来源:Workspace.cs

示例4: 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;
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:57,代码来源:KglGameStorage.cs

示例5: RemoveScene

        public void RemoveScene()
        {
            int eventsFired = 0;

            Game game = new Game("Test Game");
            game.Scenes.CollectionChanged += (o, e) => eventsFired++;

            Scene scene = new Scene("Test Scene");
            game.AddScene(scene);
            game.RemoveScene(scene);

            Assert.AreEqual(2, eventsFired);
            Assert.AreEqual(game.Scenes.Count(), 0);
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:14,代码来源:GameTests.cs

示例6: AddScene

        public void AddScene()
        {
            bool collectionChanged = false;

            Game game = new Game("Test Game");
            game.Scenes.CollectionChanged += (o, e) => collectionChanged = true;

            Scene scene = new Scene("Test Scene");
            game.AddScene(scene);

            Assert.IsTrue(collectionChanged);
            Assert.AreEqual(game.Scenes.Count(), 1);
            Assert.AreEqual(game.Scenes.First().Name, "Test Scene");
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:14,代码来源:GameTests.cs

示例7: Game_RemoveItem

        public void Game_RemoveItem()
        {
            var game = new Game("Test Game");
            var scene = new Scene("Test Scene");
            game.AddScene(scene);

            CommandHelper.TestUndoableCommand(
                () => Assert.AreEqual(1, game.Scenes.Count),
                () => game.RemoveItemCommand.Execute(scene),
                () => Assert.AreEqual(0, game.Scenes.Count)
            );

            var prototype = new Entity() { Name = "Prototype" };
            game.AddPrototype(prototype);

            CommandHelper.TestUndoableCommand(
                () => Assert.AreEqual(1, game.Prototypes.Count),
                () => game.RemoveItemCommand.Execute(prototype),
                () => Assert.AreEqual(0, game.Prototypes.Count)
            );
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:21,代码来源:CommandTests.cs

示例8: CannotRenameToDuplicateNameInSameScope

        public void CannotRenameToDuplicateNameInSameScope()
        {
            Game game = new Game("Test Game");
            game.AddPrototype(new Entity() { Name = "TestEntity" });

            Scene scene = new Scene("Test Scene");

            Entity entity = new Entity() { Name = "TestEntity2" };
            scene.AddEntity(entity);

            game.AddScene(scene);

            entity.Name = "TestEntity";

            Assert.AreEqual(1, scene.Entities.Count);
            Assert.AreEqual("TestEntity2", entity.Name);
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:17,代码来源:EntityTests.cs

示例9: CanAddDuplicateNameInDifferentScope

        public void CanAddDuplicateNameInDifferentScope()
        {
            Game game = new Game("Test Game");

            Scene scene1 = new Scene("Test Scene");

            Entity entity1 = new Entity() { Name = "TestEntity" };
            scene1.AddEntity(entity1);

            game.AddScene(scene1);

            Scene scene2 = new Scene("Test Scene 2");

            Entity entity2 = new Entity() { Name = "TestEntity" };
            scene2.AddEntity(entity2);

            game.AddScene(scene2);

            Assert.AreEqual(1, scene1.Entities.Count);
            Assert.AreEqual(1, scene2.Entities.Count);
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:21,代码来源:EntityTests.cs


注:本文中的Game.AddScene方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。