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);
        }
Example #2
0
        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;
        }
Example #3
0
        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 Destroy(BHEntity mEntity, Vector2i mDirection, Rectangle mBounds, int mBoundsOffset)
 {
     mEntity.Destroy();
 }