Beispiel #1
0
 void HandleExporter(MapDataInfo aMapDataInfo, BaseExporter aBaseExporter)
 {
     if (aBaseExporter is GroundExporter)
     {
         GroundExporter typedExporter = (GroundExporter)aBaseExporter;
         aMapDataInfo.m_GroundDataInfo.Add(typedExporter.ToGroundDataInfo());
     }
     else if (aBaseExporter is CameraLimitExporter)
     {
         CameraLimitExporter typedExporter = (CameraLimitExporter)aBaseExporter;
         aMapDataInfo.m_CameraLimitDataInfo.Add(typedExporter.ToCameraLimitDataInfo());
     }
     else if (aBaseExporter is ColliderExporter)
     {
         ColliderExporter typedExporter = (ColliderExporter)aBaseExporter;
         aMapDataInfo.m_ColliderDataInfo.Add(typedExporter.ToColliderDataInfo());
     }
     else if (aBaseExporter is SpawnPointExporter)
     {
         SpawnPointExporter typedExporter = (SpawnPointExporter)aBaseExporter;
         aMapDataInfo.m_SpawnPointDataInfo.Add(typedExporter.ToSpawnPointDataInfo());
     }
     else if (aBaseExporter is TeleportExporter)
     {
         TeleportExporter typedExporter = (TeleportExporter)aBaseExporter;
         aMapDataInfo.m_TeleportDataInfo.Add(typedExporter.ToTeleportDataInfo());
     }
     else
     {
         Debug.LogError("UnHandled Type of Exporter :: Name =" + aBaseExporter.name + " :: TypeOf =" + aBaseExporter.GetType());
     }
 }
Beispiel #2
0
    private void Init()
    {
        UIHelper.AddButtonListener(Vars["select"], Select);

        mapInfo = new MapDataInfo();
        mapInfo.SettingData();

        var e = mapInfo.MapList;

        var rt = content.GetComponent <RectTransform>();

        foreach (var map in e)
        {
            var size = rt.sizeDelta;
            size.Set(size.x, size.y + 300.0f);
            rt.sizeDelta = size;

            GameObject obj = Instantiate(Resources.Load <GameObject>("Prefabs/HomeScene/UI/StageSelectButton"));
            obj.GetComponent <SelectMapData>().SetUp(map.Value);
            obj.transform.SetParent(content);
            obj.transform.localPosition = sponStartPos;
            obj.transform.localScale    = new Vector3(0.7f, 0.8f, 1.0f);

            sponStartPos.y -= 300;
        }
    }
Beispiel #3
0
    public void LoadLowData()
    {
        {
            TextAsset    data    = Resources.Load("TestJson/Map_MapData", typeof(TextAsset)) as TextAsset;
            StringReader sr      = new StringReader(data.text);
            string       strSrc  = sr.ReadToEnd();
            JSONObject   MapData = new JSONObject(strSrc);

            for (int i = 0; i < MapData.list.Count; i++)
            {
                MapDataInfo tmpInfo = new MapDataInfo();
                tmpInfo.id                 = (uint)MapData[i]["id_ui"].n;
                tmpInfo.type               = (byte)MapData[i]["type_b"].n;
                tmpInfo.scene              = MapData[i]["scene_c"].str;
                tmpInfo.maskfile           = MapData[i]["maskfile_c"].str;
                tmpInfo.regenposX          = (uint)MapData[i]["regenposX_ui"].n;
                tmpInfo.regenposY          = (uint)MapData[i]["regenposY_ui"].n;
                tmpInfo.AddColorR          = (byte)MapData[i]["AddColorR_b"].n;
                tmpInfo.AddColorG          = (byte)MapData[i]["AddColorG_b"].n;
                tmpInfo.AddColorB          = (byte)MapData[i]["AddColorB_b"].n;
                tmpInfo.AddIntensity       = (float)MapData[i]["AddIntensity_f"].n;
                tmpInfo.Bgm                = MapData[i]["Bgm_c"].str;
                tmpInfo.CharLightIntensity = (float)MapData[i]["CharLightIntensity_f"].n;
                tmpInfo.ShadowStrength     = (float)MapData[i]["ShadowStrength_f"].n;
                tmpInfo.Bloom_Enable       = (byte)MapData[i]["Bloom_Enable_b"].n;

                tmpInfo.Bloom_Threshhold     = (float)MapData[i]["Bloom_Threshhold_f"].n;
                tmpInfo.Bloom_Intensity      = (float)MapData[i]["Bloom_Intensity_f"].n;
                tmpInfo.Bloom_BlurSize       = (float)MapData[i]["Bloom_BlurSize_f"].n;
                tmpInfo.Bloom_BlurIterations = (float)MapData[i]["Bloom_BlurIterrations_f"].n;

                MapDataInfoDic.Add(tmpInfo.id, tmpInfo);
            }
        }
    }
