Example #1
0
        public static void MoveRouteInfoSetTest(bool isNull, bool isError)
        {
            var instance            = new MapEventPage();
            var changedPropertyList = new List <string>();

            instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };

            var errorOccured = false;

            try
            {
                instance.MoveRouteInfo = isNull ? null : new MapEventPageMoveRouteInfo();
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

            // エラーフラグが一致すること
            Assert.AreEqual(errorOccured, isError);

            // 意図したとおりプロパティ変更通知が発火していること
            if (errorOccured)
            {
                Assert.AreEqual(changedPropertyList.Count, 0);
            }
            else
            {
                Assert.AreEqual(changedPropertyList.Count, 1);
                Assert.IsTrue(changedPropertyList[0].Equals(nameof(MapEventPage.MoveRouteInfo)));
            }
        }
Example #2
0
        public static void EventCommandsSetTest(IReadOnlyList <IEventCommand> commands, bool isError)
        {
            var instance            = new MapEventPage();
            var changedPropertyList = new List <string>();

            instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };

            var errorOccured = false;

            try
            {
                instance.EventCommands = new EventCommandList(commands);
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

            // エラーフラグが一致すること
            Assert.AreEqual(errorOccured, isError);

            // 意図したとおりプロパティ変更通知が発火していること
            if (errorOccured)
            {
                Assert.AreEqual(changedPropertyList.Count, 0);
            }
            else
            {
                Assert.AreEqual(changedPropertyList.Count, 1);
                Assert.IsTrue(changedPropertyList[0].Equals(nameof(MapEventPage.EventCommands)));
            }
        }
        private List <OutputStructTable> SetTrigersTableList(MapEventPage mapEventPage)
        {
            var trigersTableList = new List <OutputStructTable>();

            if (mapEventPage.Triggers != null)
            {
                for (int id = 0; id < mapEventPage.Triggers.Count(); id++)
                {
                    var trigger = mapEventPage.Triggers[id];
                    var header  = new List <string>()
                    {
                        "IsUsed", "Var", "ComparisonValue", "ComparisonMethod"
                    };
                    var data = new List <List <string> >()
                    {
                        new List <string>()
                        {
                            trigger.IsUsed.ToString(), trigger.TriggerVariable.ToString(),
                        trigger.ComparisonValue.ToString(), Utils.WodiKs.ConvertComparisonMethodToName(trigger.ComparisonMethodType)
                        }
                    };
                    trigersTableList.Add(new OutputStructTable($"条件{id}", header, data));
                }
            }
            return(trigersTableList);
        }
Example #4
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     SpriteSelectionWindow.SetPageSetterAction((page) =>
     {
         this.Page = page;
     });
     SpriteSelectionWindow.ShowWindow(this.Page);
 }
        private List <List <string> > SetExpandCollisionRangeData(MapEventPage mapEventPage)
        {
            var expandCollisionRangeData = new List <List <string> >();
            var record = new List <string>()
            {
                mapEventPage.ExpandCollisionRangeX.ToString(), mapEventPage.ExpandCollisionRangeY.ToString()
            };

            expandCollisionRangeData.Add(record);
            return(expandCollisionRangeData);
        }
 public MapEventPageStr(MapEventPage mapEventPage, int pageIDNo, MapEventStr mapEventStr)
 {
     Parent                = mapEventStr;
     PageID                = new OutputStructSentence("ページID", pageIDNo.ToString());
     GraphicType           = new OutputStructTable("グラフィックの設定", SetGraphicTypeHeader(mapEventPage.GraphicType), SetGraphicTypeData(mapEventPage, mapEventPage.GraphicType));
     ShadowGraphicNo       = new OutputStructSentence("影グラフィック番号", mapEventPage.ShadowGraphicNo.ToString());
     TriggerConditionsType = new OutputStructSentence("マップイベント起動条件", Utils.WodiKs.ConvertTriggerConditionsToName(mapEventPage.TriggerConditionsType));
     Triggers              = new OutputStructTables("起動条件データ", SetTrigersTableList(mapEventPage));
     ExpandCollisionRange  = new OutputStructTable("接触範囲拡張", SetExpandCollisionRangeHeader(), SetExpandCollisionRangeData(mapEventPage));
     MovementData          = new OutputStructTables("移動情報データ", SetMovementDataTableList(mapEventPage.MovementData));
     SetEventCommandsAndMoveEventCommands(mapEventPage.EventCommandList);
 }
