Пример #1
0
        public void LoadLevelFromDropdown()
        {
            Dropdown cbx = GameObject.Find("drpLoad").GetComponent <Dropdown>();

            currentLevel.Destroy();
            currentLevel = SerializedGameLevels.getLevel(cbx.options[cbx.value].text);
        }
Пример #2
0
        // Use this for initialization
        void Start()
        {
            Game.game.Initialize();
            Init();

            currentLevel = SerializedGameLevels.getLevel("testlevel");
        }
Пример #3
0
        static public void Serialize(SerializedGameLevels sz, string filename)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(SerializedGameLevels));
            TextWriter    textWriter = new StreamWriter(filename);

            serializer.Serialize(textWriter, sz);
            textWriter.Close();
        }
Пример #4
0
 public void SaveAll()
 {
     SerializedGameLevels.Serialize(SerializedGameLevels.gameLevels, Application.dataPath + "/8BD/Resources/" + Constants.GameLevelsXML + ".xml");
     Debug.Log("Saving : " + currentLevel.sz.mapName);
     Map2D.Save(currentLevel.map, currentLevel.sz.mapName);
     UnityEditor.AssetDatabase.Refresh();
     PopulateLoad();
 }
Пример #5
0
 public void Initialize()
 {
     Screen.orientation                    = ScreenOrientation.LandscapeLeft;
     SerializedEntities.se                 = SerializedEntities.DeSerialize(Constants.EntitiesXML);
     SerializedScenes.szScenes             = SerializedScenes.DeSerialize(Constants.ScenesXML);
     SerializedMapCategories.mapCategories = SerializedMapCategories.DeSerialize(Constants.CategoriesXML);
     SerializedGameLevels.gameLevels       = SerializedGameLevels.DeSerialize(Constants.GameLevelsXML);
 }
Пример #6
0
        public static SerializedGameLevels DeSerialize(string filename)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(SerializedGameLevels));

            TextAsset            textAsset  = (TextAsset)Resources.Load(filename);
            TextReader           textReader = new StringReader(textAsset.text);
            SerializedGameLevels sz         = (SerializedGameLevels)deserializer.Deserialize(textReader);

            foreach (SerializedGameLevel sgl in sz.levels)
            {
                foreach (SerializedCharacterInstance sci in sgl.characters)
                {
                    sci.Initialize();
                }
            }

            textReader.Close();
            return(sz);
        }
Пример #7
0
        public void CreateNew()
        {
            SerializedGameLevel gl = new SerializedGameLevel();

            gl.crtSettings_id = "crt";
            gl.mapName        = GameObject.Find("inpMapName").GetComponent <InputField>().text;
            gl.name           = GameObject.Find("inpNewName").GetComponent <InputField>().text;

            Map2D map = new Map2D();
            int   x   = int.Parse(GameObject.Find("inpX").GetComponent <InputField>().text);
            int   y   = int.Parse(GameObject.Find("inpY").GetComponent <InputField>().text);

            map.Create(x, y);
            Map2D.Save(map, gl.mapName);

            SerializedGameLevels.gameLevels.levels.Add(gl);
            SaveAll();

            currentLevel.Destroy();
            currentLevel = SerializedGameLevels.getLevel(gl.name);
        }