Beispiel #4
0
    /// <summary>
    /// 点击退出设置按钮
    /// </summary>
    public void ExitSetting_Click()
    {
        if (nowUIFocus)
        {
            nowUIFocus.LostForcus();
        }
        bigMapOperateState = EnumBigMapOperateState.OperateMap;
        //根据当前的设置更新状态
        UIFocusDropdown thisFocus = uiFocusPath.NewUIFocusArray.Where(temp => string.Equals(temp.Tag, "SceneDropDown")).FirstOrDefault() as UIFocusDropdown;

        if (thisFocus != null)
        {
            int index = thisFocus.dropdown.value;
            if (index >= 0)
            {
                SceneData       sceneData       = DataCenter.Instance.GetMetaData <SceneData>();
                SceneDataInfo[] sceneDataInfos  = sceneData.GetAllSceneData();
                List <string>   sceneNameList   = sceneDataInfos.Where(temp => temp.SceneAction == EnumSceneAction.Game).Select(temp => temp.SceneName).ToList();
                string          selectSceneName = sceneNameList[index];
                if (!string.Equals(nowSceneName, selectSceneName))//当前地图显示的和选择的场景不一致则重新载入
                {
                    MapData     mapData     = DataCenter.Instance.GetMetaData <MapData>();
                    MapDataInfo mapDataInfo = mapData[selectSceneName];
                    if (mapDataInfo != null)
                    {
                        mapDataInfo.Load();
                        PlayerState playerState   = DataCenter.Instance.GetEntity <PlayerState>();
                        Sprite      mapMaskSprite = playerState.GetSceneMapMaskSprite(selectSceneName, mapDataInfo.MapSprite);
                        ResetMap(mapDataInfo.MapSprite, mapMaskSprite, mapDataInfo.SceneRect, selectSceneName);
                    }
                }
            }
        }
    }
Beispiel #5
0
        public static void Save(string filename, MapDataInfo map)
        {
            var layers  = GetConfigLayerBytes(map);
            var ranges  = GetRangeObjectBytes(map);
            var points  = GetPointObjectBytes(map);
            var effects = GetEffectObjectBytes(map);

            // Header is 96 bytes long
            const int md3HeaderSize = 96;
            var       md3Size       = md3HeaderSize + layers.Length + points.Length + ranges.Length + effects.Length;
            var       totalSize     = md3Size + map.BacFileSize + map.TilFileSize + map.LyrFileSize;

            var file = File.OpenWrite(filename);

            using (var w = new BinaryWriter(file))
            {
                w.Write('M');
                w.Write('D');
                w.Write('N');
                w.Write('_');
                w.Write(map.Version);
                w.Write(map.TileBpp);
                w.Write(map.Param3);
                w.Write(map.Param4);

                // todo?
                w.Write(totalSize); // Total size of MD3 + BAC + TIL + LYR

                w.Write(map.Param6);
                w.Write(map.Param7);
                w.Write(map.MapSizeX);
                w.Write(map.MapSizeY);
                w.Write(map.TileSizeX);
                w.Write(map.TileSizeY);
                w.Write(map.TileCountX);
                w.Write(map.TileCountY);
                w.Write(map.Param14);
                w.Write(map.LyrDataCount);
                w.Write(map.TileGroupCount);
                w.Write(map.ConfigLayers.Count);
                w.Write(map.RangeObjects.Count);
                w.Write(map.PointObjects.Count);
                w.Write(map.EffectObjects.Count);
                w.Write(map.Param21);
                w.Write(map.Param22);
                w.Write(map.Param23);

                w.Write(layers);
                w.Write(ranges);
                w.Write(points);
                w.Write(effects);
            }

            file.Close();
        }
