Example #1
0
        public void SetEnemy(string enemyName)
        {
            int index = SCommon.IndexOf(EnemyCatalog.GetNames(), enemyName);

            if (index == -1)
            {
                index = 0;                 // 2bs
            }
            this.Enemy.SelectedIndex = index;
        }
Example #2
0
        public void SetTile_R(string tileName)
        {
            int index = SCommon.IndexOf(TileCatalog.GetNames(), tileName);

            if (index == -1)
            {
                index = 0;                 // 2bs
            }
            this.Tile_R.SelectedIndex = index;
        }
Example #3
0
        public static Surface Create(string typeName, string instanceName)
        {
            int index = SCommon.IndexOf(Infos, v => v.TypeName == typeName);

            if (index == -1)
            {
                throw new DDError("不明なタイプ名:" + typeName);
            }

            _tn = typeName;
            _in = instanceName;

            Surface surface = Infos[index].CreateSurface();

            _tn = null;
            _in = null;

            return(surface);
        }
Example #4
0
        private static List <GroupInfo> CreateTileGroups()
        {
            List <GroupInfo> groups = new List <GroupInfo>();

            string[] groupNames  = TileCatalog.GetGroupNames();
            string[] memberNames = TileCatalog.GetMemberNames();
            int      count       = groupNames.Length;

            for (int index = 0; index < count; index++)
            {
                string groupName  = groupNames[index];
                string memberName = memberNames[index];

                GroupInfo group;

                {
                    int p = SCommon.IndexOf(groups, v => v.Name == groupName);

                    if (p != -1)
                    {
                        group = groups[p];
                    }
                    else
                    {
                        group = new GroupInfo()
                        {
                            Name = groupName,
                        };

                        groups.Add(group);
                    }
                }

                group.Members.Add(new GroupInfo.MemberInfo()
                {
                    Name  = memberName,
                    Index = index,
                });
            }
            return(groups);
        }
Example #5
0
        public void Load()
        {
            I3Color[,] bmp = Common.ReadBmpFile(DDResource.Load(this.MapFile), out this.W, out this.H);

            this.Table = new MapCell[this.W, this.H];

            for (int x = 0; x < this.W; x++)
            {
                for (int y = 0; y < this.H; y++)
                {
                    int index = SCommon.IndexOf(MapCell.Kind_e_Colors, v => v == bmp[x, y]);

#if true
                    if (index == -1)                     // ? 未知の色
                    {
                        index = (int)MapCell.Kind_e.EMPTY;
                    }
#else
                    // @ 2020.12.x
                    // ペイントなどで編集して不明な色が混入してしまうことを考慮して、EMPTY に矯正するようにしたいが、
                    // 移植によるバグ混入検出のため、当面はエラーで落とす。
                    // -- 止め @ 2021.1.x
                    //
                    if (index == -1)                     // ? 未知の色
                    {
                        throw null;
                    }
#endif

                    this.Table[x, y] = new MapCell()
                    {
                        Parent     = this,
                        Self_X     = x,
                        Self_Y     = y,
                        Kind       = (MapCell.Kind_e)index,
                        ColorPhase = DDUtils.Random.Real(),
                    };
                }
            }
        }
Example #6
0
        public void SetTile(string tileName)
        {
            int index = SCommon.IndexOf(TileCatalog.GetNames(), name => name == tileName);

            if (index == -1)
            {
                throw new DDError();
            }

            for (int groupIndex = 0; groupIndex < LevelEditor.TileGroups.Count; groupIndex++)
            {
                for (int memberIndex = 0; memberIndex < LevelEditor.TileGroups[groupIndex].Members.Count; memberIndex++)
                {
                    if (LevelEditor.TileGroups[groupIndex].Members[memberIndex].Index == index)
                    {
                        this.TileGroup.SelectedIndex  = groupIndex;
                        this.TileMember.SelectedIndex = memberIndex;
                        return;
                    }
                }
            }
            throw new DDError();
        }
