示例#1
0
        //public static World NewWorld(string worldname) { return NewWorld(worldname, "Core.World"); }
        public static World NewWorld(string worldname, string fulltype)
        {
            if (worldname == "")
            {
                return(null);
            }
            World world = FindWorld(worldname);

            if (world != null)
            {
                return(world);
            }

            if (fulltype == "")
            {
                fulltype = "Core.World";
            }
            world = Info.Instance(fulltype) as World;

            if (world != null)
            {
                world.Name = worldname;
                Add(world);
                SaveFiles(world);
                //string p = Info.address_Editor + "Worlds" + Info.separator + world.Name + Info.separator;
                //Info.SaveWorld(world, p);
            }
            return(world);
        }
示例#2
0
        public virtual void Load(SerializationReader SR)
        {
            SR.ReadStartElement();
            int version = SR.ReadVersion();

            switch (version)
            {
            case 0:
            {
                string ai = SR.ReadString();
                if (ai != "")
                {
                    AI = Info.Instance(ai) as AI;
                }
                if (AI != null)
                {
                    AI.Entity = this;
                }

                ID         = SR.ReadString();
                X          = SR.ReadInt();
                Y          = SR.ReadInt();
                Z          = SR.ReadInt();
                Name       = SR.ReadString();
                Width      = SR.ReadFloat();
                Height     = SR.ReadFloat();
                CanMove    = SR.ReadBool();
                CanTarget  = SR.ReadBool();
                Cross      = SR.ReadBool();
                Direction  = SR.ReadInt();
                Flag.Value = SR.ReadInt();
                Containers = SR.ReadContainers();
                //Move = SR.ReadMove();//Supprimer!!!!!
                Body = SR.ReadBodyJSON();
                break;
            }
            }

            SR.ReadEndElement();
        }
示例#3
0
        //public void Editor_New_Cube(string[] str)
        //{
        //    int x = StringToInt(str[1]);
        //    int y = StringToInt(str[2]);
        //    int z = StringToInt(str[3]);
        //    string fulltype = str[4];

        //    Editor.NewCube(fulltype, x, y, z);

        //    Cube c = Editor.Map.FindCube(x, y, z);
        //    if (c != null)
        //        Add(new MsgJSON_Cubes("EDITOR_NEW_CUBES", new Cube[] { c }));
        //}
        //public void Editor_Modify_Cube(string[] str)
        //{
        //    int x = StringToInt(str[1]);
        //    int y = StringToInt(str[2]);
        //    int z = StringToInt(str[3]);
        //    string key = str[4];

        //    if (str[4] == "CLIMB")
        //        Editor.Climb(x, y, z, StringToBool(str[5]));
        //    else if (str[4] == "CROSS")
        //        Editor.Cross(x, y, z, StringToBool(str[5]));
        //    else if (str[4] == "SEE")
        //        Editor.See(x, y, z, StringToBool(str[5]));
        //    else if (str[4] == "ATTACK")
        //        Editor.Attack(x, y, z, StringToBool(str[5]));
        //    else if (str[4] == "FLOORS")
        //        Editor.Floors(x, y, z, Info.JSONDeserialize<ImageJSON[]>(str[5]));
        //    else if (str[4] == "FLOORSPEED")
        //        Editor.FloorSpeed(x, y, z, StringToInt(str[5]));
        //    else if (str[4] == "VOLUMES")
        //        Editor.Volumes(x, y, z, Info.JSONDeserialize<ImageJSON[]>(str[5]));
        //    else if (str[4] == "VOLUMESPEED")
        //        Editor.VolumeSpeed(x, y, z, StringToInt(str[5]));
        //}
        public void Editor_Modify_Cube2(string[] str)
        {
            int    x        = StringToInt(str[1]);
            int    y        = StringToInt(str[2]);
            int    z        = StringToInt(str[3]);
            int    x2       = StringToInt(str[4]);
            int    y2       = StringToInt(str[5]);
            int    z2       = StringToInt(str[6]);
            string fulltype = str[7];
            bool   climb    = StringToBool(str[8]);
            bool   cross    = StringToBool(str[9]);
            bool   see      = StringToBool(str[10]);
            bool   attack   = StringToBool(str[11]);

            int floorspeed = StringToInt(str[12]);

            ImageJSON[] floors = new ImageJSON[0];
            if (str[13] != "" && str[13] != "[]")
            {
                floors = Info.JSONDeserialize <ImageJSON[]>(str[13]);
            }
            int volumespeed = StringToInt(str[14]);

            ImageJSON[] volumes = new ImageJSON[0];
            if (str[15] != "" && str[15] != "[]")
            {
                volumes = Info.JSONDeserialize <ImageJSON[]>(str[15]);
            }

            if (PageInfo.Map == null || !PageInfo.Map.Contains(x, y, z))
            {
                return;
            }

            Cube cube = PageInfo.Map.FindCube(x, y, z);

            if (cube == null)
            {
                if (fulltype == "")
                {
                    fulltype = "Core.Cube";
                }
                cube = Info.Instance(fulltype) as Cube;
                if (cube == null)
                {
                    return;
                }
                cube.X = x;
                cube.Y = y;
                cube.Z = z;
                PageInfo.Map.Add(cube);
            }

            if (cube != null)
            {
                cube.Climb         = climb;
                cube.Cross         = cross;
                cube.See           = see;
                cube.Attack        = attack;
                cube.Floors_Speed  = floorspeed;
                cube.Floors        = floors;
                cube.Volumes_Speed = volumespeed;
                cube.Volumes       = volumes;

                Add(new MsgJSON_Cubes("CUBES", new Cube[] { cube }));
                //Add(new MsgJSON_Cubes("EDITOR_CUBES", new Cube[] { cube }));
            }
        }
