Ejemplo n.º 1
0
        private static void ResetInstance(Instance old, Instance current)
        {
            ObjectSave save = new ObjectSave(old, current, old.GetType());

            save.Reset();
            current.Reload();
        }
Ejemplo n.º 2
0
        public static void SaveConfig()
        {
            Object[] ObjectType =
            {
                CVisualGlowObjectManager,
                CVisualChamsColor,
                CVisualMisc,

                CAim,
                CAimWeapon,
                CAimMisc,

                CMisc
            };

            if (!Directory.Exists("Config"))
            {
                Directory.CreateDirectory("Config");
            }

            foreach (object ObjectSave in ObjectType)
            {
                using (FileStream FileStream = new FileStream(ConfigPath(ObjectSave), FileMode.Create, FileAccess.Write))
                {
                    new XmlSerializer(ObjectSave.GetType()).Serialize(FileStream, ObjectSave);
                }
            }
        }
Ejemplo n.º 3
0
        public override Instance clone()
        {
            Script     script = new Script();
            ObjectSave save   = new ObjectSave(this, script, GetType());

            save.Reset();
            return(script);
        }
Ejemplo n.º 4
0
Archivo: Part.cs Proyecto: ext0/Flex
        public override Instance clone()
        {
            Part       part = new Part();
            ObjectSave save = new ObjectSave(this, part, GetType());

            save.Reset();
            return(part);
        }
Ejemplo n.º 5
0
        private static void Reset()
        {
            ActiveWorld world = FlexUtility.DeserializeToObject(_savedState) as ActiveWorld;

            List <InstancePair> correspondings;
            List <Instance>     removedInstances;
            List <Instance>     newInstances;

            List <Instance> newChildren = new List <Instance>();
            List <Instance> oldChildren = new List <Instance>();

            LoadResetInstanceHelper(_context.ActiveWorld.World, world.World, newChildren, oldChildren);

            newInstances     = newChildren.Where(x => !oldChildren.Any(y => x.Equals(y))).ToList();
            removedInstances = oldChildren.Where(x => !newChildren.Any(y => x.Equals(y))).ToList();
            correspondings   = oldChildren.Join(newChildren, x => x, y => y, (x, y) =>
            {
                return(new InstancePair(x, y));
            }).ToList();

            foreach (Instance newInstance in newInstances)
            {
                newInstance.Cleanup();
            }

            foreach (Instance removedInstance in removedInstances)
            {
                /*
                 * Implement
                 */
            }

            foreach (InstancePair instancePair in correspondings)
            {
                ObjectSave save = new ObjectSave(instancePair.Old, instancePair.Current, instancePair.Current.GetType());
                save.Reset();
                try
                {
                    InstancePair oldParent = correspondings.Where(x => x.Old.equals(instancePair.Old.parent)).FirstOrDefault();
                    if (oldParent != null && oldParent.Current != null)
                    {
                        instancePair.Current.parent = oldParent.Current;
                    }
                }
                catch { }
                instancePair.Current.Reload();
            }

            ResetInstance(world.Sky, _context.ActiveWorld.Sky);
        }
Ejemplo n.º 6
0
        public static T LoadConfig <T>()
        {
TryLoad:
            try
            {
                using (FileStream FileStream = new FileStream(ConfigPath <T>(), FileMode.Open, FileAccess.Read))
                {
                    return((T) new XmlSerializer(typeof(T)).Deserialize(FileStream));
                }
            }
            catch
            {
                Object[] ObjectType =
                {
                    CVisualGlowObjectManager,
                    CVisualChamsColor,
                    CVisualESP,
                    CVisualMisc,

                    CAim,
                    CAimWeapon,
                    CAimMisc,

                    CTrigger,

                    CMisc
                };

                if (!Directory.Exists("Config"))
                {
                    Directory.CreateDirectory("Config");
                }

                using (FileStream FileStream = new FileStream(ConfigPath <T>(), FileMode.Create, FileAccess.Write))
                {
                    foreach (var ObjectSave in ObjectType)
                    {
                        if (typeof(T).Name == ObjectSave.GetType().Name)
                        {
                            new XmlSerializer(typeof(T)).Serialize(FileStream, ObjectSave);
                        }
                    }
                }

                goto TryLoad;
            }
        }
