Exemplo n.º 1
0
 public static void DrawUi(SpriteBatch spriteBatch)
 {
     if (TMBAW_Game.CurrentGameMode == GameMode.Edit)
     {
         LevelEditor.DrawUi(spriteBatch);
     }
     if (TMBAW_Game.CurrentGameMode == GameMode.Play)
     {
         DialogueSystem.Draw(spriteBatch);
     }
 }
Exemplo n.º 2
0
        public static void Draw(SpriteBatch spriteBatch)
        {
            if (TMBAW_Game.CurrentGameMode == GameMode.Edit)
            {
                LevelEditor.DrawBehindTiles(spriteBatch);
            }

            int[] indexes = ChunkManager.GetVisibleIndexes();
            if (indexes != null)
            {
                foreach (var tileNumber in indexes)
                {
                    if (tileNumber >= 0 && tileNumber < TileArray.Length)
                    {
                        TileArray[tileNumber].Draw(spriteBatch);
                    }
                }
            }

            foreach (Player player in GameWorld.GetPlayers())
            {
                player.Draw(spriteBatch);
            }

            for (var i = 0; i < Entities.Count; i++)
            {
                if (!Entities[i].IsDead)
                {
                    Entities[i].Draw(spriteBatch);
                }
            }

            ProjectileSystem.Draw(spriteBatch);

            //ParticleSystem.DrawNormalParticles(spriteBatch);

            if (TMBAW_Game.CurrentGameMode == GameMode.Edit)
            {
                LevelEditor.Draw(spriteBatch);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public static void UpdateWorld()
        {
            ParticleSystem.Update();
            //ParticleSystem.Update();
            Weather.Update();

            if (TMBAW_Game.CurrentGameMode == GameMode.Edit)
            {
                foreach (Player player in GetPlayers())
                {
                    player.ComplexAnimation.RemoveAllFromQueue();
                    player.AddAnimationToQueue("editMode");
                }
                LevelEditor.Update();
            }
            else
            {
                if (IsTestingLevel)
                {
                    if (GetPlayers()[0].IsTestLevelPressed())
                    {
                        LevelEditor.GoBackToEditing();
                    }
                }
                UpdateVisual();
            }

            TimesUpdated++;

            ProjectileSystem.Update();

            for (var i = Entities.Count - 1; i >= 0; i--)
            {
                var entity = Entities[i];
                if (entity.ToDelete)
                {
                    entity.Destroy();
                }
            }
            foreach (Player player in GetPlayers())
            {
                player.Update();
            }

            if (TMBAW_Game.CurrentGameMode == GameMode.Play)
            {
                foreach (Player player in GameWorld.GetPlayers())
                {
                    PlayerTrail.Add(player);
                }
            }

            foreach (var c in _clouds)
            {
                c.CheckOutOfRange();
                c.Update();
            }
            for (var i = 0; i < Entities.Count; i++)
            {
                var entity = Entities[i];
                if (entity.IsDead)
                {
                    continue;
                }
                entity.Update();

                //// Check enemy collision with other enemies.
                //for (int j = i + 1; j < Entities.Count; j++)
                //{
                //    if (Entities[i].IsTouchingEntity(Entities[j]))
                //    {
                //        if (Entities[i].Position.X > Entities[j].Position.X)
                //        {
                //            Entities[i].SetX(Entities[j].Position.X + Entities[j].CollRectangle.Width / 2);
                //        }
                //        else
                //        {
                //            Entities[i].SetX(Entities[j].Position.X - Entities[i].CollRectangle.Width / 2);
                //        }
                //        Entities[i].ForceUpdateCollisionRectangle();
                //    }
                //}
            }


            foreach (var tileNumber in ChunkManager.GetVisibleIndexes())
            {
                if (tileNumber >= 0 && tileNumber < TileArray.Length)
                {
                    TileArray[tileNumber]?.Update();
                }
            }

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