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(); }
public void LoadLevel() { string[] tmxFiles = TmxFilesLoader.GetTmxFileNames("Level*.tmx"); var mapData = TiledMapParserExtended.MapParser.ReadMap(tmxFiles[0]); _level = new BaseLevel(_caveLevelMap, _cam); AddChild(_level); _gameHud = new GameHud(_level, _cam); DebugDrawBoundBox.level = _level; foreach (var sprite in _level.GetChildren().Where(s => s is Sprite)) { DebugDrawBoundBox.AddSprite((Sprite)sprite); } foreach (var sprite in _gameHud.GetChildrenRecursive().Where(s => s is Sprite)) { DebugDrawBoundBox.AddSprite((Sprite)sprite); } }