Example #7
0
        public static void SerializeTest()
        {
            var target = new MapEventPage
            {
                ShadowGraphicId = 4
            };
            var changedPropertyList = new List <string>();

            target.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };

            var clone = DeepCloner.DeepClone(target);

            Assert.IsTrue(clone.Equals(target));

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
        }
Example #8
0
 public static void ShowWindow(MapEventPage initialPage)
 {
     if (SpriteSelectionWindow.WindowInstance == null)
     {
         SpriteSelectionWindow.WindowInstance = new SpriteSelectionWindowView
         {
             Owner = LoadingWindowViewModel.MainWindow
         };
         SpriteSelectionWindow.WindowInstance.Closing += (s, e) =>
         {
             e.Cancel = true;
             SpriteSelectionWindow.WindowInstance.Hide();
         };
         SpriteSelectionWindow.WindowInstance.DataContext = SpriteSelectionWindow.Instance;
     }
     SpriteSelectionWindow.RefreshWindow(initialPage);
     SpriteSelectionWindow.WindowInstance.Show();
     SpriteSelectionWindow.HasBeenShown = true;
 }
        private List <List <string> > SetGraphicTypeData(MapEventPage mapEventPage, MapEventPage.GraphicTypes graphicType)
        {
            var graphicTypeData = new List <List <string> >();
            var record          = new List <string>()
            {
                Utils.WodiKs.ConvertGraphicTypesToName(graphicType)
            };

            switch (graphicType)
            {
            case MapEventPage.GraphicTypes.NoGraphic:
            {
                break;
            }

            case MapEventPage.GraphicTypes.CharaChip:
            {
                record.AddRange(new List <string>()
                    {
                        mapEventPage.CharaAnimeNumber.ToString(), mapEventPage.CharaDirection.ToString(), Utils.String.Trim(mapEventPage.GraphicFilePath)
                    });
                break;
            }

            case MapEventPage.GraphicTypes.TileSet:
            {
                record.AddRange(new List <string>()
                    {
                        mapEventPage.TileSetChipID.ToString(), Utils.String.Trim(mapEventPage.GraphicFilePath)
                    });
                break;
            }
            }
            graphicTypeData.Add(record);
            return(graphicTypeData);
        }
Example #10
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);
        }
Example #11
0
    async void RenderMap()
    {
        DatabaseMergedData systemDB = await ReadSystemDB();

        var mapDataList = systemDB.GetDataDescList(0);

        if (mapNo >= mapDataList.Count)
        {
            return;
        }

        string  mapPath   = dataPath + mapDataList[mapNo].ItemValueList[0].StringValue.ToString();
        var     mpsReader = new MpsFileReader();
        MapData mapData   = await mpsReader.ReadFileAsync(mapPath);

        string      tileSetPath = dataPath + "BasicData/TileSetData.dat";
        var         reader      = new TileSetDataFileReader();
        TileSetData setData     = await reader.ReadFileAsync(tileSetPath);

        TileSetSetting tileSetting = setData.TileSetSettingList[mapData.TileSetId];

        ReadBaseTileTexture(tileSetting.BaseTileSetFileName);

        ReadAutoTileTextures(tileSetting.AutoTileFileNameList.ToArray());

        Texture2D mapTexture
            = new Texture2D(mapData.MapSizeWidth * chipSize, mapData.MapSizeHeight * chipSize);

        for (int i = 0; i < mapData.MapSizeHeight; i++)
        {
            for (int j = 0; j < mapData.MapSizeWidth; j++)
            {
                for (int k = 0; k < 3; k++)
                {
                    int id = mapData.GetLayer(k).Chips[j][i];
                    if (mapData.GetLayer(k).Chips[j][i].IsAutoTile)
                    {
                        RenderAutoTile(mapTexture, j, i, id);
                    }
                    else
                    {
                        RenderNormalTile(mapTexture, j, i, id);
                    }
                }
            }
        }

        for (int i = 0; i < mapData.MapEvents.Count; i++)
        {
            int          x            = mapData.MapEvents[i].Position.X;
            int          y            = mapData.MapEvents[i].Position.Y;
            MapEventPage mapEventPage = mapData.MapEvents[i].MapEventPageList[0];
            if (mapEventPage.GraphicInfo.IsGraphicTileChip)
            {
                int tileId = mapEventPage.GraphicInfo.GraphicTileId;
                RenderNormalTile(mapTexture, x, y, tileId);
            }
            else if (!string.IsNullOrEmpty(mapEventPage.GraphicInfo.CharaChipFilePath))
            {
                string graphicPath = dataPath + mapEventPage.GraphicInfo.CharaChipFilePath;
                Debug.Log(graphicPath);
                CharaChipDirection charaChipDirection = mapEventPage.GraphicInfo.InitDirection;
                Texture2D          charaChipTexture   = new Texture2D(1, 1);
                byte[]             bytes = System.IO.File.ReadAllBytes(graphicPath);
                charaChipTexture.LoadImage(bytes);
                charaChipTexture.filterMode = FilterMode.Point;
                RenderCharaChip(mapTexture, x, y, charaChipTexture, charaChipDirection);
            }
        }

        mapTexture.Apply();
        mapTexture.filterMode = FilterMode.Point;

        Sprite sprite = Sprite.Create(mapTexture,
                                      new Rect(0.0f, 0.0f, mapTexture.width, mapTexture.height), new Vector2(0.5f, 0.5f), 1.0f);

        mapSprite.sprite = sprite;
    }
