Example #1
0
        protected override IEnumerable <bool> E_Draw()
        {
            double x1;
            double x2;

            if (this.FacingLeft)
            {
                x1 = DDGround.ICamera.X;
                x2 = this.X;
            }
            else
            {
                x1 = this.X;
                x2 = DDGround.ICamera.X + DDConsts.Screen_W;
            }
            double y1 = this.Y - 2.0;
            double y2 = this.Y + 2.0;

            if (x2 < x1 + 2.0)
            {
                goto endFunc;
            }

            DDDraw.SetAlpha(0.2 + 0.1 * Math.Sin(DDEngine.ProcFrame / 2.0));
            DDDraw.SetBright(0.0, 1.0, 1.0);
            DDDraw.DrawRect_LTRB(
                Ground.I.Picture.WhiteBox,
                x1 - DDGround.ICamera.X,
                y1 - DDGround.ICamera.Y,
                x2 - DDGround.ICamera.X,
                y2 - DDGround.ICamera.Y
                );
            DDDraw.Reset();

            if (DDEngine.ProcFrame % 5 == 0)             // 間隔適当
            {
                this.Crash = DDCrashUtils.Rect(D4Rect.LTRB(x1, y1, x2, y2));
            }

            // 1回だけ true を返して1フレームだけ生存する必要がある。
            // -- 当たり判定時に、自弾リストに this が無いと this.Crash は参照されない。
            //
            yield return(true);            // 1フレームで消滅する。

endFunc:
            ;

            //yield break;
        }
Example #2
0
        public static IEnumerable <bool> Message(string message, I3Color color, I3Color borderColor)
        {
            Action a_draw_message = () =>
            {
                DDPrint.SetPrint(DDConsts.Screen_W / 2 - 4 * message.Length, DDConsts.Screen_H / 2 - 8);
                DDPrint.SetColor(color);
                DDPrint.SetBorder(borderColor);
                DDPrint.Print(message);
                DDPrint.Reset();
            };

            foreach (DDScene scene in DDSceneUtils.Create(20))
            {
                DDDraw.SetAlpha(0.5);
                DDDraw.SetBright(0, 0, 0);
                DDDraw.DrawRect_LTRB(
                    Ground.I.Picture.WhiteBox,
                    0,
                    DDConsts.Screen_H / 2 - (10 + 40 * scene.Rate),
                    DDConsts.Screen_W,
                    DDConsts.Screen_H / 2 + (10 + 40 * scene.Rate)
                    );
                DDDraw.Reset();

                a_draw_message();

                yield return(true);
            }
            foreach (DDScene scene in DDSceneUtils.Create(180))
            {
                DDDraw.SetAlpha(0.5);
                DDDraw.SetBright(0, 0, 0);
                DDDraw.DrawRect_LTRB(
                    Ground.I.Picture.WhiteBox,
                    0,
                    DDConsts.Screen_H / 2 - 50,
                    DDConsts.Screen_W,
                    DDConsts.Screen_H / 2 + 50
                    );
                DDDraw.Reset();

                a_draw_message();

                yield return(true);
            }
            foreach (DDScene scene in DDSceneUtils.Create(20))
            {
                DDDraw.SetAlpha(0.5);
                DDDraw.SetBright(0, 0, 0);
                DDDraw.DrawRect_LTRB(
                    Ground.I.Picture.WhiteBox,
                    0,
                    DDConsts.Screen_H / 2 - (10 + 40 * (1.0 - scene.Rate)),
                    DDConsts.Screen_W,
                    DDConsts.Screen_H / 2 + (10 + 40 * (1.0 - scene.Rate))
                    );
                DDDraw.Reset();

                a_draw_message();

                yield return(true);
            }
        }
