Example #1
0
        //public void SaveEntities(IEnumerable<Entity> entities)
        //{
        //    List<Tuple<Position, obj>> list = new List<Tuple<Position, obj>>();
        //    foreach (var i in entities)
        //    {
        //        var o = new obj() { id = Objects.type2id[(short)i.ObjectType] };
        //        string s = "";
        //        if (!string.IsNullOrEmpty(i.Name))
        //            s += ";name:" + i.Name;
        //        if (i.Size != 100)
        //            s += ";size:" + i.Size;
        //        if (i.ConditionEffects != 0)
        //            s += ";eff:0x" + ((int)i.ConditionEffects).ToString("X8");
        //        if (i is ConnectedObject)
        //            s += ";conn:0x" + (i as ConnectedObject).Connection.ToString("X8");
        //        //if (en.Stats.ContainsKey(StatsType.MerchantMerchandiseType))
        //        //    s += ";mtype:" + en.Stats[StatsType.MerchantMerchandiseType];
        //        //if (en.Stats.ContainsKey(StatsType.MerchantRemainingCount))
        //        //    s += ";mcount:" + en.Stats[StatsType.MerchantRemainingCount];
        //        //if (en.Stats.ContainsKey(StatsType.MerchantRemainingMinute))
        //        //    s += ";mtime:" + en.Stats[StatsType.MerchantRemainingMinute];
        //        //if (en.Stats.ContainsKey(StatsType.NameChangerStar))
        //        //    s += ";nstar:" + en.Stats[StatsType.NameChangerStar];
        //        o.name = s.Trim(';');
        //        list.Add(new Tuple<Position, obj>(new Position() { X = (int)(i.X - 0.5), Y = (int)(i.Y - 0.5) }, o));
        //    }
        //    descs = list.ToArray();
        //}

        MapTileDesc loc2Tile(loc loc, List <obj> objs)
        {
            MapTileDesc ret = new MapTileDesc();

            if (loc.ground != null)
            {
                ret.Tile = (Tile)Grounds.id2type[loc.ground];
            }
            else
            {
                ret.Tile = (Tile)0xff;
            }

            if (loc.objs != null)
            {
                foreach (var z in loc.objs)
                {
                    ObjectDesc desc;
                    if (Objects.objectDescs.TryGetValue(Objects.id2type[z.id], out desc))
                    {
                        if (desc.Static && !desc.Enemy)
                        {
                            ret.ObjType = desc.ObjectType;
                            ret.Name    = z.name;
                        }
                        else
                        {
                            objs.Add(z);
                        }
                    }
                    else
                    {
                        objs.Add(z);
                    }
                }
            }

            if (loc.regions != null)
            {
                ret.Region = (TileRegion)Enum.Parse(typeof(TileRegion), loc.regions[0].id.Replace(' ', '_'));
            }
            return(ret);
        }
Example #2
0
        //public void SaveEntities(IEnumerable<Entity> entities)
        //{
        //    List<Tuple<Position, obj>> list = new List<Tuple<Position, obj>>();
        //    foreach (var i in entities)
        //    {
        //        var o = new obj() { id = Objects.type2id[(short)i.ObjectType] };
        //        string s = "";
        //        if (!string.IsNullOrEmpty(i.Name))
        //            s += ";name:" + i.Name;
        //        if (i.Size != 100)
        //            s += ";size:" + i.Size;
        //        if (i.ConditionEffects != 0)
        //            s += ";eff:0x" + ((int)i.ConditionEffects).ToString("X8");
        //        if (i is ConnectedObject)
        //            s += ";conn:0x" + (i as ConnectedObject).Connection.ToString("X8");
        //        //if (en.Stats.ContainsKey(StatsType.MerchantMerchandiseType))
        //        //    s += ";mtype:" + en.Stats[StatsType.MerchantMerchandiseType];
        //        //if (en.Stats.ContainsKey(StatsType.MerchantRemainingCount))
        //        //    s += ";mcount:" + en.Stats[StatsType.MerchantRemainingCount];
        //        //if (en.Stats.ContainsKey(StatsType.MerchantRemainingMinute))
        //        //    s += ";mtime:" + en.Stats[StatsType.MerchantRemainingMinute];
        //        //if (en.Stats.ContainsKey(StatsType.NameChangerStar))
        //        //    s += ";nstar:" + en.Stats[StatsType.NameChangerStar];
        //        o.name = s.Trim(';');
        //        list.Add(new Tuple<Position, obj>(new Position() { X = (int)(i.X - 0.5), Y = (int)(i.Y - 0.5) }, o));
        //    }
        //    descs = list.ToArray();
        //}
        MapTileDesc loc2Tile(loc loc, List<obj> objs)
        {
            MapTileDesc ret = new MapTileDesc();

            if (loc.ground != null)
                ret.Tile = (Tile)Grounds.id2type[loc.ground];
            else
                ret.Tile = (Tile)0xff;

            if (loc.objs != null)
            {
                foreach (var z in loc.objs)
                {
                    ObjectDesc desc;
                    if (Objects.objectDescs.TryGetValue(Objects.id2type[z.id], out desc))
                    {
                        if (desc.Static && !desc.Enemy)
                        {
                            ret.ObjType = desc.ObjectType;
                            ret.Name = z.name;
                        }
                        else
                            objs.Add(z);
                    }
                    else
                        objs.Add(z);
                }
            }

            if (loc.regions != null)
                ret.Region = (TileRegion)Enum.Parse(typeof(TileRegion), loc.regions[0].id.Replace(' ', '_'));
            return ret;
        }