示例#1
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     if (input.IsMoving)
     {
         if (input.RotationDeg <= 90 || input.RotationDeg > 270)
         {
             Textures.Draw(spriteBatch, "player_left", GameObject.Position, layerDepth);
         }
         else
         {
             Textures.Draw(spriteBatch, "player_left", GameObject.Position, layerDepth, 0, SpriteEffects.FlipHorizontally);
         }
     }
     else
     {
         if (input.RotationDeg > 180)
         {
             Textures.Draw(spriteBatch, "player_down", GameObject.Position, layerDepth);
         }
         else
         {
             Textures.Draw(spriteBatch, "player_up", GameObject.Position, layerDepth);
         }
     }
 }
示例#2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            Textures.Draw(spriteBatch,
                          currentTexture(),
                          GameObject.Position,
                          layerDepth: 1f,
                          rotation: rotation,
                          sfx: this.sfx);

            if (Settings.DEBUG_CELL_HEALTH)
            {
                health.DrawHealth();
            }

            /*
             * spriteBatch.Draw(
             *  currentTexture(),
             *  GameObject.Position,
             *  null, // Source rectangle
             *  Color.White,
             *  0f, // rotation
             *  cellOrigin, // Origin
             *  1f, // scale
             *  SpriteEffects.None,
             *  1f // layer depth
             * );
             */
        }
示例#3
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     Textures.Draw(spriteBatch,
                   textureName,
                   GameObject.Position,
                   layerDepth: LayerDepth,
                   rotation: rotation,
                   sfx: sfx);
 }
示例#4
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     Textures.Draw(spriteBatch,
                   sprite,
                   GameObject.Position,
                   depth,
                   0,
                   SpriteEffects.None);
 }
示例#5
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            SpriteEffects gunSfx             = SpriteEffects.None;
            float         gunAngleAdjustment = 0.0f;

            if (input == null)
            {
                Textures.Draw(
                    spriteBatch, sprite,
                    GameObject.Position,
                    0.3f, // behind player, on ground
                    gunAngleAdjustment,
                    gunSfx);
                return;
            }

            float   gunDepth  = 0.1f; //in front of player
            Vector2 gunOffset = new Vector2(8, 4);

            if (!input.IsMoving)
            {
                if (input.RotationDeg <= 180)
                {
                    gunDepth  = 0.3f;
                    gunOffset = new Vector2(8, -6);
                }
            }

            // gun adj
            if (input.RotationDeg <= 90 || input.RotationDeg > 270)
            {
                gunSfx             = SpriteEffects.FlipHorizontally;
                gunAngleAdjustment = MathHelper.ToRadians(90);
                if (input.RotationDeg <= 90)
                {
                    // aiming top-left
                    if (input.IsMoving)
                    {
                        gunOffset = new Vector2(-8, 4);
                    }
                    else
                    {
                        gunOffset = new Vector2(-8, -4);
                    }
                }
                else
                {
                    //aiming top-right
                    gunOffset = new Vector2(-8, 4);
                }
            }

            Textures.Draw(spriteBatch, sprite, GameObject.Position + gunOffset,
                          gunDepth, input.Rotation + gunAngleAdjustment, gunSfx);
        }
示例#6
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     Textures.Draw(spriteBatch, "small_bullet", GameObject.Position + offset, 0.05f);
 }
示例#7
0
        protected override void Draw(GameTime Time)
        {
            Performance.Draw(Time);
            GraphicsDevice.Clear(Color.CornflowerBlue);

            Profiler.Start("Game Draw");
            switch (State)
            {
                #region MainMenu
            case States.MainMenu:
                Globe.Batches[0].Draw(Textures.Get("cog"), Screen.ViewportBounds);
                break;
                #endregion

                #region MapEditor
            case States.MapEditor:
                Globe.Batches[0].Begin(SpriteSortMode.BackToFront, Camera.View);
                Map.Draw();
                Globe.Batches[0].End();
                Globe.Batches[0].DrawRectangle(new Rectangle(16, (int)((Screen.ViewportHeight / 2f) - (11 * Tile.Height)), 52, (22 * Tile.Height)), (Color.Gray * .75f), (Color.Black * .75f));
                Vector2 UIPos = new Vector2(32, 0);
                for (int i = -10; i <= 20; i++)
                {
                    float Opacity = (1 - (Math.Abs(i) * .05f));
                    UIPos.Y = ((Screen.ViewportHeight / 2f) + (i * (Tile.Height + 5)));
                    ushort ID = (ushort)Math.Max(0, Math.Min(ushort.MaxValue, (EditorForeTile + i)));
                    if ((ID > 0) && (ID <= Mod.Fore.Values.Count))
                    {
                        if (Textures.Exists("Tiles.Fore." + ID))
                        {
                            Textures.Draw(("Tiles.Fore." + ID), UIPos, null, (Color.White * Opacity), 0, Origin.Center, 1);
                        }
                        if (Mod.Fore[ID].Frames > 0)
                        {
                            if (Mod.Fore[ID].Animation == null)
                            {
                                Mod.Fore[ID].Animation = new Animation(("Tiles.Fore." + ID + "-"), Mod.Fore[ID].Frames, true, Mod.Fore[ID].Speed);
                            }
                            else
                            {
                                Mod.Fore[ID].Animation.Update(Time);
                            }
                            Textures.Draw(Mod.Fore[ID].Animation.Texture(), UIPos, null, (Color.White * Opacity), 0, Origin.Center, 1);
                        }
                    }
                }
                UIPos = new Vector2(52, 0);
                for (int i = -10; i <= 20; i++)
                {
                    float Opacity = (1 - (Math.Abs(i) * .05f));
                    UIPos.Y = ((Screen.ViewportHeight / 2f) + (i * (Tile.Height + 5)));
                    ushort ID = (ushort)Math.Max(0, Math.Min(ushort.MaxValue, (EditorBackTile + i)));
                    if ((ID > 0) && (ID <= Mod.Back.Values.Count))
                    {
                        if (Textures.Exists("Tiles.Back." + ID))
                        {
                            Textures.Draw(("Tiles.Back." + ID), UIPos, null, (Color.White * Opacity), 0, Origin.Center, 1);
                        }
                        if (Mod.Back[ID].Frames > 0)
                        {
                            if (Mod.Back[ID].Animation == null)
                            {
                                Mod.Back[ID].Animation = new Animation(("Tiles.Back." + ID + "-"), Mod.Back[ID].Frames, true, Mod.Back[ID].Speed);
                            }
                            else
                            {
                                Mod.Back[ID].Animation.Update(Time);
                            }
                            Textures.Draw(Mod.Back[ID].Animation.Texture(), UIPos, null, (Color.White * Opacity), 0, Origin.Center, 1);
                        }
                    }
                }
                break;
                #endregion

                #region Game
            case States.Game:
                Globe.Batches[0].Begin(SpriteSortMode.BackToFront, Camera.View);
                Map.Draw();
                for (byte i = 0; i < Players.Length; i++)
                {
                    if (Players[i] != null)
                    {
                        Players[i].Draw();
                    }
                }
                Globe.Batches[0].End();
                break;
                #endregion
            }
            Profiler.Stop("Game Draw");

            //Performance.Draw(Fonts.Get("Default/ExtraSmall"), new Vector2(5, (Screen.ViewportHeight - 35)), Origin.None, Color.White, Color.Black);
            //Profiler.Draw(430);

            Batch.EndAll();
            base.Draw(Time);
        }