Beispiel #6
0
        public static List <TileData> Read(MapDataInfo map, Stream stream)
        {
            // 0x0000E0F0 is the magic number for compressed til files
            // Keep in mind that this is little endian
            if (stream.ReadByte() == 0xF0 && stream.ReadByte() == 0xE0)
            {
                // Decompress
                stream.Seek(0, SeekOrigin.Begin);
                return(ParseData(CompressedFileLoader.Decompress(stream), map));
            }

            stream.Seek(0, SeekOrigin.Begin);
            return(ParseData(GetBytesFromStream(stream), map));
        }
Beispiel #7
0
        private static byte[] GetEffectObjectBytes(MapDataInfo Map)
        {
            using (var ms = new MemoryStream())
            {
                using (var bw = new BinaryWriter(ms))
                {
                    foreach (var effect in Map.EffectObjects)
                    {
                        bw.Write(effect);
                    }

                    return(ms.ToArray());
                }
            }
        }
Beispiel #8
0
    public MapDataInfo CreateMapDataInfo()
    {
        MapDataInfo mapDataInfo = new MapDataInfo();

        mapDataInfo.m_MapName = m_MapName;
        mapDataInfo.m_ActivatedColliderLayers = m_ActivatedColliderLayers;

        BaseExporter[] baseExporter = gameObject.GetComponentsInChildren <BaseExporter> ();

        for (int i = 0; i < baseExporter.Length; i++)
        {
            HandleExporter(mapDataInfo, baseExporter[i]);
        }

        return(mapDataInfo);
    }
Beispiel #9
0
 public TLData()
 {
     info = new MapDataInfo()
     {
         Key = "TL",
         MainLayerUriFormat = "http://Kodestruct2.azurewebsites.net/MapsSources/ASCE7_10/Seismic/TL/Original/{0}.png",
         UnderlayUriFormat  = "http://Kodestruct2.azurewebsites.net/MapsSources/ASCE7_10/Seismic/TL/Color/{0}.png",
         MaxLongitude       = -65.0,
         MinLongitude       = -125.0,
         MaxLatitude        = 50.0,
         MinLatitude        = 24.6,
         PixelHeight        = 509,
         PixelWidth         = 1201,
         RangeMaxValue      = 16,
         RangeMinValue      = 4
     };
 }
Beispiel #10
0
        private static byte[] GetPointObjectBytes(MapDataInfo Map)
        {
            using (var ms = new MemoryStream())
            {
                using (var bw = new BinaryWriter(ms))
                {
                    foreach (var point in Map.PointObjects)
                    {
                        bw.Write(point.Id);
                        bw.Write(point.Type);
                        bw.Write(point.MapId);
                        bw.Write(point.X);
                        bw.Write(point.Y);
                        bw.Write(point.Options);
                    }

                    return(ms.ToArray());
                }
            }
        }
Beispiel #11
0
        private static byte[] GetRangeObjectBytes(MapDataInfo Map)
        {
            using (var ms = new MemoryStream())
            {
                using (var bw = new BinaryWriter(ms))
                {
                    foreach (var range in Map.RangeObjects)
                    {
                        bw.Write(range.Type);
                        bw.Write(range.Id);
                        bw.Write(range.Destination);
                        bw.Write(range.X1);
                        bw.Write(range.Y1);
                        bw.Write(range.X2);
                        bw.Write(range.Y2);
                        bw.Write(range.Options);
                    }

                    return(ms.ToArray());
                }
            }
        }
Beispiel #12
0
        private static byte[] GetConfigLayerBytes(MapDataInfo Map)
        {
            using (var ms = new MemoryStream())
            {
                using (var bw = new BinaryWriter(ms))
                {
                    foreach (var layer in Map.ConfigLayers)
                    {
                        // Header
                        bw.Write(layer.Type);
                        bw.Write(layer.X);
                        bw.Write(layer.Y);
                        bw.Write(layer.BppX);
                        bw.Write(layer.BppY);

                        // Data
                        bw.Write(layer.Data);
                    }

                    return(ms.ToArray());
                }
            }
        }
