Exemple #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
        {
            cam.UpdateTransform();

            spriteBatch.Begin(SpriteSortMode.BackToFront,
                              BlendState.AlphaBlend,
                              null, null, null, null,
                              cam.Transform);

            graphics.Clear(new Color(0.051f, 0.149f, 0.271f, 1.0f));
            if (GameMain.DebugDraw)
            {
                GUI.DrawLine(spriteBatch, new Vector2(Submarine.MainSub.HiddenSubPosition.X, -cam.WorldView.Y), new Vector2(Submarine.MainSub.HiddenSubPosition.X, -(cam.WorldView.Y - cam.WorldView.Height)), Color.White * 0.5f, 1.0f, (int)(2.0f / cam.Zoom));
                GUI.DrawLine(spriteBatch, new Vector2(cam.WorldView.X, -Submarine.MainSub.HiddenSubPosition.Y), new Vector2(cam.WorldView.Right, -Submarine.MainSub.HiddenSubPosition.Y), Color.White * 0.5f, 1.0f, (int)(2.0f / cam.Zoom));
            }

            Submarine.Draw(spriteBatch, true);

            if (!characterMode && !wiringMode)
            {
                if (MapEntityPrefab.Selected != null)
                {
                    MapEntityPrefab.Selected.DrawPlacing(spriteBatch, cam);
                }

                MapEntity.DrawSelecting(spriteBatch, cam);
            }


            spriteBatch.End();

            //-------------------- HUD -----------------------------

            spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, GameMain.ScissorTestEnable);

            if (Submarine.MainSub != null)
            {
                DrawSubmarineIndicator(spriteBatch, Submarine.MainSub, Color.LightBlue * 0.5f);
            }

            leftPanel.Draw(spriteBatch);
            topPanel.Draw(spriteBatch);

            //EntityPrefab.DrawList(spriteBatch, new Vector2(20,50));

            if ((characterMode || wiringMode) && dummyCharacter != null)
            {
                if (dummyCharacter.SelectedConstruction != null)
                {
                    dummyCharacter.SelectedConstruction.DrawHUD(spriteBatch, cam, dummyCharacter);
                }

                dummyCharacter.DrawHUD(spriteBatch, cam);

                if (wiringMode)
                {
                    wiringToolPanel.Draw(spriteBatch);
                }
            }
            else
            {
                if (loadFrame != null)
                {
                    loadFrame.Draw(spriteBatch);
                }
                else if (saveFrame != null)
                {
                    saveFrame.Draw(spriteBatch);
                }
                else if (selectedTab > -1)
                {
                    GUItabs[selectedTab].Draw(spriteBatch);
                }

                MapEntity.DrawEditor(spriteBatch, cam);
            }

            if (tutorial != null)
            {
                tutorial.Draw(spriteBatch);
            }

            GUI.Draw((float)deltaTime, spriteBatch, cam);

            if (!PlayerInput.LeftButtonHeld())
            {
                Inventory.draggingItem = null;
            }

            spriteBatch.End();
        }