コード例 #1
0
ファイル: GameWorld.cs プロジェクト: LucasMess/PlatformerGame
        public static void PrepareLevelForTesting()
        {
            Entities = new List <Entity>();

            //LightingEngine.RemoveAllLights();

            foreach (Tile tile in TileArray)
            {
                tile.DefineTexture();
            }

            foreach (Tile tile in WallArray)
            {
                tile.DefineTexture();
            }

            SoundtrackManager.PlayTrack(WorldData.SoundtrackId, true);

            scriptManager.Start();
        }
コード例 #2
0
ファイル: GameWorld.cs プロジェクト: LucasMess/PlatformerGame
        public static bool TryLoadFromFile(GameMode currentGameMode)
        {
            Overlay.FadeToBlack();
            Cursor.Hide();

            if (WorldData.IsTopDown)
            {
                SpriteSheet = ContentHelper.LoadTexture("Tiles/spritemap_level_select_1");
            }
            else
            {
                SpriteSheet = defaultSpriteSheet;
            }

            LoadingScreen.LoadingText = "Where did I put that file?";
            var tileIDs = WorldData.TileIDs;
            var wallIDs = WorldData.WallIDs;

            LoadingScreen.LoadingText = "Starting up world...";
            _clouds  = new List <Cloud>();
            Entities = new List <Entity>();

            var width  = WorldData.LevelWidth;
            var height = WorldData.LevelHeight;

            var maxClouds = width / 20;

            for (var i = 0; i < maxClouds; i++)
            {
                _clouds.Add(new Cloud(new Vector2(TMBAW_Game.DefaultResWidth, TMBAW_Game.DefaultResHeight), maxClouds, i));
            }

            LevelEditor.InteractableConnections.Clear();

            TileArray = new Tile[tileIDs.Length];
            WallArray = new Tile[tileIDs.Length];

            LoadingScreen.LoadingText = "Getting tiles from junkyard...";
            ConvertToTiles(TileArray, tileIDs);
            ConvertToTiles(WallArray, wallIDs, true);

            LoadingScreen.LoadingText = "Lighting up the world...";

            LoadingScreen.LoadingText = "Finding cardboard backgrounds...";
            Background.Load();

            LoadingScreen.LoadingText = "Wait, you are editing it???";
            if (currentGameMode == GameMode.Edit)
            {
                LevelEditor.Load();
            }
            try
            {
                ChunkManager.ConvertToChunks(WorldData.LevelWidth, WorldData.LevelHeight);
            }
            catch (ArgumentException e)
            {
                TMBAW_Game.MessageBox.Show(e.Message);
                return(false);
            }

            if (Session.IsHost)
            {
                Session.SendEntityUpdates();
            }

            Session.WaitForPlayers();

            SoundtrackManager.PlayTrack(WorldData.SoundtrackId, true);

            StoryTracker.OnLevelLoad();

            TMBAW_Game.Camera.ResetZoom();
            Overlay.FadeIn();

            // Start interpreting the script for this world.
            scriptManager.SetFilename(WorldData.LevelName);
            if (currentGameMode == GameMode.Play)
            {
                scriptManager.Start();
            }

            return(true);
        }