Ejemplo n.º 7
0
        public static void SaveConfig()
        {
            object[] ObjectType =
            {
                CVisual,
                CSkinChanger,
                CSkinChangerWeapons
            };

            if (!Directory.Exists("Config"))
            {
                Directory.CreateDirectory("Config");
            }

            foreach (var ObjectSave in ObjectType)
            {
                using (FileStream FileStream = new FileStream(ConfigPath(ObjectSave), FileMode.Create, FileAccess.Write))
                {
                    new XmlSerializer(ObjectSave.GetType()).Serialize(FileStream, ObjectSave);
                }
            }
        }
Ejemplo n.º 8
0
        public static T LoadConfig <T>()
        {
TryLoad:
            try
            {
                using (FileStream FileStream = new FileStream(ConfigPath <T>(), FileMode.Open, FileAccess.Read))
                {
                    return((T) new XmlSerializer(typeof(T)).Deserialize(FileStream));
                }
            }
            catch
            {
                object[] ObjectType =
                {
                    CVisual,
                    CSkinChanger,
                    CSkinChangerWeapons
                };

                if (!Directory.Exists("Config"))
                {
                    Directory.CreateDirectory("Config");
                }

                using (FileStream FileStream = new FileStream(ConfigPath <T>(), FileMode.Create, FileAccess.Write))
                {
                    foreach (var ObjectSave in ObjectType)
                    {
                        if (typeof(T).Name == ObjectSave.GetType().Name)
                        {
                            new XmlSerializer(typeof(T)).Serialize(FileStream, ObjectSave);
                        }
                    }
                }

                goto TryLoad;
            }
        }
Ejemplo n.º 9
0
    public void Save()
    {
        var status =
            new Status
        {
            position = player.position,
            HP       = player.HP,
            Defense  = player.Defense,
            Attack   = player.Attack
        };

        var objectSave =
            new ObjectSave
        {
            SceneName          = game_manager_script.SceneName,
            SceneNameBefore    = game_manager_script.SceneNameBefore,
            SceneHistroy       = game_manager_script.SceneHistroy,
            WannnaDestroyEnemy = game_manager_script.wanna_destroy_enemy,
            WannaDestroyItem   = itemDatabase.wanna_destroy_item_id
        };

        foreach (ItemList item in itemDatabase.items)
        {
            AttackSave.Add(item.itemPower);
            HPIncreaseSave.Add(item.itemHPInCrease);
            DefenseSave.Add(item.itemDefense);
            NameSave.Add(item.ItemName);
            DescriptionSave.Add(item.itemDesc);
            spriteSave.Add(item.itemIcon);
            LifeStealSave.Add(item.itemLifeSteal);
            IDSave.Add(item.itemID);
            speedSave.Add(item.itemAttackSpeed);
            eTypeSave.Add(item.elementtype);
            iTypeSave.Add(item.itemType);
        }
        for (int i = 0; i < gear_set_script.Head.Count; i++)
        {
            GearIDSave.Add(gear_set_script.GearID[i]);
            GearNameSave.Add(gear_set_script.GearName[i]);
            GearDefenseSave.Add(gear_set_script.GearDefense[i]);
            GearHeadSave.Add(gear_set_script.Head[i]);
            GearBodySave.Add(gear_set_script.Body[i]);
            GearLegSave.Add(gear_set_script.Leg[i]);
            GearArmsLeftSave.Add(gear_set_script.ArmsLeft[i]);
            GearArmsRightSave.Add(gear_set_script.ArmsRight[i]);
        }

        var GearStatusSave =
            new GearStatusSave
        {
            GearID       = GearIDSave,
            GearName     = GearNameSave,
            GearDefense  = GearDefenseSave,
            GearHead     = GearHeadSave,
            GearLeg      = GearLegSave,
            GearBody     = GearBodySave,
            GearArmLeft  = GearArmsLeftSave,
            GearArmRight = GearArmsRightSave
        };


        var itemsSave = new ItemSave
        {
            Attack      = AttackSave,
            HPIncrease  = HPIncreaseSave,
            Defense     = DefenseSave,
            Name        = NameSave,
            Description = DescriptionSave,
            sprite      = spriteSave,
            ID          = IDSave,
            eType       = eTypeSave,
            iType       = iTypeSave,
            ItemCount   = itemDatabase.items.Count,
            LifeSteal   = LifeStealSave,
            speed       = speedSave
        };

        var GearSave = new GearSave
        {
            //武器シリーズ
            weaponID          = gear_manager_script.weaponID,
            weaponName        = gear_manager_script.weaponName,
            weaponPower       = gear_manager_script.weaponPower,
            WeaponAttackSpeed = gear_manager_script.WeaponAttackSpeed,

            //ここはギアシリーズ
            GearDefense = gear_manager_script.GearDefense,
            GearID      = gear_manager_script.GearID,
            GearName    = gear_manager_script.GearName,

            //ここは装備画像を入れるところ
            GearArmLeft  = gear_manager_script.GearArmLeft,
            GearArmRight = gear_manager_script.GearArmRight,

            GearBody = gear_manager_script.GearBody,
            GearLeg  = gear_manager_script.GearLeg,
            GearHead = gear_manager_script.GearHead
        };

        PlayerPrefsObject.SetObject("Status", status);
        PlayerPrefsObject.SetObject("objectSave", objectSave);
        PlayerPrefsObject.SetObject("ItemSave", itemsSave);
        PlayerPrefsObject.SetObject("GearSave", GearSave);
        PlayerPrefsObject.SetObject("GearStatusSave", GearStatusSave);
    }
