public override void DoAfterDead(ObjectBase killer, ObjectDeadType deadType)
        {
            if (Owner.DrawObject == DrawNull.Value || (DeadType & deadType) != deadType)
            {
                return;
            }

            double angle = Function.GetAngle(0, 0, Owner.MoveObject.MoveX, Owner.MoveObject.MoveY);

            for (int i = 0; i < ScrapCount; i++)
            {
                int    speed          = Global.Rand.Next(ScrapSpeedMin, Math.Max(ScrapSpeedMin, ScrapSpeedMax));
                int    fadeTime       = Global.Rand.Next(ScrapLifeMin, Math.Max(ScrapLifeMin, ScrapLifeMax));
                double scrapDirection = angle + (Global.Rand.NextDouble() - 0.5) * Radiation;

                MoveStraight moveObject = new MoveStraight(null, 1, speed, 1, 0, 1);
                moveObject.Target.SetOffsetByAngle(scrapDirection, 1000);
                ObjectSmoke newObject;
                if (ScrapDrawObject == null)
                {
                    newObject = new ObjectSmoke(Owner.Layout.CenterX, Owner.Layout.CenterY, ScrapWidth, ScrapHeight, fadeTime, 1, 0, Owner.DrawObject.MainColor, moveObject);
                }
                else
                {
                    DrawBase scrapDraw = ScrapDrawObject.Copy();
                    scrapDraw.Angle = Global.Rand.Next(360);
                    newObject       = new ObjectSmoke(Owner.Layout.CenterX, Owner.Layout.CenterY, ScrapWidth, ScrapHeight, fadeTime, 1, 0, scrapDraw, moveObject);
                    newObject.Propertys.Add(new PropertyRotate(-1, Global.Rand.Next(280, 520), false, true));
                }
                moveObject.Target.SetObject(newObject);
                Owner.Container.Add(newObject);
            }

            base.DoAfterDead(killer, deadType);
        }
Example #2
0
        public override void DoAfterAction()
        {
            if (BuildTime.IsFull)
            {
                for (int i = 0; i < BombCount; i++)
                {
                    int    speed         = Global.Rand.Next(BombSpeedMin, Math.Max(BombSpeedMin, BombSpeedMax) + 1);
                    int    life          = Global.Rand.Next(BombLifeMin, Math.Max(BombLifeMin, BombLifeMax) + 1);
                    double bombDirection = Global.Rand.NextDouble() * 360;

                    MoveStraight moveObject = new MoveStraight(null, 1, speed, 1, 0, 1);
                    moveObject.Target.SetOffsetByAngle(bombDirection, 1000);

                    DrawBase bombDraw;
                    if (BombDrawObject == null)
                    {
                        bombDraw = new DrawPolygon(Color.Empty, Owner.DrawObject.MainColor, 2, 2, Global.Rand.Next(0, 360))
                        {
                            RotateEnabled = true
                        };
                    }
                    else
                    {
                        bombDraw = BombDrawObject.Copy();
                    }

                    ObjectBase newObject = new ObjectBase(bombDraw, moveObject);
                    newObject.Layout.Anchor        = DirectionType.Center;
                    newObject.Layout.CollisonShape = ShapeType.Ellipse;
                    newObject.Layout.Width         = BombWidth;
                    newObject.Layout.Height        = BombHeight;
                    newObject.Layout.X             = Owner.Layout.CenterX;
                    newObject.Layout.Y             = Owner.Layout.CenterY;
                    newObject.League     = Owner.League;
                    newObject.Life.Limit = life;

                    newObject.Propertys.Add(new PropertyRotate(-1, Global.Rand.Next(280, 360), false, true));
                    newObject.Propertys.Add(new PropertyDeadExplosion(8, 0, 1, LeagueType.Ememy1, Color.FromArgb(180, 225, 70, 40), 0, 1, 2, ObjectDeadType.All)
                    {
                        DrawRange = false
                    });
                    newObject.Propertys.Add(new PropertyCollision(1));

                    moveObject.Target.SetObject(newObject);
                    Owner.Container.Add(newObject);
                }
                BuildTime.Value = 0;
            }
            else
            {
                BuildTime.Value += Scene.SceneIntervalOfRound;
            }
            base.DoAfterAction();
        }
Example #3
0
        /// <summary>
        /// 技能生效
        /// </summary>
        public override void DoBeforeAction()
        {
            switch (Status)
            {
            case SkillStatus.Enabled:
            {
                if (Owner == null)
                {
                    Break();
                    return;
                }

                Owner.Skills.AllBreak();
                _OwnerSpeed            = Owner.MoveObject.Speed;
                Owner.MoveObject.Speed = 0;
                Status   = SkillStatus.Channeled;
                _MiniBar = new PropertyUI(-1, new Size(30, 6), new DrawUICounterBar(Color.FromArgb(80, 210, 140), Color.Black, Color.White, 1, true, Channeled));
                Owner.Propertys.Add(_MiniBar);
            }
            break;

            case SkillStatus.Channeled:
                int getEnergy = (int)(GetEnergyPerSec / Scene.SceneRoundPerSec + 0.5F);
                Owner.Energy.Value += getEnergy;

                if (Animation.IsFull)
                {
                    MoveStraight moveZZZ = new MoveStraight(null, 1, 150, 3, 100, 1F);
                    DrawCustom   drawZZZ = new DrawCustom();
                    drawZZZ.Colors.SetColor("Main", Color.DarkGreen);
                    drawZZZ.AfterDraw += (x, g, r) =>
                    {
                        Pen     pen      = drawZZZ.Colors.GetPen("Main");
                        Point[] drawPots = { new Point(r.Left,           r.Top),
                                             new Point(r.Left + r.Width, r.Top),
                                             new Point(r.Left,           r.Top + r.Height),
                                             new Point(r.Left + r.Width, r.Top + r.Height) };
                        g.DrawLines(pen, drawPots);
                    };
                    ObjectSmoke objectZZZ = new ObjectSmoke(Owner.Layout.CenterX, Owner.Layout.CenterY, 4, 4, Scene.Sec(1), 3F, 0, drawZZZ, moveZZZ);
                    moveZZZ.Target.SetOffsetByAngle(315 + Global.Rand.Next(-20, 20), 50);
                    moveZZZ.Target.SetObject(objectZZZ);
                    Owner.Container.Add(objectZZZ);
                    Animation.Value = 0;
                }
                Animation.Value += Scene.SceneIntervalOfRound;
                break;
            }
            base.DoBeforeAction();
        }
Example #4
0
        public override void DoAfterAction()
        {
            if (ScrapDrawObject == null && Owner.DrawObject == DrawNull.Value)
            {
                return;
            }

            if (BuildTime.IsFull)
            {
                for (int i = 0; i < ScrapCount; i++)
                {
                    int    speed          = Global.Rand.Next(ScrapSpeedMin, Math.Max(ScrapSpeedMin, ScrapSpeedMax) + 1);
                    int    life           = Global.Rand.Next(ScrapLifeMin, Math.Max(ScrapLifeMin, ScrapLifeMax) + 1);
                    double scrapDirection = Global.Rand.NextDouble() * 360;

                    MoveStraight moveObject = new MoveStraight(null, 1, speed, 1, 0, 1);
                    moveObject.Target.SetOffsetByAngle(scrapDirection, 1000);
                    ObjectSmoke newObject;
                    if (ScrapDrawObject == null)
                    {
                        newObject = new ObjectSmoke(Owner.Layout.CenterX, Owner.Layout.CenterY, ScrapWidth, ScrapHeight, life, 1, 0, Owner.DrawObject.MainColor, moveObject);
                    }
                    else
                    {
                        DrawBase scrapDraw = ScrapDrawObject.Copy();
                        scrapDraw.Angle = Global.Rand.Next(360);
                        newObject       = new ObjectSmoke(Owner.Layout.CenterX, Owner.Layout.CenterY, ScrapWidth, ScrapHeight, life, 1, 0, scrapDraw, moveObject);
                        newObject.Propertys.Add(new PropertyRotate(-1, Global.Rand.Next(280, 520), false, true));
                    }
                    moveObject.Target.SetObject(newObject);
                    Owner.Container.Add(newObject);
                }
                BuildTime.Value = 0;
            }
            else
            {
                BuildTime.Value += Scene.SceneIntervalOfRound;
            }
            base.DoAfterAction();
        }