Example #3
0
        public void Perform()
        {
            this.Player.X = DDConsts.Screen_W / 4;
            this.Player.Y = DDConsts.Screen_H / 2;

            this.Player.BornScene.Fire();

            DDCurtain.SetCurtain(10);

            for (; ; this.Frame++)
            {
                // プレイヤー行動
                {
                    bool   bornOrDead = this.Player.BornScene.IsFlaming() || this.Player.DeadScene.IsFlaming();
                    bool   dead       = this.Player.DeadScene.IsFlaming();
                    double xa         = 0.0;
                    double ya         = 0.0;

                    if (!dead && 1 <= DDInput.DIR_4.GetInput())                     // 左移動
                    {
                        xa = -1.0;
                    }
                    if (!dead && 1 <= DDInput.DIR_6.GetInput())                     // 右移動
                    {
                        xa = 1.0;
                    }
                    if (!dead && 1 <= DDInput.DIR_8.GetInput())                     // 上移動
                    {
                        ya = -1.0;
                    }
                    if (!dead && 1 <= DDInput.DIR_2.GetInput())                     // 下移動
                    {
                        ya = 1.0;
                    }

                    double speed;

                    if (1 <= DDInput.A.GetInput())                     // 低速ボタン押下中
                    {
                        speed = (double)this.Player.SpeedLevel;
                    }
                    else
                    {
                        speed = (double)(this.Player.SpeedLevel * 2);
                    }

                    this.Player.X += xa * speed;
                    this.Player.Y += ya * speed;

                    DDUtils.ToRange(ref this.Player.X, 0.0, DDConsts.Screen_W);
                    DDUtils.ToRange(ref this.Player.Y, 0.0, DDConsts.Screen_H);

                    if (!bornOrDead && 1 <= DDInput.B.GetInput())                     // 攻撃ボタン押下中
                    {
                        this.Player.Shoot();
                    }

                    if (DDInput.L.GetInput() == 1)
                    {
                        this.Player.SpeedLevel--;
                    }
                    if (DDInput.R.GetInput() == 1)
                    {
                        this.Player.SpeedLevel++;
                    }
                    DDUtils.ToRange(ref this.Player.SpeedLevel, Player.SPEED_LEVEL_MIN, Player.SPEED_LEVEL_MAX);
                }

                {
                    DDScene scene = this.Player.BornScene.GetScene();

                    if (scene.Numer != -1)
                    {
                        if (scene.Remaining == 0)
                        {
                            this.Player.MutekiScene.FireDelay();
                        }
                    }
                }

                {
                    DDScene scene = this.Player.DeadScene.GetScene();

                    if (scene.Numer != -1)
                    {
                        if (scene.Remaining == 0)
                        {
                            if (this.Status.RemainingLiveCount <= 0)
                            {
                                break;
                            }

                            this.Status.RemainingLiveCount--;
                            this.Player.BornScene.FireDelay();
                        }
                    }
                }

                {
                    DDScene scene = this.Player.MutekiScene.GetScene();

                    if (scene.Numer != -1)
                    {
                        // noop
                    }
                }

                if (this.Scenario.EachFrame() == false)
                {
                    break;
                }

                this.EnemyEachFrame();
                this.WeaponEachFrame();

                DDCrashView cv = DDKey.GetInput(DX.KEY_INPUT_LSHIFT) == 0 ? null : new DDCrashView();

                // Crash
                {
                    DDCrash playerCrash = DDCrashUtils.Point(new D2Point(this.Player.X, this.Player.Y));

                    foreach (WeaponBox weapon in this.Weapons.Iterate())
                    {
                        weapon.Crash = weapon.Value.GetCrash();
                    }

                    foreach (EnemyBox enemy in this.Enemies.Iterate())
                    {
                        DDCrash enemyCrash = enemy.Value.GetCrash();

                        if (cv != null)
                        {
                            cv.Draw(enemyCrash);
                        }

                        foreach (WeaponBox weapon in this.Weapons.Iterate())
                        {
                            if (enemyCrash.IsCrashed(weapon.Crash))
                            {
                                if (enemy.Value.Crashed(weapon.Value) == false)                                 // ? 消滅
                                {
                                    enemy.Dead = true;
                                }

                                if (weapon.Value.Crashed(enemy.Value) == false)                                 // ? 消滅
                                {
                                    weapon.Dead = true;
                                }
                            }
                        }
                        this.Weapons.RemoveAll(weapon => weapon.Dead);

                        if (this.Player.BornScene.IsFlaming() == false &&
                            this.Player.DeadScene.IsFlaming() == false &&
                            this.Player.MutekiScene.IsFlaming() == false && enemyCrash.IsCrashed(playerCrash))
                        {
                            foreach (DDScene scene in DDSceneUtils.Create(30))                             // プレイヤ死亡効果
                            {
                                this.DrawWall();
                                this.Player.Draw();
                                this.DrawEnemies();

                                DDDraw.SetAlpha(0.3);
                                DDDraw.SetBright(1.0, 0.0, 0.0);
                                DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, 0, 0, DDConsts.Screen_W, DDConsts.Screen_H);
                                DDDraw.Reset();

                                {
                                    int ix = DoubleTools.ToInt(this.Player.X);
                                    int iy = DoubleTools.ToInt(this.Player.Y);

                                    DDDraw.SetBright(1.0, 1.0, 0.0);
                                    DDDraw.SetAlpha(scene.Rate);
                                    DDDraw.DrawRect_LTRB(DDGround.GeneralResource.WhiteBox, ix - 1, 0, ix + 1, DDConsts.Screen_H);
                                    DDDraw.SetAlpha(scene.RemainingRate);
                                    DDDraw.DrawRect_LTRB(DDGround.GeneralResource.WhiteBox, 0, iy - 1, DDConsts.Screen_W, iy + 1);
                                    DDDraw.Reset();
                                }

                                DDEngine.EachFrame();
                            }

                            this.Player.DeadScene.Fire();
                        }
                    }
                    this.Enemies.RemoveAll(enemy => enemy.Dead);
                }

                // ここから描画

                this.DrawWall();
                this.Player.Draw();
                this.DrawEnemies();
                this.DrawWeapons();

                if (cv != null)
                {
                    cv.DrawToScreen(0.8);
                    cv.Dispose();
                    cv = null;
                }

                DDPrint.SetPrint();
                DDPrint.Print(DDEngine.FrameProcessingMillis_Worst + " " + this.Enemies.Count + " SPEED=" + this.Player.SpeedLevel);

                DDEngine.EachFrame();
            }
        }