Ejemplo n.º 10
0
    public void LoadMap(string mapfile, MapSave map)
    {
        StreamReader reader = new StreamReader(mapfile);
        string       line   = reader.ReadLine();

        while (!reader.EndOfStream)
        {
            if (line.Contains("<map"))
            {
                map.sizex       = Convert.ToInt32(map.GetValueFromKey("width", line));
                map.sizey       = Convert.ToInt32(map.GetValueFromKey("height", line));
                map.tilesizex   = Convert.ToInt32(map.GetValueFromKey("tilewidth", line));
                map.tilesizey   = Convert.ToInt32(map.GetValueFromKey("tileheight", line));
                map.basevalue   = Convert.ToInt32(map.GetValueFromKey("infinite", line));
                map.render      = map.GetValueFromKey("renderorder", line);
                map.orientation = map.GetValueFromKey("orientation", line);
                map.nextobject  = Convert.ToInt32(map.GetValueFromKey("nextobjectid", line));
                LayerSave maptiles = new LayerSave();
                map.layer = maptiles; // here
            }
            if (line.Contains("<layer"))
            {
                LayerSave ground = map.layer;
                ground.name  = map.GetValueFromKey("name", line);
                ground.sizex = Convert.ToInt32(map.GetValueFromKey("width", line));
                ground.sizey = Convert.ToInt32(map.GetValueFromKey("height", line));
                line         = reader.ReadLine();
                if (line.Contains("<data encoding=\"csv\""))
                {
                    string newid = reader.ReadLine();
                    for (int j = 0; j < ground.sizey; j++)
                    {
                        if (ground.name == "Ground")
                        {
                            ground.tiles.Add(new List <TileSave>());
                        }
                        for (int i = 0; i < ground.sizex; i++)
                        {
                            TileSave tilesave = new TileSave();
                            if (ground.name == "Ground")
                            {
                                if (newid.IndexOf(",") > 0)
                                {
                                    tilesave.mapid = Convert.ToInt32(newid.Substring(0, newid.IndexOf(",")));
                                    // newid for other layers
                                    newid = newid.Substring(newid.IndexOf(",") + 1);
                                    // same
                                }
                                else
                                {
                                    tilesave.mapid = Convert.ToInt32(newid);
                                }
                                tilesave.posx = i;
                                tilesave.posy = j;
                                ground.tiles[j].Add(tilesave);
                            }

                            /*else if (ground.name == "Triggers")
                             * {
                             *  tilesave = ground.tiles[j][i];
                             *  if (newid.IndexOf(",") > 0)
                             *  {
                             *      tilesave.triggerid = Convert.ToInt32(newid.Substring(0, newid.IndexOf(",")));
                             *      newid = newid.Substring(newid.IndexOf(",") + 1);
                             *  }
                             *  else
                             *  {
                             *      tilesave.triggerid = Convert.ToInt32(newid);
                             *  }
                             * }*/
                            else if (ground.name == "AddedGround")
                            {
                                // tile already created in ground.
                                tilesave = ground.tiles[j][i];
                                if (newid.IndexOf(",") > 0)
                                {
                                    tilesave.addedid = Convert.ToInt32(newid.Substring(0, newid.IndexOf(",")));
                                    newid            = newid.Substring(newid.IndexOf(",") + 1);
                                }
                                else
                                {
                                    tilesave.addedid = Convert.ToInt32(newid);
                                }
                            }
                        }
                        newid = reader.ReadLine();
                    }
                }
            }
            if (line.Contains("<objectgroup"))
            {
                ObjectGroupSave objectlayer = new ObjectGroupSave();
                objectlayer.name = map.GetValueFromKey("name", line);
                if (line.Contains("offsetx"))
                {
                    objectlayer.offsetx = Convert.ToInt32(map.GetValueFromKey("offsetx", line));
                }
                if (line.Contains("offsety"))
                {
                    objectlayer.offsety = Convert.ToInt32(map.GetValueFromKey("offsety", line));
                }
                map.objectgroups.Add(objectlayer);
                line = reader.ReadLine();
                if (line.Contains("<object"))
                {
                    while (!line.Contains("</objectgroup>"))
                    {
                        ObjectSave obj = new ObjectSave();
                        obj.id      = Convert.ToInt32(map.GetValueFromKey("id", line));
                        obj.gid     = Convert.ToInt32(map.GetValueFromKey("gid", line));
                        obj.x       = Convert.ToSingle(map.GetValueFromKey("x", line), CultureInfo.InvariantCulture.NumberFormat);
                        obj.y       = Convert.ToSingle(map.GetValueFromKey("y", line));
                        obj.width   = Convert.ToInt32(map.GetValueFromKey("width", line));
                        obj.height  = Convert.ToInt32(map.GetValueFromKey("height", line));
                        obj.offsetx = objectlayer.offsetx;
                        obj.offsety = objectlayer.offsety;

                        line = reader.ReadLine();
                        if (line.Contains("<properties"))
                        {
                            while ((!line.Contains("</object>")) && (!line.Contains("</properties")))
                            {
                                if (line.Contains("<property"))
                                {
                                    obj.modifiers.Add(map.GetValueFromKey("name", line), map.GetValueFromKey("value", line));
                                }
                                line = reader.ReadLine();
                            }
                            if (line.Contains("</properties"))
                            {
                                line = reader.ReadLine();
                            }
                            line = reader.ReadLine();
                        }
                        map.objects.Add(obj);
                    }
                }
            }
            if (line.Contains("<tileset"))
            {
                TileSetsSave tilesets = new TileSetsSave();
                tilesets.first  = Convert.ToInt32(map.GetValueFromKey("firstgid", line));
                tilesets.source = map.GetValueFromKey("source", line);
                StreamReader readertileset = new StreamReader("Assets/Resources/Map/" + tilesets.source);
                int          internid      = 0;
                string       linetileset   = readertileset.ReadLine();
                while (!readertileset.EndOfStream)
                {
                    if (linetileset.Contains("<tileset"))
                    {
                        tilesets.name        = map.GetValueFromKey("name", linetileset);
                        tilesets.tilewidth   = Convert.ToInt32(map.GetValueFromKey("tilewidth", linetileset));
                        tilesets.tileheight  = Convert.ToInt32(map.GetValueFromKey("tileheight", linetileset));
                        tilesets.spritecount = Convert.ToInt32(map.GetValueFromKey("tilecount", linetileset));
                    }
                    if (linetileset.Contains("<tile "))
                    {
                        TileSetSave tileset = new TileSetSave();
                        tileset.id          = Convert.ToInt32(map.GetValueFromKey("id", linetileset));
                        linetileset         = readertileset.ReadLine();
                        tileset.internal_id = internid;
                        while (!linetileset.Contains("</tile>"))
                        {
                            if (linetileset.Contains("<property"))
                            {
                                tileset.modifiers.Add(map.GetValueFromKey("name", linetileset), map.GetValueFromKey("value", linetileset));
                            }
                            if (linetileset.Contains("<image") && (!linetileset.Contains("format")))
                            {
                                tileset.height     = Convert.ToInt32(map.GetValueFromKey("height", linetileset));
                                tileset.spritefile = map.GetValueFromKey("source", linetileset);
                                tileset.width      = Convert.ToInt32(map.GetValueFromKey("width", linetileset));
                            }
                            linetileset = readertileset.ReadLine();
                        }
                        internid++;
                        tilesets.tilesets.Add(tileset);
                    }
                    linetileset = readertileset.ReadLine();
                }
                map.tilesets.Add(tilesets);
            }
            line = reader.ReadLine();
        }
        map.layer.tiles.Reverse();
        reader.Close();
    }
