public static void AddAllColors(string colorXMLPath)
    {
        string text;

        using (StreamReader sr = new StreamReader(colorXMLPath))
        {
            text = sr.ReadToEnd();
        }

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(text);
        XmlElement allColors = doc.DocumentElement;

        for (int i = 0; i < allColors.ChildNodes.Count; i++)
        {
            XmlNode      colorNode = allColors.ChildNodes.Item(i);
            MapBlockType colorType = (MapBlockType)Enum.Parse(typeof(MapBlockType), colorNode.Attributes["name"].Value);
            string       color_str = colorNode.Attributes["color"].Value;
            if (!ColorDict.ContainsKey(colorType))
            {
                ColorDict.Add(colorType, color_str);
            }
            if (!ColorDict_Rev.ContainsKey(color_str))
            {
                ColorDict_Rev.Add(color_str, colorType);
            }
        }
    }
示例#2
0
    private GameObject GetRamdomPrefab(string _path, MapBlockType blockType)
    {
        GameObject prefeb = null;

        switch (blockType)
        {
        case MapBlockType.battleType:
            if (battlePrefabBlocks == null)
            {
                battlePrefabBlocks = new List <GameObject>(Resources.LoadAll <GameObject>(_path));
            }
            prefeb = battlePrefabBlocks[Random.Range(0, battlePrefabBlocks.Count)];
            break;

        case MapBlockType.eventType:
            if (eventPrefabBlocks == null)
            {
                eventPrefabBlocks = new List <GameObject>(Resources.LoadAll <GameObject>(_path));
            }
            prefeb = eventPrefabBlocks[Random.Range(0, eventPrefabBlocks.Count)];
            break;

        case MapBlockType.endType:
            if (endPrefabBlocks == null)
            {
                endPrefabBlocks = new List <GameObject>(Resources.LoadAll <GameObject>(_path));
            }
            prefeb = endPrefabBlocks[Random.Range(0, endPrefabBlocks.Count)];
            break;

        case MapBlockType.shopType:
            if (shopPrefabBlocks == null)
            {
                shopPrefabBlocks = new List <GameObject>(Resources.LoadAll <GameObject>(_path));
            }
            prefeb = shopPrefabBlocks[Random.Range(0, shopPrefabBlocks.Count)];
            break;

        case MapBlockType.startType:
            if (startPrefabBlocks == null)
            {
                startPrefabBlocks = new List <GameObject>(Resources.LoadAll <GameObject>(_path));
            }
            prefeb = startPrefabBlocks[Random.Range(0, startPrefabBlocks.Count)];
            break;

        case MapBlockType.BossType:
            if (bossPrefabBlocks == null)
            {
                bossPrefabBlocks = new List <GameObject>(Resources.LoadAll <GameObject>(_path));
            }
            prefeb = bossPrefabBlocks[Random.Range(0, bossPrefabBlocks.Count)];
            break;
        }
        return(prefeb);
    }
示例#3
0
    public MapBlockInfo SpwanMapBlockInfo(int x, int y, MapBlockType type)
    {
        GameObject   gb      = (GameObject)Instantiate(Resources.Load("Block/MapBlock"), transform.position, Quaternion.identity);
        MapBlockInfo mapInfo = gb.GetComponent <MapBlockInfo>();

        mapInfo.indexInfo.x        = x;
        mapInfo.indexInfo.y        = y;
        mapInfo.blockType          = type;
        mapInfo.transform.position = new Vector2(mapInfo.indexInfo.x, mapInfo.indexInfo.y);
        mapInfo.transform.parent   = mapLocation.transform;
        return(mapInfo);
    }
