示例#1
0
        public void Draw(GameTime gameTime)
        {
            sea.Draw(currentCamera);
            if (ambientOn)
            {
                waterWave.Draw(currentCamera);
            }
            if (ambientOn)
            {
                lowerAmbients.Draw(gameTime);
            }
            foreach (var item in ships)
            {
                if (item.IsDrawingSelection)
                {
                    item.DrawCircle();
                }
            }
            if (ambientOn)
            {
                lowerParticles.Draw(gameTime);
            }
            resources.Draw(gameTime);
            islands.Draw(gameTime);
            ships.Draw(gameTime);
            if (ambientOn)
            {
                upperParticles.Draw(gameTime);
            }
            if (ambientOn)
            {
                upperAmbients.Draw(gameTime);
            }

            GameOperators.PrimitiveBatch.Begin(PrimitiveType.LineList);
            #region 绘制选择框
            if (mouseDowned)
            {
                GameOperators.PrimitiveBatch.AddVertex(rec0, Color.Yellow);
                GameOperators.PrimitiveBatch.AddVertex(new Vector2(rec1.X, rec0.Y), Color.Yellow);
                GameOperators.PrimitiveBatch.AddVertex(new Vector2(rec1.X, rec0.Y), Color.Yellow);
                GameOperators.PrimitiveBatch.AddVertex(rec1, Color.Yellow);
                GameOperators.PrimitiveBatch.AddVertex(rec1, Color.Yellow);
                GameOperators.PrimitiveBatch.AddVertex(new Vector2(rec0.X, rec1.Y), Color.Yellow);
                GameOperators.PrimitiveBatch.AddVertex(new Vector2(rec0.X, rec1.Y), Color.Yellow);
                GameOperators.PrimitiveBatch.AddVertex(rec0, Color.Yellow);
            }
            #endregion
            #region 绘制边界
            GameOperators.PrimitiveBatch.AddVertex(currentCamera.TransformPoint(corners[0]), Color.Green);
            GameOperators.PrimitiveBatch.AddVertex(currentCamera.TransformPoint(corners[1]), Color.White);
            GameOperators.PrimitiveBatch.AddVertex(currentCamera.TransformPoint(corners[1]), Color.White);
            GameOperators.PrimitiveBatch.AddVertex(currentCamera.TransformPoint(corners[2]), Color.Green);
            GameOperators.PrimitiveBatch.AddVertex(currentCamera.TransformPoint(corners[2]), Color.Green);
            GameOperators.PrimitiveBatch.AddVertex(currentCamera.TransformPoint(corners[3]), Color.White);
            GameOperators.PrimitiveBatch.AddVertex(currentCamera.TransformPoint(corners[3]), Color.White);
            GameOperators.PrimitiveBatch.AddVertex(currentCamera.TransformPoint(corners[0]), Color.Green);
            #endregion
            GameOperators.PrimitiveBatch.End();

            map.Draw(gameTime);


            foreach (var item in ships)
            {
                if (item.IsDrawingArmorBar)
                {
                    Vector2 screenPoint = CurrentCamera.TransformPoint(item.AbsolutePosition);
                    DrawArmorBar(item, new Vector2((int)(screenPoint.X - GameSettings.ArmorBarLength / 2), (int)(screenPoint.Y - GameSettings.ArmorBarWidth / 2 - GameSettings.ArmorBarHeight * CurrentCamera.Scale)));
                }
                if (item.IsDrawingTargetInf)
                {
                    item.DrawTargetInf();
                }
            }

            DrawResourcesOwners();

            cameras.Draw(gameTime);
            factions.Draw(gameTime);
            cannonBalls.Draw(gameTime);
            texts.Draw(gameTime);
            Vector2 v1 = new Vector2(20, GameOperators.GraphicsDevice.Viewport.Height - 250);
            Vector2 v2 = new Vector2(GameOperators.GraphicsDevice.Viewport.Width - 210, GameOperators.GraphicsDevice.Viewport.Height - 250);

            if (f1 != null)
            {
                DrawFactionInf(f1, v1);
            }
            if (f2 != null)
            {
                DrawFactionInf(f2, v2);
            }
        }