public static BHEntity RoundSmall(BHGame mGame, Vector2i mPosition = default(Vector2i), float mAngle = 0, int mSpeed = 0)
 {
     BHEntity result = BHPresetBase.Bullet(mGame, mPosition, mAngle, mSpeed, 5.ToUnits());
     result.Sprite = new Sprite(Assets.GetTexture("b_circlesmall"));
     result.IsSpriteFixed = true;
     return result;
 }
 public static void ClearBullets(BHGame mGame, BHStage mStage)
 {
     for (int i = mGame.Manager.EntityDictionary["deadlytoplayer"].Count - 1; i > 0; i--)
     {
         Entity entity = mGame.Manager.EntityDictionary["deadlytoplayer"][i];
         entity.Destroy();
     }
 }
        public static void CutIn(BHGame mGame, BHStage mStage, Texture mTexture, bool mText = false, string mBackgroundText = "spell attack",
                                 Vector2i mVelocity = default(Vector2i), Vector2i mOffset = default(Vector2i), int mLength = 100)
        {
            var cutInTimeline = new Timeline();

            var texts = new List<Text>();
            var drawEvents = new List<Action>();

            if (mText)
            {
                for (int iX = -2; iX < 3; iX++)
                {
                    for (int i = 0; i < 35; i++)
                    {
                        var temp = new Text(mBackgroundText, Font.DefaultFont)
                                   {
                                       Position = new Vector2f(300 + (iX*84), (i*35) - 200),
                                       Color = Color.White,
                                       CharacterSize = 15,
                                       Rotation = 25
                                   };

                        texts.Add(temp);

                        Action drawEvent = () => mGame.GameWindow.RenderWindow.Draw(temp);
                        drawEvents.Add(drawEvent);
                        mGame.AddDrawAction(drawEvent);
                    }
                }
            }

            var cutInSprite = new Sprite(mTexture)
                              {
                                  Color = new Color(255, 255, 255, 0)
                              };

            var cutInEntity = new BHEntity(mGame)
                              {
                                  DrawOrder = 100000,
                                  Sprite = cutInSprite,
                                  Position = mGame.Center + mOffset
                              };

            BHPresetTimelines.Fade(cutInEntity, 0, true, 16);
            BHPresetTimelines.Fade(cutInEntity, mLength, false, 16);

            cutInTimeline.Action(() => { foreach (var text in texts) text.Position -= new Vector2f(3, 1); });
            cutInTimeline.Action(() => cutInEntity.Position += mVelocity);
            cutInTimeline.Wait();
            cutInTimeline.Goto(mTimes: 200);
            cutInTimeline.Action(() =>
                                 {
                                     foreach (var drawEvent in drawEvents) mGame.RemoveDrawAction(drawEvent);
                                     cutInEntity.Destroy();
                                 });

            mStage.TimelinesUpdate.Add(cutInTimeline);
        }
        public static BHEntity Bullet(BHGame mGame, Vector2i mPosition = default(Vector2i), float mAngle = 0, int mSpeed = 0, long mRadius = 0)
        {
            var result = new BHEntity(mGame, "deadlytoplayer", "bullet") {Position = mPosition, Velocity = BHUtils.CalculateVelocity(mAngle, mSpeed)};
            result.CollisionShape = new BHCSCircle(result, mRadius*mRadius);

            result.OnOutOfBounds += BHPresetOutOfBounds.Destroy;

            return result;
        }
Exemple #5
0
 public BHEntity(BHGame mGame, params string[] mGroups)
     : base(mGame.Manager, 0, mGroups)
 {
     Game = mGame;
     TimelinesUpdate = new List<Timeline>();
     TimelinesDrawBefore = new List<Timeline>();
     TimelinesDrawAfter = new List<Timeline>();
     Parameters = new Dictionary<string, object>();
     CollisionAgainstGroups = new List<string>();
     CollisionEntities = new List<BHEntity>();
 }