Beispiel #13
0
 /// <summary>
 /// 更改场景
 /// </summary>
 /// <param name="sceneName">场景名</param>
 /// <param name="playerLocation">玩家的位置</param>
 /// <param name="LoadResultAction">加载结果回调</param>
 public void ChangedScene(string sceneName, Vector3 playerLocation, Action <bool> LoadResultAction = null)
 {
     GameRunType = EnumGameRunType.Start;//切换场景时当前的状态为开始状态
     //如果要切换的场景不是当前场景则加载场景
     if (SceneName != sceneName)
     {
         //保存原来地形的遮罩图
         if (!string.IsNullOrEmpty(SceneName))
         {
             playerState.SaveGetSceneMapMaskData(SceneName);
         }
         //开始加载
         UIChangeScene.Instance.LoadScene(sceneName, result =>
         {
             //自身调用初始化数据
             Debug.Log("需要调用自身的函数实现数据的初始化,如地图显示,npc位置等一系列的数据");
             //加载地图的图片以及遮罩资源
             IMapState iMapState     = GetEntity <IMapState>();
             MapData mapData         = DataCenter.Instance.GetMetaData <MapData>();
             MapDataInfo mapDataInfo = mapData[sceneName];
             if (mapDataInfo != null)
             {
                 mapDataInfo.Load();
                 iMapState.MapBackSprite  = mapDataInfo.MapSprite;
                 Sprite mapMaskSprite     = playerState.GetSceneMapMaskSprite(sceneName, mapDataInfo.MapSprite);
                 iMapState.MaskMapSprite  = mapMaskSprite;
                 iMapState.MapRectAtScene = mapDataInfo.SceneRect;
             }
             //初始化npc与npc的位置
             NPCData npcData            = DataCenter.Instance.GetMetaData <NPCData>();
             NPCDataInfo[] npcDataInfos = npcData.GetNPCDataInfos(sceneName);
             foreach (NPCDataInfo npcDataInfo in npcDataInfos)
             {
                 npcDataInfo.Load();//切换场景时有时候会导致游戏对象被删除,需要重新Load
             }
             //初始化采集点与采集点的位置
             StuffData stuffData            = DataCenter.Instance.GetMetaData <StuffData>();
             StuffDataInfo[] stuffDataInfos = stuffData.GetStuffDataInfos(sceneName);
             foreach (StuffDataInfo stuffDataInfo in stuffDataInfos)
             {
                 stuffDataInfo.Load();//切换场景时有时候会导致游戏对象被删除,需要重新Load
             }
             //初始化功能交互对象
             ActionInteractiveData actionInteractiveData            = DataCenter.Instance.GetMetaData <ActionInteractiveData>();
             ActionInteractiveDataInfo[] actionInteractiveDataInfos = actionInteractiveData.GetActionInteractiveDataInfos(sceneName);
             foreach (ActionInteractiveDataInfo actionInteractiveDataInfo in actionInteractiveDataInfos)
             {
                 actionInteractiveDataInfo.Load();//切换场景时有时候会导致游戏对象被删除,需要重新Load
             }
             //创建UI
             GameObject mainCanvasPrefab = Resources.Load <GameObject>("UI/MainCanvas");
             GameObject.Instantiate(mainCanvasPrefab);
             //创建玩家操纵的游戏对象
             GameObject playerPrefab = Resources.Load <GameObject>("Prefabs/Player");
             GameObject.Instantiate(playerPrefab);
             //更改过后修改玩家位置
             PlayerObj.transform.position = playerLocation;
             //回调
             if (LoadResultAction != null)
             {
                 LoadResultAction(result);
             }
             SceneName   = sceneName;
             GameRunType = EnumGameRunType.Safe;
             //场景变换回调
             Call <IGameState, Action <string, Vector3, Action <bool> > >(temp => temp.ChangedScene);
         });
     }
     else//如果不需要切换场景则直接更改玩家位置即可
     {
         UIChangeScene.Instance.MovePlayer(3, result =>
         {
             GameRunType = EnumGameRunType.Safe;
             //场景变换回调
             Call <IGameState, Action <string, Vector3, Action <bool> > >(temp => temp.ChangedScene);
         });
         //更改过后修改玩家位置
         PlayerObj.transform.position = playerLocation;
         //关闭当前按显示的UI
         IInteractiveState iInteractiveState = GameState.Instance.GetEntity <IInteractiveState>();
         iInteractiveState.ActionObj.SetActive(false);
     }
 }
