Ejemplo n.º 1
0
        public static IEnumerable <bool> 行き先案内(int cycle, double rotAdd, int maxDistance, bool 正しいルート)
        {
            double rot = DDUtils.ToAngle(DDEngine.ProcFrame, cycle);

            foreach (DDScene scene in DDSceneUtils.Create(30))
            {
                double centerX = Game.I.Player.X;
                double centerY = Game.I.Player.Y;

                double d = scene.Rate * maxDistance;

                double x = centerX + Math.Cos(rot) * d;
                double y = centerY + Math.Sin(rot) * d;

                I2Point mapPt = GameCommon.ToTablePoint(new D2Point(x, y));
                MapCell cell  = Game.I.Map.GetCell(mapPt);

                if (!cell.IsDefault && cell.IsWall())
                {
                    DDUtils.Approach(ref cell.ColorPhaseShift, 正しいルート ? -1.0 : 1.0, 0.5);
                }

                rot += rotAdd;

                yield return(true);
            }
        }
Ejemplo n.º 2
0
        private static void UpdateActiveScreen()
        {
            I2Point screenCenter;

            {
                DDWin32.POINT p;

                p.X = 0;
                p.Y = 0;

                DDWin32.ClientToScreen(DDWin32.GetMainWindowHandle(), out p);

                int l = p.X;
                int t = p.Y;
                int w = DDGround.RealScreen_W;
                int h = DDGround.RealScreen_H;

                screenCenter = new I2Point(l + w / 2, t + h / 2);
            }

            foreach (I4Rect monitor in DDWin32.GetAllMonitor())
            {
                if (
                    monitor.L <= screenCenter.X && screenCenter.X < monitor.R &&
                    monitor.T <= screenCenter.Y && screenCenter.Y < monitor.B
                    )
                {
                    DDGround.MonitorRect = monitor;
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        private static void DrawMenu()
        {
            DDDraw.SetAlpha(0.5);
            DDDraw.SetBright(0.0, 0.3, 0.6);
            DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, MenuRect.L, MenuRect.T, MenuRect.W, MenuRect.H);
            DDDraw.Reset();

            DDPrint.SetPrint();
            DDPrint.PrintLine("INPUT WALL: " + InputWallFlag);
            DDPrint.PrintLine("INPUT TILE: " + InputTileFlag);
            DDPrint.PrintLine("INPUT ENEMY: " + InputEnemyFlag);

            DDPrint.PrintLine("DISPLAY WALL: " + DisplayWallFlag);
            DDPrint.PrintLine("DISPLAY TILE: " + DisplayTileFlag);
            DDPrint.PrintLine("DISPLAY ENEMY: " + DisplayEnemyFlag);

            DDPrint.PrintLine("WALL: " + Wall);
            DDPrint.PrintLine("TILE: " + TileIndex + " / " + MapTileManager.GetCount());
            DDPrint.PrintLine("TILE=[" + MapTileManager.GetNames()[TileIndex] + "]");
            DDPrint.PrintLine("ENEMY: " + EnemyIndex + " / " + EnemyManager.GetCount());
            DDPrint.PrintLine("ENEMY=[" + EnemyManager.GetNames()[EnemyIndex] + "]");

            I2Point pt   = Map.ToTablePoint(DDMouse.X + DDGround.ICamera.X, DDMouse.Y + DDGround.ICamera.Y);
            MapCell cell = Game.I.Map.GetCell(pt);

            DDPrint.PrintLine("CURSOR: " + pt.X + ", " + pt.Y);
            DDPrint.PrintLine("CURSOR WALL: " + cell.Wall);
            DDPrint.PrintLine("CURSOR TILE=[" + (cell.Tile == null ? "" : cell.Tile.Name) + "]");
            DDPrint.PrintLine("CURSOR ENEMY=[" + (cell.EnemyLoader == null ? "" : cell.EnemyLoader.Name) + "]");

            DDPrint.PrintLine("");
            DDPrint.PrintLine("キー操作");
            DDPrint.PrintLine("C = COPY");
            DDPrint.PrintLine("S = SAVE");
        }
Ejemplo n.º 4
0
        public static void Perform(ref double x, ref double y, Predicate <MapCell> isWall)
        {
            IsWall = isWall;

            // 整数化
            IX = SCommon.ToInt(x);
            IY = SCommon.ToInt(y);

            A2 = new Around(IX, IY, 2);
            A3 = new Around(IX, IY, 3);

            Touch = Touch_e.AIRBORNE;

            I2Point a2RelPtBk = A2.RelativePoint;

            Perform_A(false, false);

            if (
                a2RelPtBk.X != A2.RelativePoint.X ||
                a2RelPtBk.Y != A2.RelativePoint.Y
                )
            {
                x = A2.CenterPoint.X + A2.RelativePoint.X;
                y = A2.CenterPoint.Y + A2.RelativePoint.Y;
            }
        }
Ejemplo n.º 5
0
        private static void DrawToScreen(DDSubScreen screen, Map map, D2Point mapCamera)
        {
            int cam_l = (int)mapCamera.X;
            int cam_t = (int)mapCamera.Y;
            int cam_r = cam_l + DDConsts.Screen_W;
            int cam_b = cam_t + DDConsts.Screen_H;

            int l = cam_l / GameConsts.TILE_W;
            int t = cam_t / GameConsts.TILE_H;
            int r = cam_r / GameConsts.TILE_W;
            int b = cam_b / GameConsts.TILE_H;

            using (screen.Section())
            {
                DX.ClearDrawScreen();

                {
                    Map     bk_map     = Game.I.Map;
                    D2Point bk_camera  = DDGround.Camera;
                    I2Point bk_iCamera = DDGround.ICamera;

                    // Hack
                    {
                        Game.I.Map       = map;
                        DDGround.Camera  = new D2Point(cam_l, cam_t);
                        DDGround.ICamera = new I2Point(cam_l, cam_t);
                    }

                    WallCreator.Create(map.WallName).Draw();

                    // restore
                    {
                        Game.I.Map       = bk_map;
                        DDGround.Camera  = bk_camera;
                        DDGround.ICamera = bk_iCamera;
                    }
                }

                DDGround.EL.Clear();

                for (int x = l; x <= r; x++)
                {
                    for (int y = t; y <= b; y++)
                    {
                        double cell_x = x * GameConsts.TILE_W + GameConsts.TILE_W / 2;
                        double cell_y = y * GameConsts.TILE_H + GameConsts.TILE_H / 2;

                        map.GetCell(x, y).Tile.Draw(cell_x - cam_l, cell_y - cam_t, x, y);
                    }
                }

                DDGround.EL.ExecuteAllTask();                 // 前面に表示するタイルのため
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 周辺テーブルを作成する。
        /// </summary>
        /// <param name="x">指定座標(X-座標_ドット単位)</param>
        /// <param name="y">指定座標(Y-座標_ドット単位)</param>
        /// <param name="size">周辺テーブルの幅・高さ</param>
        public Around(int x, int y, int size)
        {
            I2Point pt = new I2Point(x, y);

            this.Size  = size;
            this.Table = new MapCell[size, size];

            // 周辺テーブルの左上へ移動
            x -= (size - 1) * GameConsts.TILE_W / 2;
            y -= (size - 1) * GameConsts.TILE_H / 2;

            const int TMP_SPAN = 1000;

            // マップ座標(ドット単位) -> マップテーブル座標
            x += GameConsts.TILE_W * TMP_SPAN;
            y += GameConsts.TILE_W * TMP_SPAN;
            x /= GameConsts.TILE_W;
            y /= GameConsts.TILE_H;
            x -= TMP_SPAN;
            y -= TMP_SPAN;

            for (int xc = 0; xc < size; xc++)
            {
                for (int yc = 0; yc < size; yc++)
                {
                    this.Table[xc, yc] = Game.I.Map.GetCell(x + xc, y + yc);
                }
            }

            // マップテーブル座標 -> マップ座標(ドット単位)
            x += TMP_SPAN;
            y += TMP_SPAN;
            x *= GameConsts.TILE_W;
            y *= GameConsts.TILE_H;
            x -= GameConsts.TILE_W * TMP_SPAN;
            y -= GameConsts.TILE_W * TMP_SPAN;

            // 周辺テーブルの中心へ移動
            x += size * GameConsts.TILE_W / 2;
            y += size * GameConsts.TILE_H / 2;

            this.CenterPoint   = new I2Point(x, y);
            this.RelativePoint = new I2Point(pt.X - x, pt.Y - y);

            if (!SCommon.IsRange(this.RelativePoint.X, -16, 15))
            {
                ProcMain.WriteLog("RP_X: " + this.RelativePoint.X);                                                              // test
            }
            if (!SCommon.IsRange(this.RelativePoint.Y, -16, 15))
            {
                ProcMain.WriteLog("RP_Y: " + this.RelativePoint.Y);                                                              // test
            }
        }
Ejemplo n.º 7
0
        public World(string startMapName)
        {
            using (WorkingDir wd = new WorkingDir())
            {
                string file = wd.MakePath();

                File.WriteAllBytes(file, DDResource.Load(@"res\World\World.csv"));

                using (CsvFileReader reader = new CsvFileReader(file))
                {
                    this.MapNameTableRows = reader.ReadToEnd();
                }
            }
            this.CurrPoint = this.GetPoint(startMapName);
        }
Ejemplo n.º 8
0
        public static I2Point GetPoint(string file, I2Point defval)
        {
            for (int y = 0; y < Rows.Length; y++)
            {
                string[] row = Rows[y];

                for (int x = 0; x < row.Length; x++)
                {
                    if (StringTools.EqualsIgnoreCase(row[x], file))
                    {
                        return(new I2Point(x, y));
                    }
                }
            }
            return(defval);
        }
Ejemplo n.º 9
0
        protected override IEnumerable <bool> E_Draw()
        {
            bool   falling = false;
            double ySpeed  = 0.0;

            const double GRAVITY     = 0.5;
            const double SPEED_Y_MAX = 8.0;

            for (; ;)
            {
                if (
                    this.Y < Game.I.Player.Y &&
                    Math.Abs(Game.I.Player.X - this.X) < 50.0
                    )
                {
                    falling = true;
                }

                if (falling)
                {
                    this.Y += ySpeed;

                    ySpeed += GRAVITY;
                    ySpeed  = Math.Min(ySpeed, SPEED_Y_MAX);

                    I2Point pt = GameCommon.ToTablePoint(new D2Point(this.X, this.Y));

                    if (Game.I.Map.GetCell(pt).Tile.IsGround())                     // ? 地面に落ちた。
                    {
                        this.DeadFlag = true;

                        DDGround.EL.Add(SCommon.Supplier(this.E_地面に落ちた(
                                                             pt.X * GameConsts.TILE_W + GameConsts.TILE_W / 2,
                                                             pt.Y * GameConsts.TILE_H - GameConsts.TILE_H / 2
                                                             )));

                        break;
                    }
                }

                DDDraw.DrawCenter(Ground.I.Picture.Stage02_Chip_g04_01, this.X - DDGround.ICamera.X, this.Y - DDGround.ICamera.Y);

                this.Crash = DDCrashUtils.Rect_CenterSize(new D2Point(this.X, this.Y), new D2Size(16, 32));

                yield return(true);
            }
        }
Ejemplo n.º 10
0
        private void DrawMap()
        {
            int w = this.Map.W;
            int h = this.Map.H;

            int camL = DDGround.ICamera.X;
            int camT = DDGround.ICamera.Y;
            int camR = camL + DDConsts.Screen_W;
            int camB = camT + DDConsts.Screen_H;

            I2Point lt = Map.ToTablePoint(camL, camT);
            I2Point rb = Map.ToTablePoint(camR, camB);

            lt.X -= 2;             // margin
            lt.Y -= 2;             // margin
            rb.X += 2;             // margin
            rb.Y += 2;             // margin

            lt.X = IntTools.ToRange(lt.X, 0, w - 1);
            lt.Y = IntTools.ToRange(lt.Y, 0, h - 1);
            rb.X = IntTools.ToRange(rb.X, 0, w - 1);
            rb.Y = IntTools.ToRange(rb.Y, 0, h - 1);

            for (int x = lt.X; x <= rb.X; x++)
            {
                for (int y = lt.Y; y <= rb.Y; y++)
                {
                    int mapTileX = x * MapTile.WH + MapTile.WH / 2;
                    int mapTileY = y * MapTile.WH + MapTile.WH / 2;

                    //if (DDUtils.IsOut(new D2Point(mapTileX, mapTileY), new D4Rect(camL, camT, camR, camB), MapTile.WH * 2) == false) // old
                    {
                        MapCell cell = this.Map.GetCell(x, y);

                        if (cell.Tile != null)                         // ? ! 描画無し
                        {
                            DDDraw.DrawCenter(
                                cell.Tile.Picture,
                                mapTileX - camL + this.DrawMap_SlideX,
                                mapTileY - camT + this.DrawMap_SlideY
                                );
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public World(string worldName, string startMapName)
        {
            string worldFile = GameCommon.GetWorldFile(worldName);

            using (WorkingDir wd = new WorkingDir())
            {
                string file = wd.MakePath();

                File.WriteAllBytes(file, DDResource.Load(worldFile));

                using (CsvFileReader reader = new CsvFileReader(file))
                {
                    this.MapNameTableRows = reader.ReadToEnd();
                }
            }
            this.CurrPoint = this.GetPoint(startMapName);
            this.WorldName = worldName;
        }
Ejemplo n.º 12
0
        private void Move(int xa, int ya)
        {
            I2Point pt = WorldMap.GetPoint(this.MapFile, new I2Point());

            if (pt.X == -1)
            {
                throw new DDError("そんなマップありません。" + this.MapFile);
            }

            pt.X += xa;
            pt.Y += ya;

            string file = WorldMap.GetFile(pt.X, pt.Y);

            if (file == null)
            {
                throw new DDError("その方向にマップはありません。");
            }

            this.MapFile = file;
        }
Ejemplo n.º 13
0
        public static void DrawEnemy()
        {
            int cam_l = DDGround.ICamera.X;
            int cam_t = DDGround.ICamera.Y;
            int cam_r = cam_l + DDConsts.Screen_W;
            int cam_b = cam_t + DDConsts.Screen_H;

            I2Point lt = GameCommon.ToTablePoint(cam_l, cam_t);
            I2Point rb = GameCommon.ToTablePoint(cam_r, cam_b);

            for (int x = lt.X; x <= rb.X; x++)
            {
                for (int y = lt.Y; y <= rb.Y; y++)
                {
                    MapCell cell = Game.I.Map.GetCell(x, y);

                    if (cell.EnemyName != GameConsts.ENEMY_NONE)
                    {
                        int tileL = x * GameConsts.TILE_W;
                        int tileT = y * GameConsts.TILE_H;

                        DDDraw.SetAlpha(0.3);
                        DDDraw.SetBright(new I3Color(0, 128, 255));
                        DDDraw.DrawRect(
                            Ground.I.Picture.WhiteBox,
                            tileL - cam_l,
                            tileT - cam_t,
                            GameConsts.TILE_W,
                            GameConsts.TILE_H
                            );
                        DDDraw.Reset();

                        DDPrint.SetBorder(new I3Color(0, 128, 255));
                        DDPrint.SetDebug(tileL - cam_l, tileT - cam_t);
                        DDPrint.Print(cell.EnemyName);
                        DDPrint.Reset();
                    }
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 物体の壁へのめり込みを解消する。
        /// </summary>
        /// <param name="pt">物体の位置</param>
        /// <param name="crashPts">当たり判定(キャラクタ位置からの相対座標)</param>
        /// <returns>めり込んでいたか</returns>
        public static bool 壁処理(ref D2Point pt, D2Point[] crashPts)
        {
            bool ret = false;

            foreach (D2Point crashPt in crashPts)
            {
                I2Point cellPos = GameCommon.ToTablePoint(pt + crashPt);

                if (Game.I.Map.GetCell(cellPos).Tile.IsWall())
                {
                    if (Math.Abs(crashPt.X) < Math.Abs(crashPt.Y))   // ? Y方向に遠い -> Y位置を調整
                    {
                        if (crashPt.Y < 0.0)                         // ? 中心より上 -> 下へ動かす。
                        {
                            pt.Y = (cellPos.Y + 1) * GameConsts.TILE_H - crashPt.Y;
                        }
                        else                         // ? 中心より下 -> 上へ動かす。
                        {
                            pt.Y = cellPos.Y * GameConsts.TILE_H - crashPt.Y;
                        }
                    }
                    else                     // ? X方向に遠い -> X位置を調整
                    {
                        if (crashPt.X < 0.0) // ? 中心より左 -> 右へ動かす。
                        {
                            pt.X = (cellPos.X + 1) * GameConsts.TILE_W - crashPt.X;
                        }
                        else                         // ? 中心より右 -> 左へ動かす。
                        {
                            pt.X = cellPos.X * GameConsts.TILE_W - crashPt.X;
                        }
                    }
                    ret = true;
                }
            }
            return(ret);
        }
Ejemplo n.º 15
0
        public static void GameStart()
        {
            foreach (string dllFile in "DxLib.dll:DxLib_x64.dll:DxLibDotNet.dll".Split(':'))             // DxLibDotNet.dll 等の存在確認 (1)
            {
                if (!File.Exists(dllFile))
                {
                    throw new DDError();
                }
            }

            DX.GetColor(0, 0, 0);        // DxLibDotNet.dll 等の存在確認 (2)

            DDConfig.Load();             // LogFile, LOG_ENABLED 等を含むので真っ先に

            // Log >

            File.WriteAllBytes(DDConfig.LogFile, SCommon.EMPTY_BYTES);

            ProcMain.WriteLog = message =>
            {
                if (LogCount < DDConfig.LogCountMax)
                {
                    using (StreamWriter writer = new StreamWriter(DDConfig.LogFile, true, Encoding.UTF8))
                    {
                        writer.WriteLine("[" + DateTime.Now + "] " + message);
                    }
                    LogCount++;
                }
            };

            // < Log

            // *.INIT
            {
                DDGround.INIT();
                DDResource.INIT();
                DDDatStrings.INIT();
                DDUserDatStrings.INIT();
                DDFontRegister.INIT();
                DDKey.INIT();
            }

            DDSaveData.Load();

            // DxLib >

            if (DDConfig.LOG_ENABLED)
            {
                DX.SetApplicationLogSaveDirectory(SCommon.MakeFullPath(DDConfig.ApplicationLogSaveDirectory));
            }

            DX.SetOutApplicationLogValidFlag(DDConfig.LOG_ENABLED ? 1 : 0); // DxLib のログを出力 1: する 0: しない

            DX.SetAlwaysRunFlag(1);                                         // ? 非アクティブ時に 1: 動く 0: 止まる

            SetMainWindowTitle();

            //DX.SetGraphMode(DDConsts.Screen_W, DDConsts.Screen_H, 32);
            DX.SetGraphMode(DDGround.RealScreen_W, DDGround.RealScreen_H, 32);
            DX.ChangeWindowMode(1);             // 1: ウィンドウ 0: フルスクリーン

            //DX.SetFullSceneAntiAliasingMode(4, 2); // フルスクリーンを廃止したので不要

            DX.SetWindowIconHandle(GetAppIcon());             // ウィンドウ左上のアイコン

            if (0 <= DDConfig.DisplayIndex)
            {
                DX.SetUseDirectDrawDeviceIndex(DDConfig.DisplayIndex);
            }

            if (DX.DxLib_Init() != 0)             // ? 失敗
            {
                throw new DDError();
            }

            Finalizers.Add(() =>
            {
                if (DX.DxLib_End() != 0)                 // ? 失敗
                {
                    throw new DDError();
                }
            });

            DDUtils.SetMouseDispMode(DDGround.RO_MouseDispMode); // ? マウスを表示する。
            DX.SetWindowSizeChangeEnableFlag(0);                 // ウィンドウの右下をドラッグで伸縮 1: する 0: しない

            //DX.SetDrawScreen(DX.DX_SCREEN_BACK);
            DX.SetDrawMode(DDConsts.DEFAULT_DX_DRAWMODE);             // これをデフォルトとする。

            // < DxLib

            DDGround.MainScreen = new DDSubScreen(DDConsts.Screen_W, DDConsts.Screen_H);
            DDGround.MainScreen.ChangeDrawScreen();
            DDGround.LastMainScreen = new DDSubScreen(DDConsts.Screen_W, DDConsts.Screen_H);
            DDGround.KeptMainScreen = new DDSubScreen(DDConsts.Screen_W, DDConsts.Screen_H);

            if (DDConfig.DisplayIndex == -2)
            {
                I2Point  mousePt       = DDWin32.GetMousePosition();
                I4Rect[] monitors      = DDWin32.GetAllMonitor();
                I4Rect   activeMonitor = monitors[0];               // マウス位置のモニタを特定出来ない場合のモニタ

                foreach (I4Rect monitor in monitors)
                {
                    if (
                        monitor.L <= mousePt.X && mousePt.X < monitor.R &&
                        monitor.T <= mousePt.Y && mousePt.Y < monitor.B
                        )
                    {
                        activeMonitor = monitor;
                        break;
                    }
                }
                DDGround.MonitorRect = activeMonitor;
            }
            else
            {
                int l;
                int t;
                int w;
                int h;
                int p1;
                int p2;
                int p3;
                int p4;

                DX.GetDefaultState(out w, out h, out p1, out p2, out l, out t, out p3, out p4);

                if (
                    w < 1 || SCommon.IMAX < w ||
                    h < 1 || SCommon.IMAX < h ||
                    l < -SCommon.IMAX || SCommon.IMAX < l ||
                    t < -SCommon.IMAX || SCommon.IMAX < t
                    )
                {
                    throw new DDError();
                }

                DDGround.MonitorRect = new I4Rect(l, t, w, h);
            }

            PostSetScreenSize(DDGround.RealScreen_W, DDGround.RealScreen_H);

            // Font
            {
                //DDFontRegister.Add(@"e20200928_NovelAdv\Font\Genkai-Mincho-font\genkai-mincho.ttf");
                //DDFontRegister.Add(@"e20200928_NovelAdv\Font\riitf\RiiT_F.otf");
                DDFontRegister.Add(@"dat\Font\K Gothic\K Gothic.ttf");
                DDFontRegister.Add(@"dat\Font\焚火フォント\03Takibi-Regular.otf");
                //DDFontRegister.Add(@"dat\Font\廻想体\Kaiso-Next-B.otf");
                DDFontRegister.Add(@"dat\Font\木漏れ日ゴシック\komorebi-gothic.ttf");
            }

            Ground.I          = new Ground();
            Ground.I.Picture2 = new ResourcePicture2();             // Ground.I を参照しているので Ground のコンストラクタには書けない。

            MainWin.I.PostGameStart_G3();

            DDSaveData.Load_Delay();

            Finalizers.Add(() =>
            {
                DDSaveData.Save();
            });
        }
Ejemplo n.º 16
0
        private IEnumerable <bool> E_Jump(double jumpSpeed)
        {
            double ySpeed = -jumpSpeed;

            const double SPEED_X = 3.0;
            const double GRAVITY = 0.5;

            for (int frame = 0; frame < 5; frame++)
            {
                DDDraw.DrawBegin(Ground.I.Picture.Teki_a03_Jump02, this.X - DDGround.ICamera.X, this.Y - 16 - DDGround.ICamera.Y);
                DDDraw.DrawZoom_X(this.FacingLeft ? 1.0 : -1.0);
                DDDraw.DrawEnd();

                yield return(true);
            }
            for (int frame = 0; ; frame++)
            {
                if (this.FacingLeft)
                {
                    if (Game.I.Map.GetCell(GameCommon.ToTablePoint(this.X - 20.0, this.Y)).Tile.IsWall())
                    {
                        this.FacingLeft = false;
                    }
                }
                else
                {
                    if (Game.I.Map.GetCell(GameCommon.ToTablePoint(this.X + 20.0, this.Y)).Tile.IsWall())
                    {
                        this.FacingLeft = true;
                    }
                }
                if (
                    ySpeed < 0.0 &&                     // ? 上昇中
                    Game.I.Map.GetCell(GameCommon.ToTablePoint(this.X, this.Y - 20.0)).Tile.IsWall()
                    )
                {
                    ySpeed = 0.0;
                }

                if (0.0 < ySpeed)                 // ? 降下中
                {
                    I2Point pt = GameCommon.ToTablePoint(this.X, this.Y + 30.0);

                    if (Game.I.Map.GetCell(pt).Tile.IsGround())
                    {
                        this.Y = pt.Y * GameConsts.TILE_H - GameConsts.TILE_H / 2;
                        break;
                    }
                }
                if (Game.I.Map.H * GameConsts.TILE_H + 50.0 < this.Y) // ? 画面下に十分出た。
                {
                    this.DeadFlag = true;                             // 消滅
                }

                this.X += this.FacingLeft ? -SPEED_X : SPEED_X;
                this.Y += ySpeed;

                ySpeed += GRAVITY;

                DDDraw.DrawBegin(Ground.I.Picture.Teki_a03_Jump03, this.X - DDGround.ICamera.X, this.Y - DDGround.ICamera.Y);
                DDDraw.DrawZoom_X(this.FacingLeft ? 1.0 : -1.0);
                DDDraw.DrawEnd();

                yield return(true);
            }
            this.WaitFrame = 0;
        }
Ejemplo n.º 17
0
 public MapCell GetCell(I2Point pt)
 {
     return(this.GetCell(pt.X, pt.Y));
 }
Ejemplo n.º 18
0
        public override void Draw()
        {
            if (Game.I.Player.DeadFrame != 0)             // ? プレイヤー死亡
            {
                int addcntmax = 1 + (Game.I.Player.DeadFrame * 5) / GameConsts.PLAYER_DEAD_FRAME_MAX;

                for (int addcnt = 0; addcnt < addcntmax; addcnt++)
                {
                    D2Point enemyPos = new D2Point(
                        DDGround.Camera.X - DDConsts.Screen_W / 2 + DDConsts.Screen_W * DDUtils.Random.Real() * 2,
                        DDGround.Camera.Y - DDConsts.Screen_H / 2 + DDConsts.Screen_H * DDUtils.Random.Real() * 2
                        );

                    //Game.I.Enemies.Add(new Enemy_Death(enemyPos));
                    Game.I.Enemies.Add(new Enemy_Meteor(enemyPos));
                }
            }
            //else if (20 < this.Frame && this.Random.Real() < Math.Min(0.2, this.Frame / 500.0))
            else if (
                20 < this.Frame &&
                this.Random.GetInt(Math.Max(5, 100 - this.Frame)) == 0                 // Frame == 0.0 -> NaN 注意
                )
            {
                for (int retry = 0; retry < 10; retry++)
                {
                    D2Point dotPos;

                    switch (this.発生領域)
                    {
                    case 2:
                        dotPos = new D2Point(
                            DDGround.ICamera.X + this.Random.GetInt(DDConsts.Screen_W),
                            DDGround.ICamera.Y + this.Random.GetInt(DDConsts.Screen_H / 2) + DDConsts.Screen_H / 2
                            );
                        break;

                    case 4:
                        dotPos = new D2Point(
                            DDGround.ICamera.X + this.Random.GetInt(DDConsts.Screen_W / 2),
                            DDGround.ICamera.Y + this.Random.GetInt(DDConsts.Screen_H)
                            );
                        break;

                    case 5:
                        dotPos = new D2Point(
                            DDGround.ICamera.X + this.Random.GetInt(DDConsts.Screen_W),
                            DDGround.ICamera.Y + this.Random.GetInt(DDConsts.Screen_H)
                            );
                        break;

                    case 6:
                        dotPos = new D2Point(
                            DDGround.ICamera.X + this.Random.GetInt(DDConsts.Screen_W / 2) + DDConsts.Screen_W / 2,
                            DDGround.ICamera.Y + this.Random.GetInt(DDConsts.Screen_H)
                            );
                        break;

                    case 8:
                        dotPos = new D2Point(
                            DDGround.ICamera.X + this.Random.GetInt(DDConsts.Screen_W),
                            DDGround.ICamera.Y + this.Random.GetInt(DDConsts.Screen_H / 2)
                            );
                        break;

                    default:
                        throw null;                                 // never
                    }

                    I2Point cellPos = GameCommon.ToTablePoint(dotPos);
                    MapCell cell    = Game.I.Map.GetCell(cellPos);

                    if (
                        !cell.IsDefault &&                                                                                             // ? 画面外ではない。
                        300.0 < DDUtils.GetDistance(new D2Point(dotPos.X, dotPos.Y), new D2Point(Game.I.Player.X, Game.I.Player.Y)) && // ? 近すぎない。
                        (cell.Kind == MapCell.Kind_e.WALL || cell.Kind == MapCell.Kind_e.DEATH)
                        )
                    {
                        if (cell.Kind == MapCell.Kind_e.WALL)
                        {
                            cell.Kind     = MapCell.Kind_e.DEATH;
                            cell.KindOrig = MapCell.Kind_e.WALL;
                        }

                        D2Point enemyPos = new D2Point(
                            cellPos.X * GameConsts.TILE_W + GameConsts.TILE_W / 2,
                            cellPos.Y * GameConsts.TILE_H + GameConsts.TILE_H / 2
                            );

                        Game.I.Enemies.Add(new Enemy_Death(enemyPos));
                        Game.I.Enemies.Add(new Enemy_Meteor(enemyPos));

                        break;
                    }
                }
            }
            this.Frame++;
        }
Ejemplo n.º 19
0
 public MapCell GetCell(I2Point pt, MapCell defCell)
 {
     return(this.GetCell(pt.X, pt.Y, defCell));
 }
Ejemplo n.º 20
0
        public static void EachFrame()
        {
            I2Point pt   = Map.ToTablePoint(DDMouse.X + DDGround.ICamera.X, DDMouse.Y + DDGround.ICamera.Y);
            MapCell cell = Game.I.Map.GetCell(pt, null);

            if (cell == null)
            {
                return;
            }

            if (DDUtils.IsOutOfScreen(new D2Point(DDMouse.X, DDMouse.Y)))
            {
                return;
            }

            HideMenu = 1 <= DDKey.GetInput(DX.KEY_INPUT_LCONTROL) || 1 <= DDKey.GetInput(DX.KEY_INPUT_RCONTROL);

            if (HideMenu || DDUtils.IsOut(new D2Point(DDMouse.X, DDMouse.Y), MenuRect))
            {
                if (1 <= DDMouse.L.GetInput())
                {
                    if (InputWallFlag)
                    {
                        cell.Wall = Wall;
                    }
                    if (InputTileFlag)
                    {
                        cell.Tile = MapTileManager.GetTile(MapTileManager.GetNames()[TileIndex]);
                    }
                    if (InputEnemyFlag)
                    {
                        cell.EnemyLoader = EnemyManager.GetEnemyLoader(EnemyManager.GetNames()[EnemyIndex]);
                    }
                }
                if (1 <= DDMouse.R.GetInput())
                {
                    cell.Wall        = false;
                    cell.Tile        = null;
                    cell.EnemyLoader = null;
                }
            }
            else
            {
                int cursorMenuItemIndex = DDMouse.Y / 16;

                bool l = 1 <= DDMouse.L.GetInput();
                bool r = 1 <= DDMouse.R.GetInput();

                if (l || r)
                {
                    bool flag = l;

                    switch (cursorMenuItemIndex)
                    {
                    case 0: InputWallFlag = flag; break;

                    case 1: InputTileFlag = flag; break;

                    case 2: InputEnemyFlag = flag; break;

                    case 3: DisplayWallFlag = flag; break;

                    case 4: DisplayTileFlag = flag; break;

                    case 5: DisplayEnemyFlag = flag; break;

                    case 6: Wall = flag; break;

                    case 7:
                    case 8:
                        IntoInputTileMode();
                        break;

                    case 9:
                    case 10:
                        IntoInputEnemyMode();
                        break;
                    }
                }

                Rot += DDMouse.Rot;

                if (DDMouse.Rot == 0)
                {
                    NoRotFrame++;
                }
                else
                {
                    NoRotFrame = 0;
                }

                if (90 < NoRotFrame)
                {
                    Rot = 0;
                }

                switch (cursorMenuItemIndex)
                {
                case 7:
                case 8:
                    if (MenuItemRot(ref TileIndex, MapTileManager.GetCount()))
                    {
                        IntoInputTileMode();
                    }
                    break;

                case 9:
                case 10:
                    if (MenuItemRot(ref EnemyIndex, EnemyManager.GetCount()))
                    {
                        IntoInputEnemyMode();
                    }
                    break;
                }
            }

            if (DDKey.GetInput(DX.KEY_INPUT_C) == 1)
            {
                if (InputWallFlag)
                {
                    Wall = cell.Wall;
                }
                if (InputTileFlag)
                {
                    TileIndex = cell.Tile == null ? 0 : MapTileManager.GetNames().IndexOf(cell.Tile.Name);
                }
                if (InputEnemyFlag)
                {
                    EnemyIndex = cell.EnemyLoader == null ? 0 : EnemyManager.GetNames().IndexOf(cell.EnemyLoader.Name);
                }

                if (TileIndex == -1)                 // 2bs
                {
                    TileIndex = 0;
                }

                if (EnemyIndex == -1)                 // 2bs
                {
                    EnemyIndex = 0;
                }
            }
            if (DDKey.GetInput(DX.KEY_INPUT_S) == 1)
            {
                MapLoader.SaveToLastLoadedFile(Game.I.Map);
            }
        }
Ejemplo n.º 21
0
 public void SetCurrMapName(string mapName)
 {
     this.CurrPoint = this.GetPoint(mapName);
 }
Ejemplo n.º 22
0
 public MapCell GetCell(I2Point pt)
 {
     return(this.GetCell(pt, this.DefaultCell));
 }
Ejemplo n.º 23
0
            private bool Draw_KBKFA(int komaBack, int komaFront, double komaFrontAlpha)
            {
                bool friend_4 = this.F_IsFriend(Game.I.Map.GetCell(this.MapTablePoint.X - 1, this.MapTablePoint.Y));
                bool friend_6 = this.F_IsFriend(Game.I.Map.GetCell(this.MapTablePoint.X + 1, this.MapTablePoint.Y));
                bool friend_8 = this.F_IsFriend(Game.I.Map.GetCell(this.MapTablePoint.X, this.MapTablePoint.Y - 1));
                bool friend_2 = this.F_IsFriend(Game.I.Map.GetCell(this.MapTablePoint.X, this.MapTablePoint.Y + 1));

                bool friend_1 = this.F_IsFriend(Game.I.Map.GetCell(this.MapTablePoint.X - 1, this.MapTablePoint.Y + 1));
                bool friend_3 = this.F_IsFriend(Game.I.Map.GetCell(this.MapTablePoint.X + 1, this.MapTablePoint.Y + 1));
                bool friend_7 = this.F_IsFriend(Game.I.Map.GetCell(this.MapTablePoint.X - 1, this.MapTablePoint.Y - 1));
                bool friend_9 = this.F_IsFriend(Game.I.Map.GetCell(this.MapTablePoint.X + 1, this.MapTablePoint.Y - 1));

                I2Point lt;
                I2Point rt;
                I2Point lb;
                I2Point rb;

                if (friend_4 && friend_8)
                {
                    lt = friend_7 ? new I2Point(2, 4) : new I2Point(2, 0);
                }
                else if (friend_4)
                {
                    lt = new I2Point(2, 2);
                }
                else if (friend_8)
                {
                    lt = new I2Point(0, 4);
                }
                else
                {
                    lt = new I2Point(0, 2);
                }

                if (friend_6 && friend_8)
                {
                    rt = friend_9 ? new I2Point(1, 4) : new I2Point(3, 0);
                }
                else if (friend_6)
                {
                    rt = new I2Point(1, 2);
                }
                else if (friend_8)
                {
                    rt = new I2Point(3, 4);
                }
                else
                {
                    rt = new I2Point(3, 2);
                }

                if (friend_4 && friend_2)
                {
                    lb = friend_1 ? new I2Point(2, 3) : new I2Point(2, 1);
                }
                else if (friend_4)
                {
                    lb = new I2Point(2, 5);
                }
                else if (friend_2)
                {
                    lb = new I2Point(0, 3);
                }
                else
                {
                    lb = new I2Point(0, 5);
                }

                if (friend_6 && friend_2)
                {
                    rb = friend_3 ? new I2Point(1, 3) : new I2Point(3, 1);
                }
                else if (friend_6)
                {
                    rb = new I2Point(1, 5);
                }
                else if (friend_2)
                {
                    rb = new I2Point(3, 3);
                }
                else
                {
                    rb = new I2Point(3, 5);
                }

                foreach (var info in new[]
                {
                    new { Pt = lt, Dir = new { X = -1, Y = -1 } },
                    new { Pt = rt, Dir = new { X = 1, Y = -1 } },
                    new { Pt = lb, Dir = new { X = -1, Y = 1 } },
                    new { Pt = rb, Dir = new { X = 1, Y = 1 } },
                })
                {
                    DDDraw.DrawCenter(
                        this.PictureTable[this.PictureTable_L + info.Pt.X + komaBack * 4, this.PictureTable_T + info.Pt.Y],
                        this.DrawPoint.X + info.Dir.X * GameConsts.MINI_TILE_W / 2,
                        this.DrawPoint.Y + info.Dir.Y * GameConsts.MINI_TILE_H / 2
                        );
                    DDDraw.SetAlpha(komaFrontAlpha);
                    DDDraw.DrawCenter(
                        this.PictureTable[this.PictureTable_L + info.Pt.X + komaFront * 4, this.PictureTable_T + info.Pt.Y],
                        this.DrawPoint.X + info.Dir.X * GameConsts.MINI_TILE_W / 2,
                        this.DrawPoint.Y + info.Dir.Y * GameConsts.MINI_TILE_H / 2
                        );
                    DDDraw.Reset();
                }
                return(true);
            }
Ejemplo n.º 24
0
        public static void DrawTiles()
        {
            int cam_l = DDGround.ICamera.X;
            int cam_t = DDGround.ICamera.Y;
            int cam_r = cam_l + DDConsts.Screen_W;
            int cam_b = cam_t + DDConsts.Screen_H;

            I2Point lt = GameCommon.ToTablePoint(cam_l, cam_t);
            I2Point rb = GameCommon.ToTablePoint(cam_r, cam_b);

            for (int x = lt.X; x <= rb.X; x++)
            {
                for (int y = lt.Y; y <= rb.Y; y++)
                {
                    MapCell cell  = Game.I.Map.GetCell(x, y);
                    I3Color color = new I3Color(0, 0, 0);
                    string  name  = "";

                    switch (cell.Kind)
                    {
                    case MapCell.Kind_e.EMPTY:
                        goto endDraw;

                    case MapCell.Kind_e.START:
                        color = new I3Color(0, 255, 0);
                        break;

                    case MapCell.Kind_e.GOAL:
                        color = new I3Color(0, 255, 255);
                        break;

                    case MapCell.Kind_e.WALL:
                        color = new I3Color(255, 255, 0);
                        break;

                    case MapCell.Kind_e.WALL_ENEMY_THROUGH:
                        color = new I3Color(255, 255, 0);
                        name  = "E通";
                        break;

                    case MapCell.Kind_e.DEATH:
                        color = new I3Color(255, 0, 0);
                        break;

                    default:
                        color = new I3Color(128, 128, 255);
                        name  = MapCell.Kine_e_Names[(int)cell.Kind];

                        if (name.Contains(':'))
                        {
                            name = name.Substring(0, name.IndexOf(':'));
                        }

                        if (name.Contains('/'))
                        {
                            name = name.Substring(name.IndexOf('/') + 1);
                        }

                        break;
                    }

                    {
                        int tileL = x * GameConsts.TILE_W;
                        int tileT = y * GameConsts.TILE_H;

                        DDDraw.SetBright(color);
                        DDDraw.DrawRect(
                            Ground.I.Picture.WhiteBox,
                            tileL - cam_l,
                            tileT - cam_t,
                            GameConsts.TILE_W,
                            GameConsts.TILE_H
                            );
                        DDDraw.Reset();

                        DDDraw.SetAlpha(0.1);
                        DDDraw.SetBright(new I3Color(0, 0, 0));
                        DDDraw.DrawRect(
                            Ground.I.Picture.WhiteBox,
                            tileL - cam_l,
                            tileT - cam_t,
                            GameConsts.TILE_W,
                            GameConsts.TILE_H / 2
                            );
                        DDDraw.Reset();

                        DDDraw.SetAlpha(0.2);
                        DDDraw.SetBright(new I3Color(0, 0, 0));
                        DDDraw.DrawRect(
                            Ground.I.Picture.WhiteBox,
                            tileL - cam_l,
                            tileT - cam_t,
                            GameConsts.TILE_W / 2,
                            GameConsts.TILE_H
                            );
                        DDDraw.Reset();

                        DDGround.EL.Add(() =>
                        {
                            DDPrint.SetBorder(new I3Color(0, 64, 64));
                            DDPrint.SetPrint(tileL - cam_l, tileT - cam_t);
                            DDPrint.DebugPrint(name);
                            DDPrint.Reset();

                            return(false);
                        });
                    }

endDraw:
                    ;
                }
            }
        }