Example #5
0
 public override void Release(ITargetability target)
 {
     if (Status == SkillStatus.Channeled)
     {
         PointF targetPoint = Scene.GetTargetPoint(DirectionType.Center);
         double angle = Function.GetAngle(Owner.Layout.CenterX, Owner.Layout.CenterY, targetPoint.X, targetPoint.Y);
         float partAngle = Radiation / (float)BulletCount;
         float shotAngle = (float)angle - (partAngle * BulletCount / 2);
         for (int i = 0; i < BulletCount; i++)
         {
             MoveStraight bulletMove = new MoveStraight(null, 1, 600, 1, 0, 1);
             ObjectActive bullet = new ObjectActive(Owner.Layout.CenterX, Owner.Layout.CenterY, 5, 5, Scene.Sec(0.5F), Owner.League, ShapeType.Ellipse, new DrawBrush(Owner.DrawObject.MainColor, ShapeType.Ellipse), bulletMove);
             bullet.Propertys.Add(new PropertyCollision(AttackPower));
             bullet.Propertys.Add(new PropertyDeadBroken(5, 2, 2, ObjectDeadType.All, 360, 40, 100, Scene.Sec(0.2F), Scene.Sec(0.3F)));
             bulletMove.Target.SetOffsetByAngle(shotAngle, 1000);
             bulletMove.Target.SetObject(bullet);
             bullet.Dead += (s, k, t) =>
             {
                 if (t == ObjectDeadType.Collision)
                 {
                     SceneGaming scene = Scene as SceneGaming;
                     if (scene != null)
                     {
                         scene.AddScoreToPlayer("擊中", 150);
                     }
                 }
             };
             Owner.Container.Add(bullet);
             shotAngle += partAngle;
         }
         Owner.MoveObject.AddToNextOffset(Function.GetOffsetPoint(0, 0, angle + 180, 500));
         Cursor.Position = Scene.PointToScreen(new Point((int)Owner.Layout.CenterX, (int)Owner.Layout.CenterY));
         Status = SkillStatus.Cooldown;
         OnEnd(SkillEndType.Finish);
     }
     base.Release(target);
 }
Example #6
0
        /// <summary>
        /// 技能生效
        /// </summary>
        public override void DoBeforeAction()
        {
            switch (Status)
            {
            case SkillStatus.Enabled:
            {
                if (Owner == null || Owner.MoveObject.Target.TargetType == TargetType.None)
                {
                    Break();
                    return;
                }

                // 新增誘餌物件
                double angle = Function.GetAngle(Owner.Layout.CenterX, Owner.Layout.CenterY, Owner.MoveObject.Target.X, Owner.MoveObject.Target.Y);

                MoveStraight move = new MoveStraight(null, Owner.MoveObject.Resistance, BaitSpeed, 1, 0, 1F);
                move.Target.SetOffsetByAngle(angle, 1000);

                DrawBase draw = Owner.DrawObject.Copy();
                draw.Colors.Opacity = 0.6F;

                ObjectActive bait = new ObjectActive(Owner.Layout, BaitLife, Owner.League, draw, move);
                move.Target.SetObject(bait);

                bait.Propertys.Add(new PropertySpeeded(-1, -(BaitSpeed / (float)BaitLife * 800)));
                bait.Propertys.Add(new PropertyCollision(0));         // 強度碰撞

                // 新增雜訊物件
                int        noiseWidth  = Owner.Layout.Width + 2;
                int        noiseHeight = (int)(Owner.Layout.Height * 1.3F + 0.5F) + 5;
                DrawNoise  drawNoise   = new DrawNoise(Owner.DrawObject.MainColor, Color.White, 1);
                ObjectWave noise       = new ObjectWave(0, 0, noiseWidth, noiseHeight, noiseWidth * 3, noiseHeight * 3, -1, 0, drawNoise, MoveNull.Value);
                noise.DiffusionOpacity = 0;
                noise.Layout.Depend.SetObject(bait);
                Owner.Container.Add(bait);
                Owner.Container.Add(noise);

                // 將目標設為誘餌
                for (int i = 0; i < Owner.Container.Count; i++)
                {
                    ObjectBase objectBase = Owner.Container[i];
                    if (objectBase.Status != ObjectStatus.Alive || Function.IsFriendly(objectBase.League, Owner.League))
                    {
                        continue;
                    }
                    if (objectBase.MoveObject.Target.Object == Owner)
                    {
                        objectBase.MoveObject.Target.SetObject(bait);
                    }
                }

                bait.Dead += (s, e, t) =>
                {
                    noise.DiffusionTime.Limit = Scene.Sec(0.2F);
                    noise.DiffusionTime.Value = 0;

                    if (Owner == null)
                    {
                        return;
                    }
                    for (int i = 0; i < Owner.Container.Count; i++)
                    {
                        ObjectBase objectBase = Owner.Container[i];
                        if (objectBase.Status != ObjectStatus.Alive)
                        {
                            continue;
                        }
                        if (objectBase.MoveObject.Target.Object == s)
                        {
                            objectBase.MoveObject.Target.SetObject(Owner);
                        }
                    }

                    SceneGaming scene = Scene as SceneGaming;
                    if (t == ObjectDeadType.LifeEnd && scene != null)
                    {
                        scene.AddScoreToPlayer("誘餌生還", 300);
                    }
                };
                Status = SkillStatus.Cooldown;
            }
            break;
            }

            base.DoBeforeAction();
        }