示例#4
0
        /// <summary>
        /// Loads the file from the specified stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public override void Load(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("EUC-KR"));

            int blockCount = reader.ReadInt32();

            for (int i = 0; i < blockCount; i++)
            {
                MapBlockType type = (MapBlockType)reader.ReadInt32();

                if (!Enum.IsDefined(typeof(MapBlockType), type))
                {
                    throw new InvalidMapBlockTypeException((int)type);
                }

                int  offset    = reader.ReadInt32();
                long nextBlock = stream.Position;

                stream.Seek(offset, SeekOrigin.Begin);

                if (type == MapBlockType.MapInformation)
                {
                    MapPosition  = new IntVector2(reader.ReadInt32(), reader.ReadInt32());
                    ZonePosition = new IntVector2(reader.ReadInt32(), reader.ReadInt32());
                    World        = reader.ReadMatrix();
                    Name         = reader.ReadString();
                }
                else if (type == MapBlockType.WaterPatch)
                {
                    WaterPatches = new MapWaterPatches();
                    WaterPatches.Read(reader);
                }
                else
                {
                    if (type == MapBlockType.WaterPlane)
                    {
                        WaterSize = reader.ReadSingle();
                    }

                    int  entryCount = reader.ReadInt32();
                    Type classType  = type.GetAttributeValue <MapBlockTypeAttribute, Type>(x => x.Type);

                    for (int j = 0; j < entryCount; j++)
                    {
                        IMapBlock block = (IMapBlock)Activator.CreateInstance(classType);
                        block.Read(reader);

                        switch (type)
                        {
                        case MapBlockType.Object:
                            Objects.Add((MapObject)block);
                            break;

                        case MapBlockType.NPC:
                            NPCs.Add((MapNPC)block);
                            break;

                        case MapBlockType.Building:
                            Buildings.Add((MapBuilding)block);
                            break;

                        case MapBlockType.Sound:
                            Sounds.Add((MapSound)block);
                            break;

                        case MapBlockType.Effect:
                            Effects.Add((MapEffect)block);
                            break;

                        case MapBlockType.Animation:
                            Animations.Add((MapAnimation)block);
                            break;

                        case MapBlockType.MonsterSpawn:
                            MonsterSpawns.Add((MapMonsterSpawn)block);
                            break;

                        case MapBlockType.WaterPlane:
                            WaterPlanes.Add((MapWaterPlane)block);
                            break;

                        case MapBlockType.WarpPoint:
                            WarpPoints.Add((MapWarpPoint)block);
                            break;

                        case MapBlockType.CollisionObject:
                            CollisionObjects.Add((MapCollisionObject)block);
                            break;

                        case MapBlockType.EventObject:
                            EventObjects.Add((MapEventObject)block);
                            break;
                        }
                    }
                }


                if (i < blockCount - 1)
                {
                    stream.Seek(nextBlock, SeekOrigin.Begin);
                }
            }
        }
示例#5
0
 public MapBlock(MapBlockType type, MapBlockCoordinates coords)
 {
     Coordinates = coords;
     Type        = type;
 }
示例#6
0
    void ModifyVOByOp(MapTileVO tile)
    {
        switch (curOp)
        {
        case EDIT_OP.EDIT_TEX:
            if (tile.mat == mTexIndex)
            {
                return;
            }
            tile.mat       = mTexIndex;
            tile.type      = MapTileType.Normal;
            tile.blockType = MapBlockType.None;
            break;

        case EDIT_OP.EDIT_HEIGHT:
            byte newHeight = 0;
            if (mHeightOp && tile.height > 0)
            {
                newHeight = (byte)(tile.height - 1);
            }
            else if (!mHeightOp && tile.height < 15)
            {
                newHeight = (byte)(tile.height + 1);
            }
            else
            {
                return;
            }
            if (!TestNewHeight(newHeight))
            {
                return;
            }
            newHeight = (byte)Mathf.Clamp(newHeight, 0, 15);
            if (newHeight == tile.height)
            {
                return;
            }
            tile.height = newHeight;
            break;

        case EDIT_OP.EDIT_AREA:
            if (tile.camp == mCampIndex)
            {
                return;
            }
            tile.camp = mCampIndex;
            break;

        case EDIT_OP.EDIT_LV:
            if (tile.level == mLvIndex)
            {
                return;
            }
            tile.level = mLvIndex;
            break;

        case EDIT_OP.EDIT_TILETYPE:
            MapTileType newType = (MapTileType)mTypeIndex;
            if (tile.type == newType)
            {
                return;
            }
            tile.type = newType;
            if (tile.type != MapTileType.Block)
            {
                tile.blockType = MapBlockType.None;
            }
            break;

        case EDIT_OP.EDIT_BLOCKTYPE:
            MapBlockType newBType = (MapBlockType)mBlockTypeIndex;
            if (tile.blockType == newBType)
            {
                return;
            }
            tile.mat       = 8;
            tile.blockType = newBType;
            tile.type      = MapTileType.Block;
            break;

        case EDIT_OP.EDIT_SPRLIST:
            List <int> sprs = new List <int>(4);
            for (int i = 0; i < 4; i++)
            {
                sprs.Add(sprLists[i].value);
            }
            Coord submap = tile.coord.GetSubmapCoord();
            if (!mBulkSubmaps.Contains(submap))
            {
                mapProxy.SeedSprList(submap, sprs);
                mBulkSubmaps.Add(submap);
            }
            break;
        }
    }