Ejemplo n.º 11
0
 public ObjectEntity(string p_ControlName, ObjectSave.Pool.TiposDeControles p_TipoControl, string p_value) 
 {
     _name = p_ControlName;
     _tipoControl = p_TipoControl;
     _value = p_value;
 }
Ejemplo n.º 12
0
    public void checkObjModifiers(ObjectSave obj, GameObject curObj, string id)
    {
        if (obj.modifiers.ContainsKey("Background") && (obj.modifiers["Background"] == "true"))
        {
            curObj.GetComponent <Transform>().position += new Vector3(0.0f, 0.0f, GM.ZBackground);
        }

        // spawning object
        if (obj.modifiers.ContainsKey("spawner") && (obj.modifiers["spawner"] == "true"))
        {
            GM.Player     = new GameObject("Player");
            GM.Player.tag = "player";
            PlayerController PControl = GM.Player.AddComponent <PlayerController>();
            PControl.SetPosition(curObj.GetComponent <Transform>(), curObj.GetComponent <SpriteRenderer>());
            GM.Camera = GameObject.Find("Camera").GetComponent <CameraController>();
            GM.Camera.ReplaceCam(curObj, PControl);
        }
        // cam lock
        if (obj.modifiers.ContainsKey("camcollider") && (obj.modifiers["camcollider"] == "true"))
        {
            curObj.layer = LayerMask.NameToLayer("camera");
            curObj.tag   = "camlock";
            BoxCollider2D mybox = curObj.AddComponent <BoxCollider2D>();
            mybox.isTrigger = true;
        }
        // cam unlock
        if (obj.modifiers.ContainsKey("camcollider") && (obj.modifiers["camcollider"] == "false"))
        {
            curObj.layer = LayerMask.NameToLayer("camera");
            curObj.tag   = "camunlock";
            BoxCollider2D mybox = curObj.AddComponent <BoxCollider2D>();
            mybox.isTrigger = true;;
        }
        // collider ground
        if (obj.modifiers.ContainsKey("colliderground") && (obj.modifiers["colliderground"] == "true"))
        {
            curObj.layer = LayerMask.NameToLayer("ground");
            EdgeCollider2D mybox = curObj.AddComponent <EdgeCollider2D>();
            mybox.offset    = new Vector2(0, curObj.GetComponent <SpriteRenderer>().size.y / 2);
            mybox.isTrigger = false;
        }
        // collider
        if (obj.modifiers.ContainsKey("collider") && (obj.modifiers["collider"] == "true"))
        {
            curObj.layer = LayerMask.NameToLayer("collider");
            if (obj.modifiers.ContainsKey("face") && (obj.modifiers["face"] == "right"))
            {
                EdgeCollider2D mybox     = curObj.AddComponent <EdgeCollider2D>();
                Vector2[]      newPoints = new Vector2[2];
                newPoints[0] = new Vector2(0.0f, -2.5f);
                newPoints[1] = new Vector2(0.0f, 2.5f);
                mybox.points = newPoints;
                mybox.offset = new Vector2(curObj.GetComponent <SpriteRenderer>().size.x / 2, 0.0f);
            }
            else if (obj.modifiers.ContainsKey("face") && (obj.modifiers["face"] == "left"))
            {
                EdgeCollider2D mybox     = curObj.AddComponent <EdgeCollider2D>();
                Vector2[]      newPoints = new Vector2[2];
                newPoints[0] = new Vector2(0.0f, -2.5f);
                newPoints[1] = new Vector2(0.0f, 2.5f);
                mybox.points = newPoints;
                mybox.offset = new Vector2(-curObj.GetComponent <SpriteRenderer>().size.x / 2, 0.0f);
            }
            else
            {
                BoxCollider2D mybox = curObj.AddComponent <BoxCollider2D>();
                mybox.isTrigger = false;
            }
        }
        // level variables
        if ((id != "") && (string.Compare(id, "LevelVals") == 0))
        {
            PlayerPrefs.SetString("level", obj.modifiers["Name"]);
            GM.UI.setLevelName();
            PlayerPrefs.SetString("nextmap", obj.modifiers["NextLevel"]);
            GM.Player.AddComponent(Type.GetType(obj.modifiers["SpeScript"]));
            Destroy(curObj);
        }
        // invisible
        if (obj.modifiers.ContainsKey("visible") && (obj.modifiers["visible"] == "false"))
        {
            curObj.GetComponent <SpriteRenderer>().enabled = false;
        }
    }