Example #7
0
        public SceneStand()
        {
            InitializeComponent();

            // 場景:畫面變黑暗
            WaveEvents.Add("@Dark", (n) =>
            {
                EffectObjects.Add(new EffectDyeing(Color.Black, Wave(0.5F), Wave(Math.Max(n - 1, 0)), Wave(0.5F)));
            });

            // 場景:邊界縮小
            WaveEvents.Add("@Shrink", (n) =>
            {
                double scaleX = Global.Rand.NextDouble();
                double scaleY = 1 - scaleX;

                int limitX     = (int)(scaleX * MainRectangle.Width * 0.4F);
                int limitY     = (int)(scaleY * MainRectangle.Height * 0.4F);
                int limitLeft  = Global.Rand.Next(0, limitX);
                int limitTop   = Global.Rand.Next(0, limitY);
                int limitRight = limitX - limitLeft;
                int limitDown  = limitY - limitTop;

                Padding shrinkPerRound = new Padding(limitLeft, limitTop, limitRight, limitDown);
                EffectObjects.Add(new EffectShrink(shrinkPerRound, Wave(0.5F), Wave(Math.Max(n - 1, 0)), Wave(0.5F)));
            });

            // 物件:追捕者
            WaveEvents.Add("Catcher", (n) =>
            {
                int roundIdx = Global.Rand.Next(4);
                for (int i = 0; i < n; i++)
                {
                    int size         = Global.Rand.Next(7, 12);
                    int offsetLimit  = size + Global.Rand.Next(5, 10);
                    float speed      = Global.Rand.Next(320, 380) * _SpeedFix;
                    float weight     = 0.3F + size * 0.1F;
                    int life         = Sec(3.5F * _LifeFix) + Global.Rand.Next(0, 5);
                    Point enterPoint = GetEnterPoint(roundIdx);

                    MoveStraight moveObject = new MoveStraight(PlayerObject, weight, speed, offsetLimit, 100, 0.5F);
                    ObjectActive newObject  = new ObjectActive(enterPoint.X, enterPoint.Y, size, size, life, LeagueType.Ememy1, ShapeType.Ellipse, new DrawBrush(Color.Red, ShapeType.Ellipse), moveObject);
                    newObject.Skills.Add(new SkillSprint(0, Sec(1.5F), 15, 0, true)
                    {
                        AutoCastObject = new AutoCastNormal(0.4F)
                    });
                    newObject.Skills.Add(new SkillSprint(0, Sec(0.5F), 5, 0, false)
                    {
                        AutoCastObject = new AutoCastNormal(3F)
                    });
                    newObject.Propertys.Add(new PropertyDeadBroken(15, 2, 2, ObjectDeadType.Collision, 30, 150, 400, Sec(0.5F), Sec(0.9F)));
                    newObject.Propertys.Add(new PropertyDeadCollapse(1, Sec(0.6F), Sec(0.01F), 2, 2, ObjectDeadType.LifeEnd, 50, 100, Sec(0.15F), Sec(0.25F)));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    GameObjects.Add(newObject);
                    roundIdx = ++roundIdx % 4;
                }
            });

            // 物件:快速追捕者 速度更快 更常使用加速
            WaveEvents.Add("Faster", (n) =>
            {
                int roundIdx = Global.Rand.Next(4);
                for (int i = 0; i < n; i++)
                {
                    int size         = Global.Rand.Next(6, 8);
                    int offsetLimit  = size + Global.Rand.Next(2, 4);
                    float speed      = Global.Rand.Next(400, 460) * _SpeedFix;
                    float weight     = 0.3F + size * 0.1F;
                    int life         = Sec(4.5F * _LifeFix) + Global.Rand.Next(0, 5);
                    Point enterPoint = GetEnterPoint(roundIdx);

                    MoveStraight moveObject = new MoveStraight(PlayerObject, weight, speed, offsetLimit, 100, 0.5F);
                    ObjectActive newObject  = new ObjectActive(enterPoint.X, enterPoint.Y, size, size, life, LeagueType.Ememy1, ShapeType.Ellipse, new DrawBrush(Color.Blue, ShapeType.Ellipse), moveObject);
                    newObject.Skills.Add(new SkillSprint(0, Sec(1F), 8, 0, true)
                    {
                        AutoCastObject = new AutoCastNormal(1F)
                    });
                    newObject.Skills.Add(new SkillSprint(0, Sec(0.5F), 4, 0, false)
                    {
                        AutoCastObject = new AutoCastNormal(3F)
                    });
                    newObject.Propertys.Add(new PropertyDeadBroken(15, 2, 2, ObjectDeadType.Collision, 20, 150, 400, Sec(0.5F), Sec(0.9F)));
                    newObject.Propertys.Add(new PropertyDeadCollapse(1, Sec(0.6F), Sec(0.01F), 2, 2, ObjectDeadType.LifeEnd, 50, 100, Sec(0.15F), Sec(0.25F)));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    GameObjects.Add(newObject);
                    roundIdx = ++roundIdx % 4;
                }
            });

            // 物件:流星 四面八方的直線前進物件
            WaveEvents.Add("Meteor", (n) =>
            {
                int roundIdx = Global.Rand.Next(4);
                for (int i = 0; i < n; i++)
                {
                    int size         = 10;
                    int movesCount   = 6;
                    float speed      = 500 * _SpeedFix;
                    float weight     = 0.3F + size * 0.1F;
                    int life         = Sec(10F);
                    Point enterPoint = GetEnterPoint(roundIdx);

                    double angel            = Function.GetAngle(enterPoint.X, enterPoint.Y, PlayerObject.Layout.CenterX, PlayerObject.Layout.CenterY) + Global.Rand.Next(-20, 20);
                    MoveStraight moveObject = new MoveStraight(null, weight, speed, movesCount, 0, 1F);
                    moveObject.Target.SetOffsetByAngle(angel, 1000F);
                    ObjectActive newObject = new ObjectActive(enterPoint.X, enterPoint.Y, size, size, life, LeagueType.Ememy1, ShapeType.Ellipse, new DrawBrush(Color.Orchid, ShapeType.Ellipse), moveObject);
                    newObject.Propertys.Add(new PropertyDeadBroken(15, 2, 2, ObjectDeadType.Collision, 20, 150, 400, Sec(0.5F), Sec(0.9F)));
                    newObject.Propertys.Add(new PropertyDeadCollapse(1, Sec(0.6F), Sec(0.01F), 2, 2, ObjectDeadType.LifeEnd, 50, 100, Sec(0.15F), Sec(0.25F)));
                    newObject.Propertys.Add(new PropertySmoking(-1, Sec(0.2F)));
                    newObject.Propertys.Add(new PropertyFreeze(Sec(0.2F * i)));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    newObject.Propertys.Add(new PropertyOutClear());
                    moveObject.Target.SetObject(newObject);
                    GameObjects.Add(newObject);
                    roundIdx = ++roundIdx % 4;
                }
            });

            // 物件:水平牆壁(有缺口)
            WaveEvents.Add("WallA", (n) =>
            {
                List <ObjectActive> objects = new List <ObjectActive>();
                for (int i = 0; i < MainRectangle.Height + 60; i += 30)
                {
                    int movesCount          = 6;
                    float speed             = 700 * (10 + n) / 10F;
                    float weight            = 3;
                    int life                = Sec(10F);
                    MoveStraight moveObject = new MoveStraight(null, weight, speed, movesCount, 0, 1F);
                    moveObject.Target.SetOffsetByXY(1000F, 0);
                    DrawBrush drawObject = new DrawBrush(Color.Orchid, ShapeType.Rectangle)
                    {
                        RotateEnabled = false
                    };
                    //DrawPolygon drawObject = new DrawPolygon(Color.Orchid, Color.Orchid, 2, 5, 0) { RotateEnabled = false };
                    ObjectActive newObject = new ObjectActive(-50, MainRectangle.Top + i - 20, 5, 28, life, LeagueType.Ememy1, ShapeType.Ellipse, drawObject, moveObject);
                    //newObject.Propertys.Add(new PropertyRotate(-1, 780, false, true));
                    //newObject.Propertys.Add(new PropertyDeadBroken(new DrawBrush(Color.Orchid, ShapeType.Rectangle), 15, 6, 6, ObjectDeadType.Collision | ObjectDeadType.LifeEnd, 20, 200, 600, Sec(0.6F), Sec(1.2F)));
                    newObject.Propertys.Add(new PropertyDeadBrokenShaping(15, 6, 6, ObjectDeadType.Collision | ObjectDeadType.LifeEnd, 20, 100, 300, Sec(0.6F), Sec(1.2F)));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    newObject.Propertys.Add(new PropertyOutClear());
                    moveObject.Target.SetObject(newObject);
                    GameObjects.Add(newObject);
                    objects.Add(newObject);
                }

                int clearCount = 2;
                int clearIndex = Global.Rand.Next(1, objects.Count - 2 - clearCount + 1);
                for (int i = 0; i < clearCount; i++)
                {
                    objects[clearIndex + i].Kill(null, ObjectDeadType.Clear);
                }
            });

            // 物件:水平牆壁(交錯)
            WaveEvents.Add("WallB", (n) =>
            {
                List <ObjectActive> objects = new List <ObjectActive>();
                int midRand   = 50;
                int cot       = MainRectangle.Height + 60 / 30;
                int offsetMid = 100 / cot;
                for (int i = 0; i < MainRectangle.Height + 60; i += 30)
                {
                    int movesCount = 6;
                    float speed    = 700 * (10 + n) / 10F;
                    float weight   = 3;
                    int life       = Sec(10F);
                    int enterX;
                    int moveX;
                    if (Global.Rand.Next(100) > midRand)
                    {
                        enterX   = -50;
                        moveX    = 1000;
                        midRand += offsetMid;
                    }
                    else
                    {
                        enterX   = Width + 50;
                        moveX    = -1000;
                        midRand -= offsetMid;
                    }

                    MoveStraight moveObject = new MoveStraight(null, weight, speed, movesCount, 0, 1F);
                    moveObject.Target.SetOffsetByXY(moveX, 0);
                    DrawPolygon drawObject = new DrawPolygon(Color.Orchid, Color.Orchid, 2, 5, 0)
                    {
                        RotateEnabled = true
                    };
                    ObjectActive newObject = new ObjectActive(enterX, MainRectangle.Top + i - 20, 28, 28, life, LeagueType.Ememy1, ShapeType.Ellipse, drawObject, moveObject);
                    newObject.Propertys.Add(new PropertyRotate(-1, 780, false, true));
                    newObject.Propertys.Add(new PropertyDeadBrokenShaping(15, 6, 6, ObjectDeadType.Collision | ObjectDeadType.LifeEnd, 20, 100, 300, Sec(0.6F), Sec(1.2F)));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    newObject.Propertys.Add(new PropertyOutClear());
                    moveObject.Target.SetObject(newObject);
                    GameObjects.Add(newObject);
                    objects.Add(newObject);
                }
            });

            // 物件:序列 排列成直線的追捕者
            WaveEvents.Add("Series", (n) =>
            {
                Point enterPoint = GetEnterPoint();
                int size         = Global.Rand.Next(10, 12);
                int movesCount   = 6;
                float speed      = Global.Rand.Next(300, 400) * _SpeedFix;
                float weight     = 0.3F + size * 0.1F;
                int life         = Sec(6F * _LifeFix) + Global.Rand.Next(0, 5);

                ObjectActive target     = PlayerObject;
                ObjectActive lastObject = null;
                for (int i = 0; i < n; i++)
                {
                    MoveStraight moveObject = new MoveStraight(target, weight, speed, movesCount, 30, 1F);
                    ObjectActive newObject  = new ObjectActive(enterPoint.X, enterPoint.Y, size, size, life, LeagueType.Ememy1, ShapeType.Ellipse, new DrawBrush(Color.DarkOrange, ShapeType.Ellipse), moveObject);
                    newObject.Propertys.Add(new PropertyFreeze(Sec(i * 0.05F)));
                    newObject.Propertys.Add(new PropertyDeadBroken(15, 2, 2, ObjectDeadType.Collision, 40, 150, 400, Sec(0.5F), Sec(0.9F)));
                    newObject.Propertys.Add(new PropertyDeadCollapse(1, Sec(0.2F), Sec(0.01F), 2, 2, ObjectDeadType.LifeEnd, 50, 100, Sec(0.15F), Sec(0.25F)));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    GameObjects.Add(newObject);
                    target = newObject;
                    speed += 10;
                    life  -= 50;
                    if (lastObject != null)
                    {
                        lastObject.Dead += (x, e, t) =>
                        {
                            newObject.MoveObject.Target.SetObject((x as ObjectActive).MoveObject.Target.Object);
                        };
                    }
                    lastObject = newObject;
                }
            });

            // 物件:轟炸機
            WaveEvents.Add("Bomber", (n) =>
            {
                int roundIdx = Global.Rand.Next(4);
                for (int i = 0; i < n; i++)
                {
                    Point enterPoint = GetEnterPoint(roundIdx);
                    int size         = Global.Rand.Next(28, 34);
                    int movesCount   = 6;
                    float speed      = Global.Rand.Next(300, 380);
                    float weight     = 0.3F + size * 0.1F;
                    double angle     = Function.GetAngle(enterPoint.X, enterPoint.Y, MainRectangle.Left + MainRectangle.Width / 2, MainRectangle.Top + MainRectangle.Height / 2) + Global.Rand.Next(-20, 20);
                    int life         = Sec(10F);

                    MoveStraight moveObject = new MoveStraight(null, weight, speed, movesCount, 30, 1F);
                    DrawPic drawObject      = new DrawPic(Color.Black, Properties.Resources.Bomber, (float)angle);
                    drawObject.Colors.RFix  = 0.7F;
                    drawObject.Colors.BFix  = 0.5F;
                    //DrawPolygon drawObject = new DrawPolygon(Color.SlateBlue, Color.SlateBlue, 3, 1, (float)angle);
                    ObjectActive newObject = new ObjectActive(enterPoint.X, enterPoint.Y, size, size, life, LeagueType.Ememy1, ShapeType.Ellipse, drawObject, moveObject);
                    moveObject.Target.SetOffsetByAngle(angle, 1000);
                    moveObject.Target.SetObject(newObject);

                    newObject.Propertys.Add(new PropertyAlert(-1));
                    newObject.Propertys.Add(new PropertyDeadBroken(30, 2, 2, ObjectDeadType.Collision, 40, 150, 400, Sec(0.5F), Sec(0.9F)));
                    newObject.Propertys.Add(new PropertyCollision(10));
                    newObject.Propertys.Add(new PropertyShadow(4, 6));
                    newObject.Propertys.Add(new PropertyBomber(-1, Sec(0.2F), 3, 8, 8, 5, 80, Sec(1F), Sec(1.4F)));
                    newObject.Propertys.Add(new PropertyOutClear());
                    GameObjects.Add(newObject);
                    roundIdx = ++roundIdx % 4;
                }
            });

            // 物件:攔截者 不會加速 但速度會越來越快
            WaveEvents.Add("Blocker", (n) =>
            {
                int roundIdx = Global.Rand.Next(4);
                for (int i = 0; i < n; i++)
                {
                    int size         = Global.Rand.Next(14, 17);
                    int movesCount   = 2;
                    float weight     = 0.3F + size * 0.1F;
                    float speed      = 200 * _SpeedFix;
                    int life         = Sec(6F * _LifeFix) + Global.Rand.Next(0, 5);
                    Point enterPoint = GetEnterPoint(roundIdx);

                    MoveStraight moveObject = new MoveStraight(PlayerObject, weight, speed, movesCount, 100, 0.5F);
                    DrawPolygon drawObject  = new DrawPolygon(Color.Fuchsia, Color.Fuchsia, 3, 1, 0)
                    {
                        RotateEnabled = true, Resistance = weight
                    };
                    ObjectActive newObject = new ObjectActive(enterPoint.X, enterPoint.Y, size, size, life, LeagueType.Ememy1, ShapeType.Ellipse, drawObject, moveObject);
                    newObject.Propertys.Add(new PropertyRotate(-1, 360, false, false));
                    newObject.Propertys.Add(new PropertyDeadBroken(15, 2, 2, ObjectDeadType.Collision, 60, 150, 400, Sec(0.5F), Sec(0.9F)));
                    newObject.Propertys.Add(new PropertyDeadCollapse(1, Sec(0.6F), Sec(0.01F), 2, 2, ObjectDeadType.LifeEnd, 50, 100, Sec(0.15F), Sec(0.25F)));
                    newObject.Propertys.Add(new PropertyCollision(10));
                    newObject.Propertys.Add(new PropertySpeeded(-1, 100));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    GameObjects.Add(newObject);
                    roundIdx = ++roundIdx % 4;
                }
            });

            // 物件:地雷
            WaveEvents.Add("Mine", (n) =>
            {
                int roundIdx = Global.Rand.Next(4);
                for (int i = 0; i < n; i++)
                {
                    int size       = Global.Rand.Next(16, 20);
                    int movesCount = Global.Rand.Next(10, 15);
                    float speed    = Global.Rand.Next(200, 300);
                    float weight   = 0.3F + size * 0.1F;
                    int life       = Sec(4);

                    Point enterPoint = Point.Empty;
                    int targetX      = 0, targetY = 0;
                    switch (roundIdx)
                    {
                    case 0:
                        enterPoint = GetEnterPoint(DirectionType.Left);
                        targetX    = MainRectangle.Left + Global.Rand.Next(MainRectangle.Width / 2);
                        targetY    = MainRectangle.Top + Global.Rand.Next(MainRectangle.Height);
                        break;

                    case 1:
                        enterPoint = GetEnterPoint(DirectionType.Right);
                        targetX    = MainRectangle.Left + MainRectangle.Width / 2 + Global.Rand.Next(MainRectangle.Width / 2);
                        targetY    = MainRectangle.Top + Global.Rand.Next(MainRectangle.Height);
                        break;

                    case 2:
                        enterPoint = GetEnterPoint(DirectionType.Top);
                        targetX    = MainRectangle.Left + Global.Rand.Next(MainRectangle.Width);
                        targetY    = MainRectangle.Top + Global.Rand.Next(MainRectangle.Height / 2);
                        break;

                    case 3:
                        enterPoint = GetEnterPoint(DirectionType.Bottom);
                        targetX    = MainRectangle.Left + Global.Rand.Next(MainRectangle.Width);
                        targetY    = MainRectangle.Top + MainRectangle.Height / 2 + Global.Rand.Next(MainRectangle.Height / 2);
                        break;
                    }

                    MoveStraight moveObject = new MoveStraight(new PointObject(targetX, targetY), weight, speed, movesCount, 100, 0.5F);
                    DrawPic drawObject      = new DrawPic(Color.Black, Properties.Resources.Mine, 0)
                    {
                        RotateEnabled = true, Resistance = weight
                    };
                    ObjectActive newObject = new ObjectActive(enterPoint.X, enterPoint.Y, size, size, life, LeagueType.Ememy1, ShapeType.Ellipse, drawObject, moveObject);
                    newObject.Propertys.Add(new PropertyRotate(-1, 280, false, false));
                    newObject.Propertys.Add(new PropertyDeadExplosion(10, 0, 1, LeagueType.Chaos, Color.FromArgb(180, 225, 70, 40), 0.15F, 0.1F, 5, ObjectDeadType.Collision | ObjectDeadType.LifeEnd));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    GameObjects.Add(newObject);
                    roundIdx = ++roundIdx % 4;
                }
            });

            // 物件:分裂地雷
            WaveEvents.Add("MineSplit", (n) =>
            {
                int size       = Global.Rand.Next(28, 30);
                int movesCount = Global.Rand.Next(10, 15);
                float speed    = Global.Rand.Next(200, 300);
                float weight   = 0.3F + size * 0.1F;
                int life       = Sec(4);

                Point enterPoint = GetEnterPoint();
                int targetX      = MainRectangle.Left + MainRectangle.Width / 2 + Global.Rand.Next(-40, 40);
                int targetY      = MainRectangle.Top + MainRectangle.Height / 2 + Global.Rand.Next(-40, 40);

                MoveStraight moveObject = new MoveStraight(new PointObject(targetX, targetY), weight, speed, movesCount, 100, 0.5F);
                DrawPic drawObject      = new DrawPic(Color.Black, Properties.Resources.Mine, 0)
                {
                    RotateEnabled = true, Resistance = weight
                };
                drawObject.Colors.BFix = 0.5F;
                ObjectActive newObject = new ObjectActive(enterPoint.X, enterPoint.Y, size, size, life, LeagueType.Ememy1, ShapeType.Ellipse, drawObject, moveObject);
                newObject.Propertys.Add(new PropertyRotate(-1, 280, false, false));
                newObject.Propertys.Add(new PropertyDeadExplosion(10, 0, 1, LeagueType.None, Color.FromArgb(180, 225, 70, 40), 0.15F, 0.1F, 5, ObjectDeadType.Collision | ObjectDeadType.LifeEnd));
                newObject.Propertys.Add(new PropertyCollision(1));
                newObject.Propertys.Add(new PropertyShadow(2, 3));
                newObject.Dead += (x, e, t) =>
                {
                    float partAngle = 360F / n;
                    float baseAngle = Global.Rand.Next(360);
                    for (int i = 0; i < n; i++)
                    {
                        int size2                = Global.Rand.Next(16, 18);
                        float speed2             = Global.Rand.Next(150, 250);
                        float weight2            = 0.3F + size2 * 0.1F;
                        int life2                = Sec(1.5F);
                        MoveStraight moveObject2 = new MoveStraight(null, weight2, speed2, movesCount, 0, 1F);
                        moveObject2.Target.SetOffsetByAngle(baseAngle, 1000);
                        DrawPic drawObject2 = new DrawPic(Color.Black, Properties.Resources.Mine, 0)
                        {
                            RotateEnabled = true, Resistance = weight2
                        };
                        drawObject2.Colors.BFix = 0.5F;
                        ObjectActive newObject2 = new ObjectActive(x.Layout.CenterX, x.Layout.CenterY, size2, size2, life2, LeagueType.Ememy1, ShapeType.Ellipse, drawObject2, moveObject2);
                        newObject2.Propertys.Add(new PropertyRotate(-1, 280, false, false));
                        newObject2.Propertys.Add(new PropertyDeadExplosion(10, 0, 1, LeagueType.None, Color.FromArgb(180, 225, 70, 40), 0.15F, 0.1F, 5, ObjectDeadType.Collision | ObjectDeadType.LifeEnd));
                        newObject2.Propertys.Add(new PropertyCollision(1));
                        newObject2.Propertys.Add(new PropertyShadow(2, 3));
                        moveObject2.Target.SetObject(newObject2);

                        newObject2.Dead += (x2, e2, t2) =>
                        {
                            float baseAngle2 = Global.Rand.Next(360);
                            for (int j = 0; j < n; j++)
                            {
                                int size3                = Global.Rand.Next(8, 10);
                                float speed3             = Global.Rand.Next(150, 250);
                                float weight3            = 0.3F + size3 * 0.1F;
                                int life3                = Sec(1.5F);
                                MoveStraight moveObject3 = new MoveStraight(null, weight3, speed3, movesCount, 0, 1F);
                                moveObject3.Target.SetOffsetByAngle(baseAngle2, 1000);
                                DrawPic drawObject3 = new DrawPic(Color.Black, Properties.Resources.Mine, 0)
                                {
                                    RotateEnabled = true, Resistance = weight3
                                };
                                drawObject3.Colors.BFix = 0.5F;
                                ObjectActive newObject3 = new ObjectActive(x2.Layout.CenterX, x2.Layout.CenterY, size3, size3, life3, LeagueType.Ememy1, ShapeType.Ellipse, drawObject3, moveObject3);
                                newObject3.Propertys.Add(new PropertyRotate(-1, 280, false, false));
                                newObject3.Propertys.Add(new PropertyDeadExplosion(10, 0, 1, LeagueType.None, Color.FromArgb(180, 225, 70, 40), 0.15F, 0.1F, 5, ObjectDeadType.Collision | ObjectDeadType.LifeEnd));
                                newObject3.Propertys.Add(new PropertyCollision(1));
                                newObject3.Propertys.Add(new PropertyShadow(2, 3));
                                moveObject3.Target.SetObject(newObject2);
                                GameObjects.Add(newObject3);
                                baseAngle2 += partAngle;
                            }
                        };

                        GameObjects.Add(newObject2);
                        baseAngle += partAngle;
                    }
                };
                GameObjects.Add(newObject);
            });
        }
        protected override void OnAfterAction()
        {
            switch (_Mode)
            {
            case 1:
                if (_CommandBack.DrawObject.Colors.Opacity < 1)
                {
                    _CommandBack.DrawObject.Colors.Opacity += 0.05F;
                }

                if (_BackDrak < 1)
                {
                    _BackDrak += 0.05F;

                    if (_BackDrak > 1)
                    {
                        _BackDrak = 1;
                    }
                    DrawObject.Colors.RFix = DrawObject.Colors.GFix = DrawObject.Colors.BFix = -_BackDrak * 1F;
                    for (int i = 0; i < BackObjects.Count; i++)
                    {
                        BackObjects[i].DrawObject.Colors.RFix = BackObjects[i].DrawObject.Colors.GFix = _BackDrak * 1F;
                    }
                }
                break;

            case 0:
                if (_CommandBack.DrawObject.Colors.Opacity > 0)
                {
                    _CommandBack.DrawObject.Colors.Opacity -= 0.1F;
                    if (_CommandBack.DrawObject.Colors.Opacity <= 0)
                    {
                        _CommandBack.Visible = false;
                    }
                }

                if (_BackDrak > 0)
                {
                    _BackDrak -= 0.05F;

                    if (_BackDrak < 0)
                    {
                        _BackDrak = 0;
                    }
                    DrawObject.Colors.RFix = DrawObject.Colors.GFix = DrawObject.Colors.BFix = -_BackDrak * 1F;
                    for (int i = 0; i < BackObjects.Count; i++)
                    {
                        BackObjects[i].DrawObject.Colors.RFix = BackObjects[i].DrawObject.Colors.GFix = _BackDrak * 1F;
                    }
                }
                break;
            }

            if (_BackBuildCounter.IsFull)
            {
                int          Size       = Global.Rand.Next(2, 5);
                int          top        = Layout.Rectangle.Top + Global.Rand.Next(5, Layout.RectHeight - 10);
                MoveStraight moveObject = new MoveStraight(null, 1, Size * Global.Rand.Next(120, 180) - 80, 1, 100, 0);
                ObjectSmoke  newObject  = new ObjectSmoke(-10, top, Size, Size, -1, 1, 1, Color.FromArgb(50, 50, 50), moveObject);
                newObject.DrawObject.Colors.RFix = newObject.DrawObject.Colors.GFix = _BackDrak * 1F;
                moveObject.Target.SetObject(newObject);
                moveObject.Target.SetOffsetByXY(1000, 0);
                moveObject.Resistance = Mode == 1 ? 10 : 1;
                BackObjects.Add(newObject);
                _BackBuildCounter.Value = 0;
            }
            else
            {
                _BackBuildCounter.Value += Scene.IntervalOfRound;
            }
            base.OnAfterAction();
        }
        public override void DoAfterDead(ObjectBase killer, ObjectDeadType deadType)
        {
            if (Owner.DrawObject == DrawNull.Value || (DeadType & deadType) != deadType)
            {
                return;
            }

            double    angle         = Function.GetAngle(0, 0, Owner.MoveObject.MoveX, Owner.MoveObject.MoveY);
            DrawBase  drawObject    = Owner.DrawObject;
            Rectangle baseRectangle = Owner.Layout.Rectangle;
            Rectangle drawRectangle;

            if (drawObject.Scale > 1)
            {
                drawRectangle = drawObject.GetScaleRectangle(baseRectangle);
                baseRectangle.Location.Offset(-drawRectangle.Location.X, -drawRectangle.Location.Y);
                drawRectangle.Location = new Point(0, 0);
            }
            else
            {
                baseRectangle.Location = new Point(0, 0);
                drawRectangle          = baseRectangle;
            }

            List <Point> getPoints = new List <Point>();

            using (Bitmap image = new Bitmap(drawRectangle.Width, drawRectangle.Height))
                using (Graphics g = Graphics.FromImage(image))
                {
                    Owner.DrawObject.Draw(g, baseRectangle);
                    BitmapData bitData = image.LockBits(drawRectangle, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                    IntPtr     scan0   = bitData.Scan0;
                    unsafe
                    {
                        byte *p = (byte *)scan0.ToPointer();
                        for (int y = 0; y < drawRectangle.Height; y++)
                        {
                            for (int x = 0; x < drawRectangle.Width; x++)
                            {
                                if (p[3] > 0)
                                {
                                    getPoints.Add(new Point(x, y));
                                }
                                p += 4;
                            }
                        }
                    }
                    image.UnlockBits(bitData);
                    if (getPoints.Count == 0)
                    {
                        return;
                    }

                    int idxPlus = ((getPoints.Count - 1) / ScrapCount) + 1;
                    int idx     = Global.Rand.Next(idxPlus);
                    for (int i = 0; i < ScrapCount; i++)
                    {
                        Point  point    = getPoints[idx];
                        PointF putPoint = new PointF(Owner.Layout.CenterX - (drawRectangle.Width / 2) + point.X,
                                                     Owner.Layout.CenterY - (drawRectangle.Height / 2) + point.Y);

                        int    speed          = Global.Rand.Next(ScrapSpeedMin, Math.Max(ScrapSpeedMin, ScrapSpeedMax));
                        int    fadeTime       = Global.Rand.Next(ScrapLifeMin, Math.Max(ScrapLifeMin, ScrapLifeMax));
                        double scrapDirection = angle + (Global.Rand.NextDouble() - 0.5) * Radiation;

                        MoveStraight moveObject = new MoveStraight(null, 1, speed, 1, 0, 1);
                        moveObject.Target.SetOffsetByAngle(scrapDirection, 1000);
                        ObjectSmoke newObject;
                        if (ScrapDrawObject == null)
                        {
                            Color drawColor = image.GetPixel(point.X, point.Y);
                            newObject = new ObjectSmoke(putPoint.X, putPoint.Y, ScrapWidth, ScrapHeight, fadeTime, 1, 0, drawColor, moveObject);
                        }
                        else
                        {
                            DrawBase scrapDraw = ScrapDrawObject.Copy();
                            scrapDraw.Angle = Global.Rand.Next(360);
                            newObject       = new ObjectSmoke(putPoint.X, putPoint.Y, ScrapWidth, ScrapHeight, fadeTime, 1, 0, scrapDraw, moveObject);
                            newObject.Propertys.Add(new PropertyRotate(-1, Global.Rand.Next(280, 520), false, true));
                        }
                        moveObject.Target.SetObject(newObject);
                        Owner.Container.Add(newObject);

                        idx += idxPlus;
                        if (idx >= getPoints.Count)
                        {
                            idx = Global.Rand.Next(idxPlus);
                        }
                    }
                }
            base.DoAfterDead(killer, deadType);
        }
Example #10
0
        protected override void OnLoadComplete()
        {
            base.OnLoadComplete();

            int   drawWidth  = 400;
            int   drawHeight = 150;
            int   drawLeft   = (Width - drawWidth) / 2;
            int   drawTop    = (Height - drawHeight) / 2;
            int   partCountX = _StringPoint[0].Length;
            int   partCountY = _StringPoint.Length;
            int   partWidth  = drawWidth / partCountX;
            int   partHeight = drawHeight / partCountY;
            float delay      = 0;

            int[,] map = new int[partCountX, partCountY];
            // 建立關連圖
            for (int x = 0; x < partCountX; x++)
            {
                for (int y = 0; y < partCountY; y++)
                {
                    if (_StringPoint[y][x] == '0')
                    {
                        bool checkRight  = x + 1 < partCountX;
                        bool checkBottom = y + 1 < partCountY;
                        bool checkLeft   = x - 1 >= 0;

                        if (checkRight)
                        {
                            map[x + 1, y] |= 1; // 右
                        }

                        if (checkBottom)
                        {
                            map[x, y + 1] |= 2; // 下
                        }

                        if (checkRight && checkBottom)
                        {
                            map[x + 1, y + 1] |= 4; // 右下
                        }

                        if (checkLeft && checkBottom)
                        {
                            map[x - 1, y + 1] |= 8; // 左下
                        }
                    }
                    else
                    {
                        map[x, y] = -1;
                    }
                }
            }

            byte[] linkIdx     = { 0, 1, 2, 4, 8 };
            int[]  linkOffsetX = { 0, -1, 0, -1, 1 };
            int[]  linkOffsetY = { 0, 0, -1, -1, -1 };
            for (int x = 0; x < partCountX; x++)
            {
                for (int y = 0; y < partCountY; y++)
                {
                    int mapValue = map[x, y];
                    if (mapValue >= 0)
                    {
                        Point        enterPoint  = GetEnterPoint();
                        int          size        = Global.Rand.Next(6, 8);
                        int          speed       = Global.Rand.Next(1800, 2200);
                        PointF       targetPoint = new PointF(drawLeft + x * partWidth, drawTop + y * partHeight);
                        MoveStraight moveObject  = new MoveStraight(new PointObject(targetPoint), 1, speed, 1, 100, 1F);
                        ObjectActive bigBall     = new ObjectActive(enterPoint.X, enterPoint.Y, size, size, -1, LeagueType.None, ShapeType.Ellipse, new DrawPen(Color.FromArgb(150, 0, 0, 0), ShapeType.Ellipse, 4), moveObject);
                        bigBall.Propertys.Add(new PropertyFreeze(Sec(delay)));
                        GameObjects.Add(bigBall);

                        for (int i = 0; i < linkIdx.Length; i++)
                        {
                            if ((mapValue & linkIdx[i]) == linkIdx[i])
                            {
                                int smallballCount = Global.Rand.Next(2, 3);
                                for (int n = 0; n < smallballCount; n++)
                                {
                                    Point        enterPoint2 = GetEnterPoint();
                                    int          size2       = Global.Rand.Next(3, 8);
                                    int          speed2      = Global.Rand.Next(1400, 1600);
                                    float        fx          = 1 - size2 * 0.02F;
                                    int          targetFixX  = (partWidth * linkOffsetX[i] / 2) + (int)((0.5F - Global.Rand.NextDouble()) * partWidth * fx + 0.5F);
                                    int          targetFixY  = (partHeight * linkOffsetY[i] / 2) + (int)((0.5F - Global.Rand.NextDouble()) * partHeight * fx + 0.5F);
                                    PointF       target2     = new PointF(targetPoint.X + targetFixX, targetPoint.Y + targetFixY);
                                    MoveStraight moveObject2 = new MoveStraight(new PointObject(target2), 1, speed2, 1, 100, 1F);
                                    Color        color2      = Color.FromArgb(Global.Rand.Next(200), Global.Rand.Next(200), Global.Rand.Next(200));
                                    ObjectActive smallBall   = new ObjectActive(enterPoint2.X, enterPoint2.Y, size2, size2, -1, LeagueType.None, ShapeType.Ellipse, new DrawBrush(color2, ShapeType.Ellipse), moveObject2);
                                    smallBall.Propertys.Add(new PropertyFreeze(Sec(0.75F + (float)Global.Rand.NextDouble() * 0.5F)));
                                    GameObjects.Add(smallBall);
                                }
                            }
                        }
                    }
                    delay += 0.003F;
                }
            }
        }
Example #11
0
        public SceneDisco()
        {
            InitializeComponent();

            // 場景:畫面變黑暗
            WaveEvents.Add("@Dark", (n) =>
            {
                EffectObjects.Add(new EffectDyeing(Color.Black, Wave(0.1F), Wave(Math.Max(n, 0)), Wave(0.1F)));
            });

            // 場景:邊界縮小
            WaveEvents.Add("@Shrink", (n) =>
            {
                double scaleX = Global.Rand.NextDouble();
                double scaleY = 1 - scaleX;

                int limitX     = (int)(scaleX * MainRectangle.Width * 0.4F);
                int limitY     = (int)(scaleY * MainRectangle.Height * 0.4F);
                int limitLeft  = Global.Rand.Next(0, limitX);
                int limitTop   = Global.Rand.Next(0, limitY);
                int limitRight = limitX - limitLeft;
                int limitDown  = limitY - limitTop;

                Padding shrinkPerRound = new Padding(limitLeft, limitTop, limitRight, limitDown);
                EffectObjects.Add(new EffectShrink(shrinkPerRound, Wave(0.1F), Wave(Math.Max(n, 0)), Wave(0.1F)));
            });

            // 物件:追捕者
            WaveEvents.Add("Catcher", (n) =>
            {
                int roundIdx = Global.Rand.Next(4);
                for (int i = 0; i < n; i++)
                {
                    int size         = Global.Rand.Next(9, 11);
                    int offsetLimit  = 10;
                    float speed      = Global.Rand.Next(200, 240) * _SpeedFix;
                    float weight     = 0.3F + size * 0.1F;
                    int life         = Sec(6F * _LifeFix) + Global.Rand.Next(0, 5);
                    Point enterPoint = GetEnterPoint(roundIdx);

                    MoveFrog moveObject    = new MoveFrog(PlayerObject, weight, speed, offsetLimit, Sec(1F));
                    ObjectActive newObject = new ObjectActive(enterPoint.X, enterPoint.Y, size, size, life, LeagueType.Ememy1, ShapeType.Ellipse, new DrawBrush(Color.Red, ShapeType.Ellipse), moveObject);
                    newObject.Propertys.Add(new PropertyDeadBroken(15, 2, 2, ObjectDeadType.Collision, 20, 150, 400, Sec(0.5F), Sec(0.9F)));
                    newObject.Propertys.Add(new PropertyDeadCollapse(1, Sec(0.6F), Sec(0.01F), 2, 2, ObjectDeadType.LifeEnd, 50, 100, Sec(0.15F), Sec(0.25F)));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    GameObjects.Add(newObject);
                    roundIdx = ++roundIdx % 4;
                }
            });

            // 物件:快速追捕者 移動間格減半
            WaveEvents.Add("Faster", (n) =>
            {
                int roundIdx = Global.Rand.Next(4);
                for (int i = 0; i < n; i++)
                {
                    int size         = Global.Rand.Next(6, 8);
                    int offsetLimit  = 10;
                    float speed      = Global.Rand.Next(275, 320) * _SpeedFix;
                    float weight     = 0.3F + size * 0.1F;
                    int life         = Sec(4.5F * _LifeFix) + Global.Rand.Next(0, 5);
                    Point enterPoint = GetEnterPoint(roundIdx);

                    MoveFrog moveObject    = new MoveFrog(PlayerObject, weight, speed, offsetLimit, Sec(0.5F));
                    ObjectActive newObject = new ObjectActive(enterPoint.X, enterPoint.Y, size, size, life, LeagueType.Ememy1, ShapeType.Ellipse, new DrawBrush(Color.Blue, ShapeType.Ellipse), moveObject);
                    newObject.Propertys.Add(new PropertyDeadBroken(15, 2, 2, ObjectDeadType.Collision, 20, 150, 400, Sec(0.5F), Sec(0.9F)));
                    newObject.Propertys.Add(new PropertyDeadCollapse(1, Sec(0.6F), Sec(0.01F), 2, 2, ObjectDeadType.LifeEnd, 50, 100, Sec(0.15F), Sec(0.25F)));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    GameObjects.Add(newObject);
                    roundIdx = ++roundIdx % 4;
                }
            });

            // 物件:蜻蜓 固定方向且會左右擺動
            WaveEvents.Add("Dragonfly", (n) =>
            {
                for (int i = 0; i < n; i++)
                {
                    int size         = Global.Rand.Next(14, 18);
                    int offsetLimit  = 10;
                    float speed      = Global.Rand.Next(220, 260) * _SpeedFix;
                    float weight     = 0.3F + size * 0.1F;
                    int life         = -1;
                    Point enterPoint = GetEnterPoint(DirectionType.Right);

                    MoveFrog moveObject    = new MoveFrog(null, weight, speed, offsetLimit, Sec(1F));
                    DrawPolygon drawObject = new DrawPolygon(Color.BlueViolet, Color.BlueViolet, 3, 0, 0)
                    {
                        RotateEnabled = true
                    };
                    ObjectActive newObject = new ObjectActive(enterPoint.X, enterPoint.Y, size, size, life, LeagueType.Ememy1, ShapeType.Ellipse, drawObject, moveObject);
                    newObject.Propertys.Add(new PropertyDeadBroken(15, 2, 2, ObjectDeadType.Collision, 20, 150, 400, Sec(0.5F), Sec(0.9F)));
                    newObject.Propertys.Add(new PropertyDeadCollapse(1, Sec(0.6F), Sec(0.01F), 2, 2, ObjectDeadType.LifeEnd, 50, 100, Sec(0.15F), Sec(0.25F)));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    newObject.Propertys.Add(new PropertyOutClear());
                    newObject.Propertys.Add(new PropertyDelay(Sec(0.5F), new PropertyDrunken(-1, Sec(1F), -45, 45, Global.Rand.Next(2) == 0 ? 100 : -100)));
                    newObject.Propertys.Add(new PropertyRotateTarget(-1, 400, true));
                    moveObject.Target.SetObject(newObject);
                    moveObject.Target.SetOffsetByXY(-1000, 0);
                    GameObjects.Add(newObject);
                }
            });

            // 物件:水平牆壁
            WaveEvents.Add("WallA", (n) =>
            {
                List <ObjectActive> objects = new List <ObjectActive>();
                for (int i = 0; i < MainRectangle.Height + 60; i += 30)
                {
                    int movesCount      = 6;
                    float speed         = 300 * (10 + n) / 10F;
                    float weight        = 3;
                    int life            = -1;
                    MoveFrog moveObject = new MoveFrog(null, weight, speed, movesCount, Sec(1));
                    moveObject.Target.SetOffsetByXY(1000F, 0);
                    DrawBrush drawObject = new DrawBrush(Color.Orchid, ShapeType.Rectangle)
                    {
                        RotateEnabled = false
                    };
                    ObjectActive newObject = new ObjectActive(-50, MainRectangle.Top + i - 20, 5, 28, life, LeagueType.Ememy1, ShapeType.Ellipse, drawObject, moveObject);
                    newObject.Propertys.Add(new PropertyDeadBrokenShaping(15, 6, 6, ObjectDeadType.Collision | ObjectDeadType.LifeEnd, 20, 100, 300, Sec(0.6F), Sec(1.2F)));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    newObject.Propertys.Add(new PropertyOutClear());
                    moveObject.Target.SetObject(newObject);
                    GameObjects.Add(newObject);
                    objects.Add(newObject);
                }

                int clearCount = 2;
                int clearIndex = Global.Rand.Next(1, objects.Count - 2 - clearCount + 1);
                for (int i = 0; i < clearCount; i++)
                {
                    objects[clearIndex + i].Kill(null, ObjectDeadType.Clear);
                }
            });

            // 物件:箭雨(水平)
            WaveEvents.Add("Arrow", (n) =>
            {
                int baseTop = Global.Rand.Next(MainRectangle.Top - 20, MainRectangle.Top + MainRectangle.Height + 20 - ((n - 1) * 30));
                for (int i = 0; i < n; i++)
                {
                    int movesCount          = 12;
                    float weight            = 3;
                    int life                = -1;// Sec(10F);
                    MoveStraight moveObject = new MoveStraight(null, weight, 500, movesCount, 0, 1F);
                    moveObject.Target.SetOffsetByXY(1000F, 0);
                    DrawPolygon drawObject = new DrawPolygon(Color.Orchid, Color.Empty, 3, 1, 90F)
                    {
                        RotateEnabled = false
                    };
                    ObjectActive newObject = new ObjectActive(-30, baseTop, 25, 25, life, LeagueType.Ememy1, ShapeType.Ellipse, drawObject, moveObject);
                    newObject.Skills.Add(new SkillSprint(0, Sec(1F), 0, (int)(400000), false)
                    {
                        AutoCastObject = new AutoCastNormal(100), Status = SkillStatus.Cooldown
                    });
                    newObject.Propertys.Add(new PropertySpeeded(Sec(1F), -300));
                    newObject.Propertys.Add(new PropertyDeadBrokenShaping(15, 6, 6, ObjectDeadType.Collision | ObjectDeadType.LifeEnd, 20, 100, 300, Sec(0.6F), Sec(1.2F)));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    newObject.Propertys.Add(new PropertyOutClear());
                    moveObject.Target.SetObject(newObject);

                    GameObjects.Add(newObject);
                    baseTop += 30;
                }
            });

            // 物件:炸彈陣列
            WaveEvents.Add("BoomGrid", (n) =>
            {
                List <ObjectActive> objects = new List <ObjectActive>();
                for (int i = 0; i < MainRectangle.Height + 60; i += 120)
                {
                    int movesCount      = 6;
                    float speed         = 300 * (10 + n) / 10F;
                    float weight        = 3;
                    int life            = -1;
                    MoveFrog moveObject = new MoveFrog(null, weight, speed, movesCount, Sec(1));
                    moveObject.Target.SetOffsetByXY(1000F, 0);
                    DrawBrush drawObject = new DrawBrush(Color.Orchid, ShapeType.Rectangle)
                    {
                        RotateEnabled = false
                    };
                    ObjectActive newObject = new ObjectActive(-50, MainRectangle.Top + i - 20, 5, 28, life, LeagueType.Ememy1, ShapeType.Ellipse, drawObject, moveObject);
                    newObject.Propertys.Add(new PropertyDeadBrokenShaping(15, 6, 6, ObjectDeadType.Collision | ObjectDeadType.LifeEnd, 20, 100, 300, Sec(0.6F), Sec(1.2F)));
                    newObject.Propertys.Add(new PropertyCollision(1));
                    newObject.Propertys.Add(new PropertyShadow(2, 3));
                    newObject.Propertys.Add(new PropertyOutClear());
                    moveObject.Target.SetObject(newObject);
                    GameObjects.Add(newObject);
                    objects.Add(newObject);
                }

                int clearCount = 2;
                int clearIndex = Global.Rand.Next(1, objects.Count - 2 - clearCount + 1);
                for (int i = 0; i < clearCount; i++)
                {
                    objects[clearIndex + i].Kill(null, ObjectDeadType.Clear);
                }
            });
        }