예제 #1
0
        public static void Main()
        {
            ConsoleWindow.CustomizeConsole();

            IDrawManager drawManager = new ConsoleDrawManager();

            IBorder border = new Border(
                new Point(middleConsoleWidth - 25, middleConsoleHeight - 15),
                new Point(middleConsoleWidth + 25, middleConsoleHeight + 15));
            IFoodFactory foodFactory   = new FoodFactory(new Random(), border);
            IScene       pauseScene    = new PauseScene(drawManager);
            IScene       infoScene     = new InfoScene(drawManager);
            IScene       gameOverScene = new GameOverScene
                                         (
                drawManager,
                new PlayAgainButton(new Point(middleConsoleWidth, 30)),
                new MenuButton(new Point(middleConsoleWidth, 35))
                                         );
            IButton playButton = new PlayButton
                                 (
                new Point(middleConsoleWidth, 30),
                new Point(border.TopLeftCorner.CoordinateX + 2, border.TopLeftCorner.CoordinateY + 2),
                drawManager, foodFactory, border, pauseScene, gameOverScene);
            IScene startMenu = new StartMenuScene(drawManager, playButton, new InfoButton(new Point(middleConsoleWidth, 35), infoScene), new ExitButton(new Point(middleConsoleWidth, 40)));

            Engine engine = new Engine(startMenu);

            engine.Run();
        }
예제 #2
0
 public void OnMouseDown()
 {
     if (Construction.Cell != null && !EventSystem.current.IsPointerOverGameObject())
     {
         ScenesManager.Instance.Push(InfoScene.GetInstance(Construction));
     }
 }
예제 #3
0
    private void TestEncDec()
    {
        InfoScene infoScene = new InfoScene();

        infoScene.sceneSid = "1";

        /*try
         * {
         *  byte[] bytes1 = null;
         *  using (MemoryStream i1 = new MemoryStream())
         *  {
         *      ProtoBuf.Serializer.Serialize<InfoScene>(i1, infoScene);
         *
         *      bytes1 = i1.ToArray();
         *  }
         *
         *  InfoScene decInfo1 = null;
         *  using (MemoryStream o = new MemoryStream(bytes1))
         *  {
         *      decInfo1 = (InfoScene)ProtoBuf.Serializer.Deserialize<InfoScene>(o);
         *  }
         *
         *  Debug.LogError(decInfo1.sceneSid);
         * }
         * catch (System.Exception e)
         * {
         *  Debug.LogException(e);
         * }
         */

        try
        {
            byte[] bytes2 = null;
            using (MemoryStream i2 = new MemoryStream())
            {
                //(new ProtoBufSerializer()).Serialize(i2, infoScene);
                ProtoBuf.Serializer.Serialize(i2, infoScene);
                bytes2 = i2.ToArray();
            }

            InfoScene decInfo2 = null;
            using (MemoryStream o2 = new MemoryStream(bytes2))
            {
                decInfo2 = (InfoScene)(new ProtoBufSerializer()).Deserialize(o2, null, typeof(InfoScene));
            }

            Debug.LogError(decInfo2.sceneSid);
        }
        catch (System.Exception e)
        {
            Debug.LogException(e);
        }
    }