예제 #1
0
    private void ToogleDebug(Vector2 worldMousePos)
    {
        Debug = !Debug;

        _debugText.SetActive(Debug);

        int playerIndex = _caveLevelMap.Index + 1;

        //Draw walkable image layers
        var debugWalkable = _level.GetChildren().FirstOrDefault(g => g.name == "Debug_Walkable");

        if (Debug && debugWalkable == null)
        {
            var bitmapData = _caveLevelMap._walkableImageLayer.GetBitmapDataFromWorldPos(worldMousePos);
            if (bitmapData.bitMap != null)
            {
                debugWalkable = new Canvas(bitmapData.bitMap, false)
                {
                    name = "Debug_Walkable"
                };

                _level.AddChildAt(debugWalkable, playerIndex);
                debugWalkable.SetXY(bitmapData.offSetX, bitmapData.offSetY);
            }
        }
        else
        {
            debugWalkable?.Destroy();
        }

        _level.PlayerCollision?.ToogleDebug();
    }
예제 #2
0
    public MyGame() : base(SCREEN_WIDTH, SCREEN_HEIGHT, Settings.FullScreen) // Create a window that's 800x600 and NOT fullscreen
    {
        SCREEN_WIDTH  = game.width;
        SCREEN_HEIGHT = game.height;

        HALF_SCREEN_WIDTH  = SCREEN_WIDTH / 2;
        HALF_SCREEN_HEIGHT = SCREEN_HEIGHT / 2;

        ShowMouse(true);

        string[] tmxFiles = TmxFilesLoader.GetTmxFileNames("Level*.tmx");
        var      mapData  = TiledMapParserExtended.MapParser.ReadMap(tmxFiles[0]);

        _caveLevelMap = new CaveLevelMapGameObject(mapData);

        _cam       = new FollowCamera(0, 0, game.width, game.height);
        _cam.scale = Settings.Camera_Scale;
        Cam        = _cam;

        var gameSoundManager = new GameSoundManager(mapData);

        AddChild(gameSoundManager);

        var startScreen = new PreGameStartScreen(Settings.StartScreen_Bg_Image, Settings.StartScreen_Music, () =>
        {
            var inGameStartScreen1 =
                new PreGameStartScreen(Settings.In_Game_StartScreen_1_Bg_Image, Settings.In_Game_StartScreen_1_Music,
                                       () =>
            {
                var inGameStartScreen2 =
                    new PreGameStartScreen(Settings.In_Game_StartScreen_2_Bg_Image, Settings.In_Game_StartScreen_2_Music,
                                           () =>
                {
                    var inGameStartScreen3 =
                        new PreGameStartScreen(Settings.In_Game_StartScreen_3_Bg_Image, null,
                                               () =>
                    {
                        GameSoundManager.Instance.FadeOutCurrentMusic();
                        CoroutineManager.StartCoroutine(LoadLevelWithDelay(), this);
                    });
                    AddChild(inGameStartScreen3);
                });
                AddChild(inGameStartScreen2);
            });
            AddChild(inGameStartScreen1);
        });

        AddChild(startScreen);

        //Debug
        _fpsCounter = new FpsCounter();
        AddChild(_fpsCounter);

        _debugText = new DebugTextBox("Hello World", width, 100);
        _cam.AddChild(_debugText);
        _debugText.x = -SCREEN_WIDTH / 2;
        _debugText.y = -SCREEN_HEIGHT / 2;
        _debugText.SetActive(false);
    }