Ejemplo n.º 1
0
        /// <summary>
        /// イベントコマンド
        /// </summary>
        /// <param name="readStatus">読み込み経過状態</param>
        /// <param name="commonEvent">結果格納インスタンス</param>
        private void ReadEventCommand(BinaryReadStatus readStatus, CommonEvent commonEvent)
        {
            var length = readStatus.ReadInt();

            readStatus.IncreaseIntOffset();

            var reader = new EventCommandListReader();

            commonEvent.EventCommands = reader.Read(readStatus, length);
        }
Ejemplo n.º 2
0
        private void ReadMapEventOnePage(ICollection <MapEventPage> mapEventPages)
        {
            var result = new MapEventPage();

            // ヘッダチェック
            foreach (var b in MapEventPage.Header)
            {
                if (ReadStatus.ReadByte() != b)
                {
                    throw new InvalidOperationException(
                              $"マップイベントページのヘッダが異なります。(offset: {ReadStatus.Offset})");
                }

                ReadStatus.IncreaseByteOffset();
            }

            var graphicInfo = new MapEventPageGraphicInfo();

            // タイル画像ID
            var graphicTileId = (MapEventTileId)ReadStatus.ReadInt();

            if (graphicTileId != MapEventTileId.NotUse)
            {
                graphicInfo.IsGraphicTileChip = true;
                graphicInfo.GraphicTileId     = graphicTileId;
            }

            ReadStatus.IncreaseIntOffset();

            // キャラチップ名
            var charaChipString = ReadStatus.ReadString();

            if (!graphicInfo.IsGraphicTileChip)
            {
                graphicInfo.CharaChipFilePath = charaChipString.String;
            }

            ReadStatus.AddOffset(charaChipString.ByteLength);

            // 初期キャラ向き
            var initDirection = ReadStatus.ReadByte();

            graphicInfo.InitDirection = CharaChipDirection.FromByte(initDirection);
            ReadStatus.IncreaseByteOffset();

            // 初期アニメーション番号
            graphicInfo.InitAnimationId = ReadStatus.ReadByte();
            ReadStatus.IncreaseByteOffset();

            // キャラチップ透過度
            graphicInfo.CharaChipOpacity = ReadStatus.ReadByte();
            ReadStatus.IncreaseByteOffset();

            // キャラチップ表示形式
            graphicInfo.CharaChipDrawType = PictureDrawType.FromByte(ReadStatus.ReadByte());
            ReadStatus.IncreaseByteOffset();

            result.GraphicInfo = graphicInfo;

            var bootInfo = new MapEventPageBootInfo();

            // 起動条件
            bootInfo.MapEventBootType = MapEventBootType.FromByte(ReadStatus.ReadByte());
            ReadStatus.IncreaseByteOffset();

            // 条件1~4演算子 & 使用フラグ
            var conditions = new List <MapEventBootCondition>
            {
                new MapEventBootCondition(),
                new MapEventBootCondition(),
                new MapEventBootCondition(),
                new MapEventBootCondition(),
            };

            for (var i = 0; i < 4; i++)
            {
                conditions[i].Operation    = CriteriaOperator.FromByte((byte)(ReadStatus.ReadByte() & 0xF0));
                conditions[i].UseCondition = (byte)(ReadStatus.ReadByte() & 0x0F) != 0;
                ReadStatus.IncreaseByteOffset();
            }

            // 条件1~4左辺
            for (var i = 0; i < 4; i++)
            {
                conditions[i].LeftSide = ReadStatus.ReadInt();
                ReadStatus.IncreaseIntOffset();
            }

            // 条件1~4右辺
            for (var i = 0; i < 4; i++)
            {
                conditions[i].RightSide = ReadStatus.ReadInt();
                ReadStatus.IncreaseIntOffset();
                bootInfo.SetEventBootCondition(i, conditions[i]);
            }

            result.BootInfo = bootInfo;

            var moveRouteInfo = new MapEventPageMoveRouteInfo();

            // アニメ速度
            moveRouteInfo.AnimateSpeed = AnimateSpeed.FromByte(ReadStatus.ReadByte());
            ReadStatus.IncreaseByteOffset();

            // 移動速度
            moveRouteInfo.MoveSpeed = MoveSpeed.FromByte(ReadStatus.ReadByte());
            ReadStatus.IncreaseByteOffset();

            // 移動頻度
            moveRouteInfo.MoveFrequency = MoveFrequency.FromByte(ReadStatus.ReadByte());
            ReadStatus.IncreaseByteOffset();

            // 移動ルート
            moveRouteInfo.MoveType = MoveType.FromByte(ReadStatus.ReadByte());
            ReadStatus.IncreaseByteOffset();

            var option = new MapEventPageOption();

            // オプション
            var optionByte = ReadStatus.ReadByte();

            option.SetOptionFlag(optionByte);
            ReadStatus.IncreaseByteOffset();

            result.Option = option;

            // カスタム移動ルートフラグ
            var actionEntry         = new ActionEntry();
            var customMoveRouteFlag = ReadStatus.ReadByte();

            actionEntry.SetOptionFlag(customMoveRouteFlag);
            ReadStatus.IncreaseByteOffset();

            // 動作指定コマンド数
            actionEntry.CommandList = ReadCharaMoveCommand();

            moveRouteInfo.CustomMoveRoute = actionEntry;
            result.MoveRouteInfo          = moveRouteInfo;

            // イベント行数
            var eventLength = ReadStatus.ReadInt();

            ReadStatus.IncreaseIntOffset();

            // イベントコマンド
            var eventCommandListReader = new EventCommandListReader();

            result.EventCommands = eventCommandListReader.Read(eventLength, ReadStatus);

            // イベントコマンド終端チェック
            foreach (var b in EventCommandList.EndEventCommand)
            {
                if (ReadStatus.ReadByte() != b)
                {
                    throw new InvalidOperationException(
                              $"イベントコマンド後の値が異なります。(offset: {ReadStatus.Offset})");
                }

                ReadStatus.IncreaseByteOffset();
            }

            // 影グラフィック番号
            result.ShadowGraphicId = ReadStatus.ReadByte();
            ReadStatus.IncreaseByteOffset();

            // 接触範囲拡張X
            var rangeWidth = ReadStatus.ReadByte();

            ReadStatus.IncreaseByteOffset();

            // 接触範囲拡張Y
            var rangeHeight = ReadStatus.ReadByte();

            ReadStatus.IncreaseByteOffset();

            result.HitExtendRange = (rangeWidth, rangeHeight);

            // イベントページ末尾チェック
            foreach (var b in MapEventPage.Footer)
            {
                if (ReadStatus.ReadByte() != b)
                {
                    throw new InvalidOperationException(
                              $"イベントページ末尾の値が異なります。(offset: {ReadStatus.Offset})");
                }

                ReadStatus.IncreaseByteOffset();
            }

            // 完了
            mapEventPages.Add(result);
        }