Example #7
0
        private IEnumerable <bool> モード変更(string modeName, bool?mirrored)
        {
            int mode = SCommon.IndexOf(this.ImageTable[this.Chara], v => v.Name == modeName);

            if (mode == -1)
            {
                throw new DDError("Bad mode: " + mode);
            }

            int  currMode     = this.Mode;
            int  destMode     = mode;
            bool currMirrored = this.Mirrored;
            bool destMirrored = mirrored == null ? this.Mirrored : mirrored.Value;

            foreach (DDScene scene in DDSceneUtils.Create(30))
            {
                if (NovelAct.IsFlush)
                {
                    this.A        = 1.0;
                    this.Mode     = destMode;
                    this.Mirrored = destMirrored;
                    break;
                }
                this.A        = DDUtils.Parabola(scene.Rate * 0.5 + 0.5);
                this.Mode     = currMode;
                this.Mirrored = currMirrored;
                this.P_Draw();

                this.A        = DDUtils.Parabola(scene.Rate * 0.5 + 0.0);
                this.Mode     = destMode;
                this.Mirrored = destMirrored;
                this.P_Draw();

                yield return(true);
            }
        }
Example #8
0
        private static List <GroupInfo> CreateKindGroups()
        {
            List <GroupInfo> groups = new List <GroupInfo>();

            for (int index = 0; index < MapCell.Kine_e_Names.Length; index++)
            {
                string name = MapCell.Kine_e_Names[index];

                {
                    int p = name.IndexOf(':');

                    if (p != -1)
                    {
                        name = name.Substring(p + 1);
                    }
                }

                string groupName;

                {
                    int p = name.IndexOf('/');

                    if (p != -1)
                    {
                        groupName = name.Substring(0, p);
                        name      = name.Substring(p + 1);
                    }
                    else
                    {
                        groupName = GroupInfo.DEFAULT_NAME;
                    }
                }

                GroupInfo group;

                {
                    int p = SCommon.IndexOf(groups, v => v.Name == groupName);

                    if (p != -1)
                    {
                        group = groups[p];
                    }
                    else
                    {
                        group = new GroupInfo()
                        {
                            Name = groupName,
                        };

                        groups.Add(group);
                    }
                }

                group.Members.Add(new GroupInfo.MemberInfo()
                {
                    Name  = name,
                    Index = index,
                });
            }
            return(groups);
        }
Example #9
0
        protected override void Invoke_02(string command, params string[] arguments)
        {
            int c = 0;

            if (command == "Chara")
            {
                this.Act.AddOnce(() =>
                {
                    string charaName = arguments[c++];
                    int chara        = SCommon.IndexOf(CHARA_NAMES, charaName);

                    if (chara == -1)
                    {
                        throw new DDError("Bad chara: " + charaName);
                    }

                    this.Chara = chara;
                });
            }
            else if (command == "Mode")
            {
                this.Act.AddOnce(() =>
                {
                    string modeName = arguments[c++];
                    int mode        = SCommon.IndexOf(this.ImageTable[this.Chara], v => v.Name == modeName);

                    if (mode == -1)
                    {
                        throw new DDError("Bad mode: " + mode);
                    }

                    this.Mode = mode;
                });
            }
            else if (command == "A")
            {
                this.Act.AddOnce(() => this.A = double.Parse(arguments[c++]));
            }
            else if (command == "Zoom")
            {
                this.Act.AddOnce(() => this.Zoom = double.Parse(arguments[c++]));
            }
            else if (command == "Mirror")
            {
                this.Act.AddOnce(() => this.Mirrored = int.Parse(arguments[c++]) != 0);
            }
            else if (command == "待ち")
            {
                int frame = int.Parse(arguments[c++]);

                this.Act.Add(SCommon.Supplier(this.待ち(frame)));
            }
            else if (command == "フェードイン")
            {
                this.Act.Add(SCommon.Supplier(this.フェードイン()));
            }
            else if (command == "フェードアウト")
            {
                this.Act.Add(SCommon.Supplier(this.フェードアウト()));
            }
            else if (command == "モード変更")
            {
                string modeName = arguments[c++];

                this.Act.Add(SCommon.Supplier(this.モード変更(modeName)));
            }
            else if (command == "モード変更_Mirror")
            {
                string modeName = arguments[c++];
                bool   mirrored = int.Parse(arguments[c++]) != 0;

                this.Act.Add(SCommon.Supplier(this.モード変更(modeName, mirrored)));
            }
            else if (command == "スライド")
            {
                double x = double.Parse(arguments[c++]);
                double y = double.Parse(arguments[c++]);

                this.Act.Add(SCommon.Supplier(this.スライド(x, y)));
            }
            else if (command == "Walk")
            {
                double x = double.Parse(arguments[c++]);

                this.Act.Add(SCommon.Supplier(this.Walk(x)));
            }
            else
            {
                ProcMain.WriteLog(command);
                throw new DDError();
            }
        }