Example #12
0
 public static void RefreshWindow(MapEventPage initialPage)
 {
     SpriteSelectionWindow.Instance.CurrentPage = initialPage;
 }
Example #13
0
    void RenderMap()
    {
        MapData mapData = CoreData.Instance.mapDataArray[CoreData.Instance.currentMapID];

        TileSetSetting tileSetting = CoreData.Instance.tileSetData.TileSetSettingList[mapData.TileSetId];

        ReadBaseTileTexture(tileSetting.BaseTileSetFileName);

        ReadAutoTileTextures(tileSetting.AutoTileFileNameList.ToArray());

        Texture2D mapTexture
            = new Texture2D(mapData.MapSizeWidth * chipSize, mapData.MapSizeHeight * chipSize);

        for (int i = 0; i < mapTexture.height; i++)
        {
            for (int j = 0; j < mapTexture.width; j++)
            {
                mapTexture.SetPixel(j, i, new Color(0, 0, 0));
            }
        }

        for (int i = 0; i < mapData.MapSizeHeight; i++)
        {
            for (int j = 0; j < mapData.MapSizeWidth; j++)
            {
                for (int k = 0; k < 3; k++)
                {
                    int id = mapData.GetLayer(k).Chips[j][i];
                    if (mapData.GetLayer(k).Chips[j][i].IsAutoTile)
                    {
                        RenderAutoTile(mapTexture, j, i, id);
                    }
                    else
                    {
                        RenderNormalTile(mapTexture, j, i, id);
                    }
                }
            }
        }

        for (int i = 0; i < mapData.MapEvents.Count; i++)
        {
            int          x            = mapData.MapEvents[i].Position.X;
            int          y            = mapData.MapEvents[i].Position.Y;
            MapEventPage mapEventPage = mapData.MapEvents[i].MapEventPageList[0];
            if (mapEventPage.GraphicInfo.IsGraphicTileChip)
            {
                int tileId = mapEventPage.GraphicInfo.GraphicTileId;
                RenderNormalTile(mapTexture, x, y, tileId);
            }
            else if (!string.IsNullOrEmpty(mapEventPage.GraphicInfo.CharaChipFilePath))
            {
                string graphicPath = dataPath + mapEventPage.GraphicInfo.CharaChipFilePath;
                Debug.Log(graphicPath);
                CharaChipDirection charaChipDirection = mapEventPage.GraphicInfo.InitDirection;
                Texture2D          charaChipTexture   = new Texture2D(1, 1);
                byte[]             bytes = System.IO.File.ReadAllBytes(graphicPath);
                charaChipTexture.LoadImage(bytes);
                charaChipTexture.filterMode = FilterMode.Point;
                RenderCharaChip(mapTexture, x, y, charaChipTexture, charaChipDirection);
            }
        }

        mapTexture.Apply();
        mapTexture.filterMode = FilterMode.Point;

        Sprite sprite = Sprite.Create(mapTexture,
                                      new Rect(0.0f, 0.0f, mapTexture.width, mapTexture.height), new Vector2(0.5f, 0.5f), 1.0f);

        /*sprite = Sprite.Create(baseTileTexture,
         *  new Rect(0, 0, baseTileTexture.width, baseTileTexture.height), new Vector2(0.5f, 0.5f), 1.0f);*/
        mapSprite.sprite = sprite;
    }