Beispiel #14
0
        public static MapDataInfo Load(BinaryReader reader)
        {
            var mapData = new MapDataInfo();

            var signature = Encoding.ASCII.GetString(reader.ReadBytes(4));

            if (signature != "MDN_")
            {
                throw new InvalidDataException(Strings.InvalidMapFileError);
            }

            mapData.Version        = reader.ReadInt32();
            mapData.TileBpp        = reader.ReadInt32();
            mapData.Param3         = reader.ReadInt32();
            mapData.Param4         = reader.ReadInt32();
            mapData.MapSizeSum     = reader.ReadInt32();
            mapData.Param6         = reader.ReadInt32();
            mapData.Param7         = reader.ReadInt32();
            mapData.MapSizeX       = reader.ReadInt32();
            mapData.MapSizeY       = reader.ReadInt32();
            mapData.TileSizeX      = reader.ReadInt32();
            mapData.TileSizeY      = reader.ReadInt32();
            mapData.TileCountX     = reader.ReadInt32();
            mapData.TileCountY     = reader.ReadInt32();
            mapData.Param14        = reader.ReadInt32();
            mapData.LyrDataCount   = reader.ReadInt32();
            mapData.TileGroupCount = reader.ReadInt32();

            var layerCount = reader.ReadInt32();

            Console.WriteLine("layerCount = {0}", layerCount);

            var rangeCount = reader.ReadInt32();

            Console.WriteLine("rangeCount = {0}", rangeCount);

            var pointCount = reader.ReadInt32();

            Console.WriteLine("pointCount = {0}", pointCount);

            var effectCount = reader.ReadInt32();

            Console.WriteLine("effectCount = {0}", effectCount);

            mapData.Param21 = reader.ReadInt32();
            mapData.Param22 = reader.ReadInt32();
            mapData.Param23 = reader.ReadInt32();

            for (var i = 0; i < layerCount; i++)
            {
                var layer = new ConfigLayer()
                {
                    Type = reader.ReadInt32(),
                    X    = reader.ReadInt32(),
                    Y    = reader.ReadInt32(),
                    BppX = reader.ReadInt32(),
                    BppY = reader.ReadInt32()
                };

                layer.Data = reader.ReadBytes(layer.X * layer.Y);

                Console.WriteLine("X: {0} / Y: {1} / Total length: {2} ( {2:X} )", layer.X, layer.Y, layer.X * layer.Y);
                Console.WriteLine("Type: {0}", layer.Type);
                Console.WriteLine("Config layer {0} length: {1:X}", i + 1, layer.Data.Length);

                mapData.ConfigLayers.Add(layer);
            }

            Console.WriteLine("Reading rangeData");

            var rangeData = reader.ReadBytes(32 * rangeCount);

            for (var i = 0; i < rangeCount; i++)
            {
                var obj = rangeData.Skip(i * 32).Take(32).ToArray();

                using (var range = new BinaryReader(new MemoryStream(obj)))
                {
                    mapData.RangeObjects.Add(new RangeObject()
                    {
                        Type        = range.ReadInt32(),
                        Id          = range.ReadInt32(),
                        Destination = range.ReadInt32(),
                        X1          = range.ReadInt32(),
                        Y1          = range.ReadInt32(),
                        X2          = range.ReadInt32(),
                        Y2          = range.ReadInt32(),
                        Options     = range.ReadInt32()
                    });
                }
            }

            Console.WriteLine("Reading pointData");

            var pointData = reader.ReadBytes(24 * pointCount);

            for (var i = 0; i < pointCount; i++)
            {
                var pointBytes = pointData.Skip(i * 24).Take(24).ToArray();

                using (var pointReader = new BinaryReader(new MemoryStream(pointBytes)))
                {
                    mapData.PointObjects.Add(new PointObject()
                    {
                        Id      = pointReader.ReadInt32(),
                        Type    = pointReader.ReadInt32(),
                        MapId   = pointReader.ReadInt32(),
                        X       = pointReader.ReadInt32(),
                        Y       = pointReader.ReadInt32(),
                        Options = pointReader.ReadInt32()
                    });
                }
            }


            Console.WriteLine("Reading effectData");

            var effectData = reader.ReadBytes(52 * effectCount);

            for (int i = 0; i < effectCount; i++)
            {
                var effect = effectData.Skip(i * 52).Take(52).ToArray();
                mapData.EffectObjects.Add(effect);
                Console.WriteLine(ByteArrayToString(effect));
            }

            return(mapData);
        }