Example #10
0
        private void Edit()
        {
            this.Map.Load();             // ゲーム中にマップを書き換える場合があるので、再ロードする。

            DDEngine.FreezeInput();
            DDUtils.SetMouseDispMode(true);
            LevelEditor.ShowDialog();

            int lastMouseX = DDMouse.X;
            int lastMouseY = DDMouse.Y;

            for (; ;)
            {
                if (LevelEditor.Dlg.XPressed)
                {
                    break;
                }

                // 廃止
                //if (DDKey.GetInput(DX.KEY_INPUT_E) == 1)
                //    break;

                I2Point cellPos = GameCommon.ToTablePoint(
                    DDGround.Camera.X + DDMouse.X,
                    DDGround.Camera.Y + DDMouse.Y
                    );

                MapCell cell = Game.I.Map.GetCell(cellPos);

                if (cell.IsDefault)
                {
                    // noop
                }
                else if (1 <= DDKey.GetInput(DX.KEY_INPUT_LSHIFT) && 1 <= DDKey.GetInput(DX.KEY_INPUT_LCONTROL)) // 左シフト・コントロール押下 -> 塗り潰し_L / 塗り潰し_R
                {
                    if (DDMouse.L.GetInput() == -1)                                                              // クリックを検出
                    {
                        this.Map.Save();                                                                         // 失敗を想定して、セーブしておく

                        switch (LevelEditor.Dlg.GetMode())
                        {
                        case LevelEditor.Mode_e.TILE:
                        {
                            string tileName = LevelEditor.Dlg.GetTile_L();

                            if (tileName != cell.TileName)
                            {
                                string targetTileName = cell.TileName;                                                 // cell.TileName は this.EditFill で変更される。

                                this.EditFill(
                                    cellPos,
                                    v => v.TileName == targetTileName,
                                    v =>
                                    {
                                        v.TileName = tileName;
                                        v.Tile     = TileCatalog.Create(tileName);
                                    }
                                    );
                            }
                        }
                        break;

                        case LevelEditor.Mode_e.ENEMY:
                        {
                            string enemyName = LevelEditor.Dlg.GetEnemy();

                            if (enemyName != cell.EnemyName)
                            {
                                string targetEnemyName = cell.EnemyName;                                                 // cell.EnemyName は this.EditFill で変更される。

                                this.EditFill(
                                    cellPos,
                                    v => v.EnemyName == targetEnemyName,
                                    v => v.EnemyName = enemyName
                                    );
                            }
                        }
                        break;

                        default:
                            throw null;                                     // never
                        }
                    }
                    else if (DDMouse.R.GetInput() == -1)         // クリックを検出
                    {
                        this.Map.Save();                         // 失敗を想定して、セーブしておく

                        switch (LevelEditor.Dlg.GetMode())
                        {
                        case LevelEditor.Mode_e.TILE:
                        {
                            string tileName = LevelEditor.Dlg.GetTile_R();

                            if (tileName != cell.TileName)
                            {
                                string targetTileName = cell.TileName;                                                 // cell.TileName は this.EditFill で変更される。

                                this.EditFill(
                                    cellPos,
                                    v => v.TileName == targetTileName,
                                    v =>
                                    {
                                        v.TileName = tileName;
                                        v.Tile     = TileCatalog.Create(tileName);
                                    }
                                    );
                            }
                        }
                        break;

                        case LevelEditor.Mode_e.ENEMY:
                            // none
                            break;

                        default:
                            throw null;                                     // never
                        }
                    }
                }
                else if (1 <= DDKey.GetInput(DX.KEY_INPUT_LSHIFT))                 // 左シフト押下 -> 移動 / none
                {
                    if (1 <= DDMouse.L.GetInput())
                    {
                        DDGround.Camera.X -= DDMouse.X - lastMouseX;
                        DDGround.Camera.Y -= DDMouse.Y - lastMouseY;

                        DDUtils.ToRange(ref DDGround.Camera.X, 0.0, this.Map.W * GameConsts.TILE_W - DDConsts.Screen_W);
                        DDUtils.ToRange(ref DDGround.Camera.Y, 0.0, this.Map.H * GameConsts.TILE_H - DDConsts.Screen_H);

                        DDGround.ICamera.X = SCommon.ToInt(DDGround.Camera.X);
                        DDGround.ICamera.Y = SCommon.ToInt(DDGround.Camera.Y);
                    }
                    else if (1 <= DDMouse.R.GetInput())
                    {
                        // none
                    }
                }
                else if (1 <= DDKey.GetInput(DX.KEY_INPUT_LCONTROL))                 // 左コントロール押下 -> スポイト_L / スポイト_R
                {
                    if (1 <= DDMouse.L.GetInput())
                    {
                        switch (LevelEditor.Dlg.GetMode())
                        {
                        case LevelEditor.Mode_e.TILE:
                            LevelEditor.Dlg.SetTile_L(cell.TileName);
                            break;

                        case LevelEditor.Mode_e.ENEMY:
                            LevelEditor.Dlg.SetEnemy(cell.EnemyName);
                            break;

                        default:
                            throw null;                                     // never
                        }
                    }
                    else if (1 <= DDMouse.R.GetInput())
                    {
                        switch (LevelEditor.Dlg.GetMode())
                        {
                        case LevelEditor.Mode_e.TILE:
                            LevelEditor.Dlg.SetTile_R(cell.TileName);
                            break;

                        case LevelEditor.Mode_e.ENEMY:
                            // none
                            break;

                        default:
                            throw null;                                     // never
                        }
                    }
                }
                else if (1 <= DDKey.GetInput(DX.KEY_INPUT_LALT))        // 左 ALT 押下 -> 自機ワープ / none
                {
                    if (DDMouse.L.GetInput() == -1)                     // クリックを検出
                    {
                        this.Player.X = cellPos.X * GameConsts.TILE_W + GameConsts.TILE_W / 2;
                        this.Player.Y = cellPos.Y * GameConsts.TILE_H + GameConsts.TILE_H / 2;

                        DDGround.EL.Add(SCommon.Supplier(Effects.中爆発(this.Player.X, this.Player.Y)));                         // アクションが分かるように
                    }
                    else if (1 <= DDMouse.R.GetInput())
                    {
                        // none
                    }
                }
                else                 // シフト系押下無し -> セット_L / セット_R (敵はクリア)
                {
                    if (1 <= DDMouse.L.GetInput())
                    {
                        switch (LevelEditor.Dlg.GetMode())
                        {
                        case LevelEditor.Mode_e.TILE:
                        {
                            string tileName = LevelEditor.Dlg.GetTile_L();

                            cell.TileName = tileName;
                            cell.Tile     = TileCatalog.Create(tileName);
                        }
                        break;

                        case LevelEditor.Mode_e.ENEMY:
                        {
                            string enemyName = LevelEditor.Dlg.GetEnemy();

                            cell.EnemyName = enemyName;
                        }
                        break;

                        default:
                            throw null;                                     // never
                        }
                    }
                    else if (1 <= DDMouse.R.GetInput())
                    {
                        switch (LevelEditor.Dlg.GetMode())
                        {
                        case LevelEditor.Mode_e.TILE:
                        {
                            string tileName = LevelEditor.Dlg.GetTile_R();

                            cell.TileName = tileName;
                            cell.Tile     = TileCatalog.Create(tileName);
                        }
                        break;

                        case LevelEditor.Mode_e.ENEMY:
                            cell.EnemyName = GameConsts.ENEMY_NONE;
                            break;

                        default:
                            throw null;                                     // never
                        }
                    }
                }

                if (DDKey.GetInput(DX.KEY_INPUT_S) == 1)                 // S キー --> Save
                {
                    this.Map.Save();

                    // 表示
                    {
                        int endFrame = DDEngine.ProcFrame + 60;

                        DDGround.EL.Add(() =>
                        {
                            DDPrint.SetDebug(0, 16);
                            DDPrint.SetBorder(new I3Color(0, 0, 0));
                            DDPrint.Print("セーブしました...");
                            DDPrint.Reset();

                            return(DDEngine.ProcFrame < endFrame);
                        });
                    }
                }
                if (DDKey.GetInput(DX.KEY_INPUT_L) == 1)                 // L キー --> Load
                {
                    this.Map.Load();

                    // 表示
                    {
                        int endFrame = DDEngine.ProcFrame + 60;

                        DDGround.EL.Add(() =>
                        {
                            DDPrint.SetDebug(0, 16);
                            DDPrint.SetBorder(new I3Color(0, 0, 0));
                            DDPrint.Print("ロードしました...");
                            DDPrint.Reset();

                            return(DDEngine.ProcFrame < endFrame);
                        });
                    }
                }
                if (DDKey.GetInput(DX.KEY_INPUT_H) == 1) // H キー --> セット_L(10x10)
                {
                    this.Map.Save();                     // 失敗を想定して、セーブしておく

                    int firstTileIndex;

                    {
                        string tileName = LevelEditor.Dlg.GetTile_L();
                        int    index    = SCommon.IndexOf(TileCatalog.GetNames(), name => name == tileName);

                        if (index == -1)
                        {
                            throw new DDError();
                        }

                        firstTileIndex = index;
                    }

                    int offset = 0;

                    for (int xc = 0; xc < 10; xc++)
                    {
                        for (int yc = 0; yc < 10; yc++)
                        {
                            string tileName = TileCatalog.GetNames()[(firstTileIndex + offset) % TileCatalog.GetNames().Length];
                            offset++;

                            I2Point subCellPos = new I2Point(cellPos.X + xc, cellPos.Y + yc);
                            MapCell subCell    = Game.I.Map.GetCell(subCellPos);

                            subCell.TileName = tileName;
                            subCell.Tile     = TileCatalog.Create(tileName);
                        }
                    }
                }

                DDCurtain.DrawCurtain();

                if (LevelEditor.Dlg.IsShowTile())
                {
                    this.DrawMap();
                }

                if (LevelEditor.Dlg.IsShowEnemy())
                {
                    LevelEditor.DrawEnemy();
                }

                lastMouseX = DDMouse.X;
                lastMouseY = DDMouse.Y;

                DDEngine.EachFrame();
            }
            DDEngine.FreezeInput();
            DDUtils.SetMouseDispMode(false);
            LevelEditor.CloseDialog();

            this.Map.Save();             // ★★★ マップをセーブする ★★★
        }