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 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);
        }
Exemplo n.º 4
0
        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;
        }