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


C# GameEngine.Start方法代码示例

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


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

示例1: Main

    static void Main()
    {
        FleckLog.Level = LogLevel.Error;

        var renderers = new ConcurrentDictionary<IWebSocketConnection, IRenderer>();

        var proxyRenderer = new ProxyRenderer();
            proxyRenderer.AddRenderer( new ConsoleRenderer());
        var allSockets = new List<IWebSocketConnection>();
        var server = new WebSocketServer("ws://localhost:8080/websession");
        server.Start(socket =>
        {
            socket.OnOpen = () =>
            {
                allSockets.Add(socket);
                renderers[socket] = new WebRenderer(socket);
                proxyRenderer.AddRenderer(renderers[socket]);

                if (allSockets.Count == 1)
                {
                    var size = new Size(10, 15);
                    var dto = new InitMessageDto(new SizeDto(size));
                    socket.Send(dto.ToJson());

                    var engine = new GameEngine(size, new ConsoleInputListener(), proxyRenderer);
                    engine.Start();
                }
                else
                {
                    var size = new Size(10, 15);
                    var dto = new InitMessageDto(new SizeDto(size));
                    socket.Send(dto.ToJson());
                }
            };
            socket.OnClose = () =>
            {
                allSockets.Remove(socket);
                proxyRenderer.RemoveRenderer(renderers[socket]);

                IRenderer toRemove;
                renderers.TryRemove(socket, out toRemove);
            };
            socket.OnMessage = message =>
            {
                //Console.WriteLine(message);
                //allSockets.ToList().ForEach(s => s.Send("Echo: " + message));
            };
        });

        while (true)
        {
            Thread.Sleep(1000);
        }

           // Console.ReadLine();
    }
开发者ID:MarkiyanMatsekh,项目名称:MultiplayerTetris,代码行数:56,代码来源:Program.cs

示例2: Main

        public static void Main()
        {
            IGameDatabase gameDatabase = new GameDatabase();
            IInputReader reader = new ConsoleReader();
            IOutputWriter writer = new ConsoleWriter();

            var engine = new GameEngine(
                gameDatabase,
                reader,
                writer);

            engine.Start();
        }
开发者ID:k1r1L,项目名称:Soft-Uni-Homeworks,代码行数:13,代码来源:MinesweeperApplication.cs

示例3: Main

 public static void Main()
 {
     GameEngine gameEngine = new GameEngine();
     gameEngine.Start();
 }
开发者ID:tockata,项目名称:GuessTheWeight,代码行数:5,代码来源:ConsoleApp.cs


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