Beispiel #15
0
        public static MapDataInfo Load(BinaryReader reader)
        {
            var mapData = new MapDataInfo();

            var signature = Encoding.ASCII.GetString(reader.ReadBytes(4));

            if (signature != "MDN_")
            {
                throw new InvalidDataException("Invalid map file");
            }

            mapData.Version        = reader.ReadInt32();
            mapData.TileBpp        = reader.ReadInt32();
            mapData.Param3         = reader.ReadInt32();
            mapData.Param4         = reader.ReadInt32();
            mapData.MapSizeSum     = reader.ReadInt32();
            mapData.Param6         = reader.ReadInt32();
            mapData.Param7         = reader.ReadInt32();
            mapData.MapSizeX       = reader.ReadInt32();
            mapData.MapSizeY       = reader.ReadInt32();
            mapData.TileSizeX      = reader.ReadInt32();
            mapData.TileSizeY      = reader.ReadInt32();
            mapData.TileCountX     = reader.ReadInt32();
            mapData.TileCountY     = reader.ReadInt32();
            mapData.Param14        = reader.ReadInt32();
            mapData.LyrDataCount   = reader.ReadInt32();
            mapData.TileGroupCount = reader.ReadInt32();

            var layerCount = reader.ReadInt32();

            var rangeCount = reader.ReadInt32();

            var pointCount = reader.ReadInt32();

            var effectCount = reader.ReadInt32();

            mapData.Param21 = reader.ReadInt32();
            mapData.Param22 = reader.ReadInt32();
            mapData.Param23 = reader.ReadInt32();

            for (var i = 0; i < layerCount; i++)
            {
                var layer = new ConfigLayer()
                {
                    Type = reader.ReadInt32(),
                    X    = reader.ReadInt32(),
                    Y    = reader.ReadInt32(),
                    BppX = reader.ReadInt32(),
                    BppY = reader.ReadInt32()
                };

                layer.Data = reader.ReadBytes(layer.X * layer.Y);

                mapData.ConfigLayers.Add(layer);
            }

            var rangeData = reader.ReadBytes(32 * rangeCount);

            for (var i = 0; i < rangeCount; i++)
            {
                var obj = rangeData.Skip(i * 32).Take(32).ToArray();

                using (var range = new BinaryReader(new MemoryStream(obj)))
                {
                    mapData.RangeObjects.Add(new RangeObject()
                    {
                        Type        = range.ReadInt32(),
                        Id          = range.ReadInt32(),
                        Destination = range.ReadInt32(),
                        X1          = range.ReadInt32(),
                        Y1          = range.ReadInt32(),
                        X2          = range.ReadInt32(),
                        Y2          = range.ReadInt32(),
                        Options     = range.ReadInt32()
                    });
                }
            }

            var pointData = reader.ReadBytes(24 * pointCount);

            for (var i = 0; i < pointCount; i++)
            {
                var pointBytes = pointData.Skip(i * 24).Take(24).ToArray();

                using (var pointReader = new BinaryReader(new MemoryStream(pointBytes)))
                {
                    mapData.PointObjects.Add(new PointObject()
                    {
                        Id      = pointReader.ReadInt32(),
                        Type    = pointReader.ReadInt32(),
                        MapId   = pointReader.ReadInt32(),
                        X       = pointReader.ReadInt32(),
                        Y       = pointReader.ReadInt32(),
                        Options = pointReader.ReadInt32()
                    });
                }
            }

            /*
             * var effectData = reader.ReadBytes(52 * effectCount);
             *
             * for (int i = 0; i < effectCount; i++)
             * {
             *  var effect = effectData.Skip(i * 52).Take(52).ToArray();
             *  mapData.EffectObjects.Add(effect);
             * }
             */

            reader.Dispose();

            return(mapData);
        }