Exemple #6
0
        private static void Main()
        {
            Settings.Framerate.Limit = 60;
            Settings.Framerate.IsLimited = true;
            Settings.Frametime.IsStatic = false;
            Settings.Frametime.StaticValue = 1;

            var game = new BHGame();
            var gameWindow = new GameWindow(640, 480, 1);

            gameWindow.SetGame(game);
            gameWindow.Camera.Move(-new Vector2f(32, 16));
            gameWindow.Run();
        }
        public static BHEntity Boss(BHGame mGame, int mRadius, int mHealth)
        {
            var deathTimeline = new Timeline();

            var result = new BHEntity(mGame, "boss", "enemy", "character");
            result.CollisionShape = new BHCSCircle(result, mRadius*mRadius);
            result.Parameters["health"] = mHealth;

            deathTimeline.Action(() => { if ((int) result.Parameters["health"] <= 0) {} });
            deathTimeline.Wait();
            deathTimeline.Goto();

            result.TimelinesUpdate.Add(deathTimeline);

            return result;
        }
        public static BHEntity Enemy(BHGame mGame, int mRadius, int mHealth)
        {
            var deathTimeline = new Timeline();

            var result = new BHEntity(mGame, "enemy", "character");
            result.CollisionShape = new BHCSCircle(result, mRadius*mRadius);
            result.Parameters["health"] = mHealth;

            deathTimeline.Action(() =>
                                 {
                                     if ((int) result.Parameters["health"] <= 0)
                                     {
                                         result.Destroy();
                                         Assets.GetSound("se_enep00").Play();
                                     }
                                 });
            deathTimeline.Wait();
            deathTimeline.Goto();

            result.TimelinesUpdate.Add(deathTimeline);

            return result;
        }
        public static BHEntity Reimu(BHGame mGame)
        {
            var fireTimeline = new Timeline();

            BHEntity result = BHPresetBase.Player(mGame, 4.ToUnits(), 2.ToUnits(), Assets.GetAnimation("playerleft"), Assets.GetAnimation("playerright"), Assets.GetAnimation("playerstill"));
            result.Sprite = Assets.GetTileset("p_reimu").GetSprite("s1", Assets.GetTexture("p_reimu"));

            fireTimeline.Action(() =>
                                {
                                    if (Keyboard.IsKeyPressed(Keyboard.Key.Z))
                                    {
                                        Assets.GetSound("se_plst00").Play();
                                        BHPresetBase.PlayerBullet(mGame, result.Position - new Vector2i(8.ToUnits(), 17.ToUnits()), 270, 27.ToUnits()).Sprite = new Sprite(Assets.GetTexture("b_player_reimu1"));
                                        BHPresetBase.PlayerBullet(mGame, result.Position - new Vector2i(-8.ToUnits(), 17.ToUnits()), 270, 27.ToUnits()).Sprite = new Sprite(Assets.GetTexture("b_player_reimu1"));
                                    }
                                });
            fireTimeline.Wait(4);
            fireTimeline.Goto();

            result.TimelinesUpdate.Add(fireTimeline);

            return result;
        }
        public static BHEntity EnemyFairy1(BHGame mGame, Vector2i mPosition, bool mRight, string mTexture, int mMultiplier = 1)
        {
            int dir = -1;
            if (mRight) dir = 1;
            int s = 2;

            BHEntity result = BHPresetBase.Enemy(mGame, 20.ToUnits(), 2);
            result.Sprite = Assets.GetTileset(mTexture).GetSprite("s1", Assets.GetTexture("enemyfairy"));
            result.IsSpriteFixed = true;
            result.Position = mPosition;
            result.Animation = Assets.GetAnimation("enemyfairystill");

            BHPresetTimelines.Kill(result, 400);

            // MOVEMENT TIMELINES
            var timelineMovement = new Timeline();
            for (int i = 0; i < 150; i++)
            {
                int i1 = i;
                timelineMovement.AddCommand(new Do(() => result.Velocity = new Vector2i((0.1f.ToUnits()*s - (i1*-3*s))*dir, 0 + (i1*3*s))));
                if (i%3 == 0) timelineMovement.AddCommand(new Wait(1));
            }
            // -------------------

            // ATTACK TIMELINES
            var timelineAttack = new Timeline();
            timelineAttack.AddCommand(new Do(() => EnemyFairy1Attack(mGame, result.Position, new Color(135, 135, 230, 255), mMultiplier)));
            timelineAttack.AddCommand(new Wait(25));
            timelineAttack.AddCommand(new Goto(0, 8));
            // -------------------

            result.TimelinesUpdate.Add(timelineMovement);
            result.TimelinesUpdate.Add(timelineAttack);

            return result;
        }
        public static void EnemyMidboss1SpellCard2(BHGame mGame, BHEntity mBoss)
        {
            var spellcardTimeline = new Timeline();
            spellcardTimeline.AddCommand(new Do(() => EnemyMidboss1SpellCardAttack3(mGame, mBoss.Position)));
            spellcardTimeline.AddCommand(new Wait(21));
            spellcardTimeline.AddCommand(new Do(() => BHPresetTimelines.MovementLerp(mBoss,
                                                                                     new Vector2i(Utils.Random.Next(mGame.Bounds.Left + 5.ToUnits(), mGame.Bounds.Right - 5.ToUnits()), mBoss.Position.Y))));
            spellcardTimeline.AddCommand(new Goto(0));

            var continueTimeline = new Timeline();
            continueTimeline.AddCommand(new Wait(25));
            continueTimeline.AddCommand(new Do(() => BHPresetTimelines.MovementLerp(mBoss, new Vector2i(mGame.Center.X, mBoss.Position.Y))));
            continueTimeline.AddCommand(new Wait(75));
            continueTimeline.AddCommand(new Do(mBoss.Destroy));
            continueTimeline.AddCommand(new Do(() => Assets.GetSound("enep01").Play()));

            BHPresetStageControl.CutIn(mGame, mGame.CurrentStage, Assets.GetTexture("face07bs"), true, "u mad bro?",
                                       new Vector2i(6.ToUnits(), 1.ToUnits()), new Vector2i(-10.ToUnits(), 5.ToUnits()), 150);
            BHPresetStageControl.SpellCard(mGame, mGame.CurrentStage, mBoss, "HERE ARE SOME BULLETS 4 U", 150, 1000, 10000, continueTimeline, spellcardTimeline);
        }
 public static BHEntity Pellet(BHGame mGame, Vector2i mPosition = default(Vector2i), float mAngle = 0, int mSpeed = 0)
 {
     BHEntity result = BHPresetBase.Bullet(mGame, mPosition, mAngle, mSpeed, 3.4f.ToUnits());
     result.Sprite = new Sprite(Assets.GetTexture("b_pellet"));
     return result;
 }
        public static BHEntity Laser(BHGame mGame, Sprite mSprite, Vector2i mPosition = default(Vector2i), float mAngle = 0, int mSpeed = 0,
                                     long mRadius = 0, int mLength = 0, bool mGrow = false, int mGrowSpeed = 0, bool mPrimed = false, int mPrimeTime = 50, int mPrimeSurviveTime = 50)
        {
            var primeTimeline = new Timeline();
            var growTimeline = new Timeline();
            var drawTimeline = new Timeline();

            long radius = (mRadius/2)*(mRadius/2);

            var result = new BHEntity(mGame, "laser") {Position = mPosition, Velocity = BHUtils.CalculateVelocity(mAngle, mSpeed)};
            if (!mPrimed) result.AddGroup("deadlytoplayer");

            result.CollisionShape = mGrow ? new BHCSLine(result, mAngle, 0, radius) : new BHCSLine(result, mAngle, mLength, radius);
            result.BoundsOffset = -1000.ToUnits();

            result.Sprite = mSprite;
            result.Sprite.Rotation = mAngle;
            result.Sprite.Transform.Scale(1, result.Sprite.Texture.Size.Y);
            result.Sprite.Origin = new Vector2f(0, result.Sprite.Origin.Y);
            //result.Sprite.BlendMode = BlendMode.Add;
            result.IsSpriteFixed = true;

            float height = (mRadius*2).ToPixels();

            if (mPrimed) height = 1;
            // if (mPrimed) result.Sprite.BlendMode = BlendMode.Alpha;

            primeTimeline.Wait(mPrimeTime);
            primeTimeline.Action(() =>
                                 {
                                     result.AddGroup("deadlytoplayer");
                                     height = (mRadius*2).ToPixels();
                                     // result.Sprite.BlendMode = BlendMode.Add;
                                 });
            primeTimeline.Wait(mPrimeSurviveTime);
            primeTimeline.Action(result.Destroy);

            growTimeline.Action(() =>
                                {
                                    var lineShape = (BHCSLine) result.CollisionShape;
                                    if (lineShape.Length < mLength)
                                    {
                                        lineShape.Length += mGrowSpeed;
                                        result.Velocity = new Vector2i(0, 0);
                                    }
                                    else
                                    {
                                        result.Velocity = BHUtils.CalculateVelocity(mAngle, mSpeed);
                                        growTimeline.Finished = true;
                                    }
                                });
            growTimeline.Wait();
            growTimeline.Goto();

            drawTimeline.Action(() =>
                                {
                                    var lineShape = (BHCSLine) result.CollisionShape;
                                    result.Sprite.Rotation = lineShape.Degrees;
                                    result.Sprite.Transform.Scale(lineShape.Length.ToPixels(), height);
                                    result.Sprite.Origin = new Vector2f(0, result.Sprite.Origin.Y);
                                });
            drawTimeline.Wait();
            drawTimeline.Goto();

            if (mPrimed) result.TimelinesUpdate.Add(primeTimeline);
            result.TimelinesUpdate.Add(growTimeline);
            result.TimelinesDrawBefore.Add(drawTimeline);

            result.OnOutOfBounds += BHPresetOutOfBounds.Destroy;

            return result;
        }
        public static void EnemyMidboss1SpellCardAttack1(BHGame mGame, Vector2i mPosition)
        {
            Assets.GetSound("lazer00").Play();

            for (int i = 0; i < 60; i++)
            {
                BHEntity ent = BHPresetBase.Laser(mGame,
                                                  new Sprite(Assets.GetTexture("b_laser")),
                                                  mPosition, (360/12)*i + i, 0.5f.ToUnits() + i*10, 4.ToUnits(), 30.ToUnits() + (i*0.1f.ToUnits()), true, 250);

                var laserTimeline = new Timeline();
                int i1 = i;
                laserTimeline.AddCommand(new Do(() =>
                                                {
                                                    var lineShape = (BHCSLine) ent.CollisionShape;
                                                    lineShape.Degrees += i1/20f;
                                                    lineShape.Length += 0.7f.ToUnits();
                                                }));
                laserTimeline.AddCommand(new Wait(1));
                laserTimeline.AddCommand(new Goto(0, 145));

                ent.TimelinesUpdate.Add(laserTimeline);
            }
        }
        public static BHEntity Polygon(BHGame mGame, List<Vector2i> mVertices)
        {
            var drawTimeline = new Timeline();

            var result = new BHEntity(mGame, "deadlytoplayer") {Position = mGame.Center};
            result.CollisionShape = new BHCSPolygon(result, mVertices.ToArray());

            drawTimeline.Action(() =>
                                {
                                    var shape = (BHCSPolygon) result.CollisionShape;
                                    //foreach (Vector2i vertex in shape.Vertices) mGame.WindowManager.RenderWindow.Draw(new CircleShape(new Vector2f(vertex.X.ToPixels(), vertex.Y.ToPixels()), 2, Color.Red));
                                });
            drawTimeline.Wait();
            drawTimeline.Goto();

            result.TimelinesDrawBefore.Add(drawTimeline);

            return result;
        }
        public static BHEntity PlayerBullet(BHGame mGame, Vector2i mPosition = default(Vector2i), float mAngle = 0, int mSpeed = 0)
        {
            var result = new BHEntity(mGame, "playerbullet") {Position = mPosition, Velocity = BHUtils.CalculateVelocity(mAngle, mSpeed)};
            result.CollisionShape = new BHCSPoint(result);
            result.CollisionAgainstGroups.Add("enemy");

            result.OnCollision += (entity, group) =>
                                  {
                                      if (group == "enemy")
                                      {
                                          entity.Sprite.Color = new Color((byte) Utils.Random.Next(0, 255), (byte) Utils.Random.Next(0, 255), (byte) Utils.Random.Next(0, 255));
                                          entity.Parameters["health"] = (int) entity.Parameters["health"] - 1;
                                          result.Destroy();
                                          Assets.GetSound("se_damage00").Play();
                                      }
                                  };

            result.OnOutOfBounds += BHPresetOutOfBounds.Destroy;

            return result;
        }
        public static void EnemyMidboss1SpellCardAttack2(BHGame mGame, Vector2i mPosition)
        {
            Assets.GetSound("lazer00").Play();

            for (int i = 1; i < 12; i++)
            {
                int nextX = mGame.Bounds.Left + (mGame.Bounds.Width/12*i);
                BHPresetBase.Laser(mGame, new Sprite(Assets.GetTexture("b_laser")), new Vector2i(nextX, 0), 90,
                                   4.ToUnits(), 5.ToUnits(), 30.ToUnits(), true, 2.5f.ToUnits());
            }
        }
        public static BHEntity EnemyFairyBig1(BHGame mGame, Vector2i mPosition, string mTexture)
        {
            BHEntity result = BHPresetBase.Enemy(mGame, 30.ToUnits(), 40);

            result.Sprite = new Sprite(Assets.GetTexture(mTexture));
            result.IsSpriteFixed = true;
            result.Position = mPosition;

            BHPresetTimelines.Kill(result, 900);

            // MOVEMENT TIMELINES
            var timelineMovement = new Timeline();
            timelineMovement.Action(() => result.Velocity = new Vector2i(0, 150));
            timelineMovement.Wait(100);
            timelineMovement.Action(() => result.Velocity = new Vector2i(0, 0));
            timelineMovement.Wait(500);
            timelineMovement.Action(() => result.Velocity = new Vector2i(0, -150));
            // -------------------

            // ATTACK TIMELINES
            var timelineAttack = new Timeline();
            timelineAttack.Parameters["angle"] = 0;
            timelineAttack.AddCommand(new Do(() =>
                                             {
                                                 var angle = (int) timelineAttack.Parameters["angle"];
                                                 for (int i = 0; i < 24; i++)
                                                 {
                                                     BHPresetBullets.Glow1(mGame, result.Position, (360/24)*i + angle, 5.ToUnits());
                                                     BHPresetBullets.Glow1(mGame, result.Position, (360/24)*i - angle, 5.ToUnits());
                                                 }
                                                 timelineAttack.Parameters["angle"] = angle + 20;
                                             }));
            timelineAttack.AddCommand(new Wait(25));
            timelineAttack.AddCommand(new Goto(0, 50));

            var timelineAttack2 = new Timeline();
            timelineAttack2.AddCommand(new Do(() =>
                                              {
                                                  Assets.GetSound("tan00").Play();
                                                  for (int i = 0; i < 16; i++)
                                                  {
                                                      var bulletTimeline = new Timeline();
                                                      BHEntity bullet = BHPresetBullets.RoundSmall(mGame, result.Position, (360/16)*i, 1.ToUnits());

                                                      bulletTimeline.AddCommand(new Wait(50));
                                                      bulletTimeline.AddCommand(new Do(() =>
                                                                                       {
                                                                                           Assets.GetSound("kira01").Play();
                                                                                           var player = (BHEntity) mGame.Manager.EntityDictionary["player"][0];
                                                                                           float angle = BHUtils.GetAngleTowards(bullet, player) + Utils.Random.Next(-8, 8);
                                                                                           var newVelocity = Utils.Math.Angles.ToVectorDegrees(angle)*4.ToUnits();
                                                                                           bullet.Velocity = new Vector2i((int) newVelocity.X, (int) newVelocity.Y);
                                                                                       }));

                                                      bullet.TimelinesUpdate.Add(bulletTimeline);
                                                  }
                                              }));
            timelineAttack2.AddCommand(new Wait(50));
            timelineAttack2.AddCommand(new Goto(0, 50));
            // -------------------

            result.TimelinesUpdate.Add(timelineMovement);
            result.TimelinesUpdate.Add(timelineAttack);
            result.TimelinesUpdate.Add(timelineAttack2);

            return result;
        }
 public static void EnemyFairy1Attack(BHGame mGame, Vector2i mPosition, Color mColor, int mMultiplier = 1)
 {
     Assets.GetSound("tan01").Play();
     for (int i = 0; i < 10*mMultiplier; i++) BHPresetBullets.RoundFull(mGame, mPosition, Utils.Random.Next(0, 360), Utils.Random.Next(2.ToUnits(), 4.ToUnits())).Sprite.Color = mColor;
 }
        public static BHStage TestScriptStage2(BHGame mGame)
        {
            var result = new BHStage();
            var stageTimeline = new Timeline();

            // FIRST FAIRY WAVE
            for (int i = 0; i < 200; i++)
            {
                int i1 = i;
                var position = new Vector2i();
                if (i%2 == 0) position = new Vector2i(mGame.Bounds.Right, 0);

                stageTimeline.Wait(5);
                stageTimeline.Action(() => EnemyFairy1(mGame, position, i1%2 != 0, "enemyfairy"));
            }
            // -------------------

            // DISPLAY STAGE IMAGE
            stageTimeline.Wait(150);
            stageTimeline.Action(() => BHPresetStageControl.CutIn(mGame, result, Assets.GetTexture("st01logo"), mOffset: new Vector2i(0, -50000), mLength: 200));
            // -------------------

            // FIRST BIG FAIRY
            stageTimeline.Wait(50);
            stageTimeline.Action(() => EnemyFairyBig1(mGame, new Vector2i(mGame.Center.X, 0), "enemyfairybig"));
            // -------------------

            // SECOND FAIRY WAVE
            stageTimeline.Wait(200);
            for (int i = 0; i < 50; i++)
            {
                int i1 = i;
                var position = new Vector2i();
                if (i%2 == 0) position = new Vector2i(mGame.Bounds.Right, 0);

                stageTimeline.Wait(8);
                stageTimeline.Action(() => EnemyFairy1(mGame, position, i1%2 != 0, "enemyfairy", 2));
            }
            // -------------------

            // SECOND AND THIRD BIG FAIRIES
            stageTimeline.Wait(180);
            stageTimeline.Action(() => EnemyFairyBig1(mGame, new Vector2i(mGame.Center.X - 100.ToUnits(), 0), "enemyfairybig"));
            stageTimeline.Action(() => EnemyFairyBig1(mGame, new Vector2i(mGame.Center.X + 100.ToUnits(), 0), "enemyfairybig"));
            stageTimeline.Wait(500);
            // -------------------

            // MIDBOSS WITH 1 SPELLCARD
            stageTimeline.Action(() => EnemyMidboss1(mGame, new Vector2i(mGame.Center.X, 0)));
            // -------------------

            result.TimelinesUpdate.Add(stageTimeline);

            return result;
        }
 public static void EnemyMidboss1SpellCardAttack3(BHGame mGame, Vector2i mPosition)
 {
     Assets.GetSound("tan02").Play();
     for (int i = 0; i < 85; i++) BHPresetBullets.Pellet(mGame, mPosition, Utils.Random.Next(0, 360), Utils.Random.Next(0.8f.ToUnits(), 3.5f.ToUnits()));
 }
        public static void SpellCard(BHGame mGame, BHStage mStage, BHEntity mBoss, string mSpellCardName, int mHealth, int mTime, int mScore, Timeline mOnEnd, params Timeline[] mTimelines)
        {
            var spellCardTimeline = new Timeline();

            mBoss.Parameters["health"] = mHealth;

            var drawEvents = new List<Action>();

            var spellCardText = new Text(mSpellCardName, Font.DefaultFont)
                                {
                                    Position = new Vector2f(32, 16),
                                    Color = Color.White,
                                    CharacterSize = 15,
                                };
            var mTimeText = new Text(mTime.ToString(), Font.DefaultFont)
                            {
                                Position = new Vector2f(384, 16),
                                Color = Color.White,
                                CharacterSize = 15
                            };

            Action spellCardTextDrawEvent = () => mGame.GameWindow.RenderWindow.Draw(spellCardText);
            drawEvents.Add(spellCardTextDrawEvent);
            mGame.AddDrawAction(spellCardTextDrawEvent);

            Action timeTextDrawEvent = () => mGame.GameWindow.RenderWindow.Draw(mTimeText);
            drawEvents.Add(timeTextDrawEvent);
            mGame.AddDrawAction(timeTextDrawEvent);

            mStage.TimelinesUpdate.AddRange(mTimelines);

            Assets.GetSound("cat00").Play();

            spellCardTimeline.Action(() =>
                                     {
                                         mTime--;
                                         mTimeText.DisplayedString = mTime.ToString();
                                     });
            spellCardTimeline.Wait();
            spellCardTimeline.AddCommand(new GotoConditional(() => mTime < 1 || (int) mBoss.Parameters["health"] < 1, 0, -1));
            spellCardTimeline.Action(() =>
                                     {
                                         foreach (var drawEvent in drawEvents) mGame.RemoveDrawAction(drawEvent);
                                         foreach (var timeline in mTimelines) timeline.Finished = true;
                                         ClearBullets(mGame, mStage);
                                         if (mOnEnd != null) mStage.TimelinesUpdate.Add(mOnEnd);
                                     });

            mStage.TimelinesUpdate.Add(spellCardTimeline);
        }
        public static BHEntity Player(BHGame mGame, int mSpeedNormal, int mSpeedFocus, Animation mAnimationLeft, Animation mAnimationRight, Animation mAnimationStill)
        {
            var updateTimeline = new Timeline();
            var drawTimeline = new Timeline();

            var hitboxSprite = new Sprite(Assets.GetTexture("p_hitbox"));

            var result = new BHEntity(mGame, "character", "player") {DrawOrder = -10000, IsSpriteFixed = true, BoundsOffset = 10.ToUnits(), Animation = mAnimationStill};
            result.CollisionShape = new BHCSPoint(result);
            result.CollisionAgainstGroups.Add("deadlytoplayer");

            result.OnOutOfBounds += BHPresetOutOfBounds.Stop;
            result.OnCollision += (entity, group) => { if (group == "deadlytoplayer") Assets.GetSound("pldead00").Play(); };

            updateTimeline.Action(() =>
                                  {
                                      int speed = mGame.Focus == 1 ? mSpeedFocus : mSpeedNormal;

                                      if (mGame.NextX != 0 && mGame.NextY != 0) speed = (int) (speed*0.7);

                                      if (mGame.NextX > 0 && mAnimationRight != null) result.Animation = mAnimationRight;
                                      else if (mGame.NextX < 0 && mAnimationLeft != null) result.Animation = mAnimationLeft;
                                      else if (mAnimationStill != null) result.Animation = mAnimationStill;

                                      result.Velocity = new Vector2i(mGame.NextX*speed, mGame.NextY*speed);

                                      hitboxSprite.Rotation++;
                                  });
            updateTimeline.Wait();
            updateTimeline.Goto();

            drawTimeline.Action(() =>
                                {
                                    if (mGame.Focus == 0) return;
                                    hitboxSprite.Origin = new Vector2f(32, 32);
                                    hitboxSprite.Position = new Vector2f(result.Position.X.ToPixels(), result.Position.Y.ToPixels());
                                    mGame.GameWindow.RenderWindow.Draw(hitboxSprite);
                                });
            drawTimeline.Wait();
            drawTimeline.Goto();

            result.TimelinesUpdate.Add(updateTimeline);
            result.TimelinesDrawAfter.Add(drawTimeline);

            return result;
        }
 public BHBeatTapper(BHGame mGame)
 {
     Game = mGame;
     Reset();
 }
        public static BHEntity EnemyMidboss1(BHGame mGame, Vector2i mPosition)
        {
            BHEntity result = BHPresetBase.Boss(mGame, 30.ToUnits(), 100);

            result.Sprite = Assets.GetTileset("stg7enm").GetSprite("s1", Assets.GetTexture("stg7enm"));
            result.IsSpriteFixed = true;
            result.Position = mPosition;
            result.Animation = Assets.GetAnimation("stg7enmstill");

            // MOVEMENT TIMELINES
            var startTimeline = new Timeline();
            startTimeline.AddCommand(new Do(() => result.Velocity = new Vector2i(0, 0.7f.ToUnits())));
            startTimeline.AddCommand(new Wait(210));
            startTimeline.AddCommand(new Do(() => result.Velocity = new Vector2i(0, 0)));
            startTimeline.AddCommand(new Wait(25));
            startTimeline.AddCommand(new Do(() => EnemyMidboss1SpellCard1(mGame, result)));
            // -------------------

            result.TimelinesUpdate.Add(startTimeline);

            return result;
        }