示例#4
0
        public void Editor_New_Entity(string[] str, bool permanents)
        {
            //bool permanent = StringToBool(str[1]);
            int    x        = StringToInt(str[2]);
            int    y        = StringToInt(str[3]);
            int    z        = StringToInt(str[4]);
            int    adjx     = StringToInt(str[5]);
            int    adjy     = StringToInt(str[6]);
            string fulltype = str[7];
            string ai       = str[8];
            string id       = str[9];
            string name     = str[10];
            float  width    = StringToFloat(str[11]);
            float  height   = StringToFloat(str[12]);

            //int bodyspeed = StringToInt(str[12]);
            bool canmove   = StringToBool(str[13]);
            bool cantarget = StringToBool(str[14]);
            bool cross     = StringToBool(str[15]);
            //bool animated = StringToBool(str[16]);
            //bool turned = StringToBool(str[17]);
            int direction = StringToInt(str[16]);
            //ImageJSON[] bodys = Info.JSONDeserialize<ImageJSON[]>(str[19]);
            //BodyJSON body2 = Info.JSONDeserialize<BodyJSON>(str[20]);
            BodyJSON body_Stand = Info.JSONDeserialize <BodyJSON>(str[17]);
            BodyJSON body_Move  = Info.JSONDeserialize <BodyJSON>(str[18]);
            BodyJSON body_Jump  = Info.JSONDeserialize <BodyJSON>(str[19]);


            if (PageInfo.Map == null || !PageInfo.Map.Contains(x, y, z))
            {
                return;
            }
            if (id == "")
            {
                return;
            }

            Entity entity = PageInfo.Map.FindEntity(id);

            if (entity == null)
            {
                if (fulltype == "")
                {
                    fulltype = "Core.Entity";
                }
                entity = Info.Instance(fulltype) as Entity;
                if (entity == null)
                {
                    return;
                }
                if (permanents)
                {
                    PageInfo.Map.Permanents.Add(entity);
                }
                else
                {
                    PageInfo.Map.Entitys.Add(entity);
                }
            }
            if (entity != null)
            {
                if (ai != "")
                {
                    entity.AI = Info.Instance(ai) as AI;
                    if (entity.AI != null)
                    {
                        entity.AI.Entity = entity;
                    }
                }
                entity.Adjustment.X = adjx;
                entity.Adjustment.Y = adjy;
                entity.ID           = id;
                entity.Name         = name;
                entity.Width        = width;
                entity.Height       = height;
                //entity.Body.Speed = bodyspeed;
                entity.CanMove   = canmove;
                entity.CanTarget = cantarget;
                entity.Cross     = cross;
                //entity.Body.Animated = animated;
                //entity.Body.Turned = turned;
                entity.Direction = direction;
                //entity.Body = bodys;

                entity.Body = body_Stand;
                entity.X    = x;
                entity.Y    = y;
                entity.Z    = z;
                entity.Map  = PageInfo.Map;
                //if (GameInfo.Map.Entitys.Contains(id))
                //    GameInfo.Map.Entitys.Remove(entity);
                //if (GameInfo.Map.Permanents.Contains(id))
                //    GameInfo.Map.Permanents.Remove(entity);
                Mobile mobile = entity as Mobile;
                if (mobile != null)
                {
                    mobile.Body_Stand = body_Stand;
                    mobile.Body_Move  = body_Move;
                    mobile.Body_Jump  = body_Jump;
                }
            }



            //GameInfo.Map.EntityJSON = GameInfo.Map.Entitys.JSON();

            //SendEntitys();
            //if (permanent)
            PageInfo.Map.CreateMessagePermanents();
            SendMap();
        }
示例#5
0
 public object ReadType()
 {
     return(Info.Instance(reader.ReadElementString()));
 }