Example #4
0
        protected override IEnumerable <bool> E_Draw()
        {
            for (; ;)
            {
                double map_w   = Game.I.Map.W * GameConsts.TILE_W;
                double map_h   = Game.I.Map.H * GameConsts.TILE_H;
                double camXMax = map_w - DDConsts.Screen_W;
                double camYMax = map_h - DDConsts.Screen_H;

                // 最背面
                {
                    double xRate = DDGround.Camera.X / camXMax;
                    double yRate = DDGround.Camera.Y / camYMax;

                    DDDraw.DrawSimple(
                        Ground.I.Picture.Stage01_Bg_a01,
                        -(Ground.I.Picture.Stage01_Bg_a01.Get_W() - DDConsts.Screen_W) * xRate,
                        -(Ground.I.Picture.Stage01_Bg_a01.Get_H() - DDConsts.Screen_H) * yRate
                        );
                }

                // 山
                {
                    DDPicture picture    = Ground.I.Picture.Stage01_Bg_a02;
                    double    xSlideRate = 0.2;
                    double    ySlideRate = 0.2;
                    double    x          = -DDGround.Camera.X * xSlideRate;
                    double    y          = (DDConsts.Screen_H - 500.0) + (camYMax - DDGround.Camera.Y) * ySlideRate;
                    int       ix         = (int)x;
                    int       iy         = (int)y;

                    ix %= picture.Get_W();

                    for (int cx = ix; cx < DDConsts.Screen_W; cx += picture.Get_W())
                    {
                        DDDraw.DrawSimple(picture, cx, iy);
                    }
                }

                // 森
                {
                    DDPicture picture    = Ground.I.Picture.Stage01_Bg_a03;
                    double    xSlideRate = 0.3;
                    double    ySlideRate = 0.3;
                    double    x          = -DDGround.Camera.X * xSlideRate;
                    double    y          = (DDConsts.Screen_H - 416.0) + (camYMax - DDGround.Camera.Y) * ySlideRate;
                    int       ix         = (int)x;
                    int       iy         = (int)y;

                    ix %= picture.Get_W();

                    for (int cx = ix; cx < DDConsts.Screen_W; cx += picture.Get_W())
                    {
                        DDDraw.DrawSimple(picture, cx, iy);
                    }
                    iy += picture.Get_H();

                    if (iy < DDConsts.Screen_H)
                    {
                        //DDDraw.SetBright(new I3Color(15, 25, 19));
                        DDDraw.SetBright(new I3Color(16, 48, 16));
                        DDDraw.DrawRect_LTRB(Ground.I.Picture.WhiteBox, 0, iy, DDConsts.Screen_W, DDConsts.Screen_H);
                        DDDraw.Reset();
                    }
                }

                // 木
                {
                    DDPicture picture_01 = Ground.I.Picture.Stage01_Bg_Item01;
                    DDPicture picture_02 = Ground.I.Picture.Stage01_Bg_Item02;

                    const int CYCLE_SPAN = 1000;
                    const int WOOD_01_X  = 200;
                    const int WOOD_02_X  = 700;

                    int x = -DDGround.ICamera.X;
                    int y = (int)(map_h - 96 - DDGround.ICamera.Y);

                    x %= CYCLE_SPAN;
                    x -= CYCLE_SPAN;

                    for (int cx = x; cx < DDConsts.Screen_W; cx += CYCLE_SPAN)
                    {
                        DDDraw.DrawSimple(picture_01, cx + WOOD_01_X, y - picture_01.Get_H());
                        DDDraw.DrawSimple(picture_02, cx + WOOD_02_X, y - picture_02.Get_H());
                    }
                }

                yield return(true);
            }
        }