Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        if (GameObject.Find ("MidSceneData") == null) {
            Instantiate (midSceneDataPrefab).name = "MidSceneData";
        }

        string storageDir;
        #if UNITY_IPHONE && !UNITY_EDITOR
        storageDir = Path.Combine (Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Game Editor Resources/");
        #elif UNITY_EDITOR
        storageDir = Path.Combine (Application.dataPath, "Resources/Game Editor Resources/");
        #else
        storageDir = Path.Combine (Application.dataPath, "Game Editor Resources/");
        #endif
        ResourceManager.Instance.SetStoragePath (storageDir);

        levelSaveCollection = ResourceManager.Instance.Load ("levels.xml", typeof(LevelsSaveCollection)) as LevelsSaveCollection;
        shipSaveCollection = ResourceManager.Instance.Load ("ships.xml", typeof(ShipsSaveCollection)) as ShipsSaveCollection;
        equipmentSaveCollection = ResourceManager.Instance.Load ("equipment.xml", typeof(EquipmentSaveCollection)) as EquipmentSaveCollection;
        ammoSaveCollection = ResourceManager.Instance.Load ("ammo.xml", typeof(AmmoSaveCollection)) as AmmoSaveCollection;

        if (levelSaveCollection.levels.Count == 0 || shipSaveCollection.ships.Count == 0) {
            Application.LoadLevel ("GameEditor");
        } else {
            poplst_levels.items.Clear ();
            for (int i = 0; i < levelSaveCollection.levels.Count; i++) {
                poplst_levels.items.Add (levelSaveCollection.levels [i].name);
            }
            poplst_levels.selection = poplst_levels.items [0];

            poplst_ship.items.Clear ();
            for (int i = 0; i < shipSaveCollection.ships.Count; i++) {
                poplst_ship.items.Add (shipSaveCollection.ships [i].name);
            }
            poplst_ship.selection = poplst_ship.items [0];
        }
    }
Beispiel #2
0
 void Start()
 {
     ammoSaveCollection = resourceManager.Load ("ammo.xml", typeof(AmmoSaveCollection)) as AmmoSaveCollection;
     equipmentSaveCollection = resourceManager.Load ("equipment.xml", typeof(EquipmentSaveCollection)) as EquipmentSaveCollection;
     shipSaveCollection = resourceManager.Load ("ships.xml", typeof(ShipsSaveCollection)) as ShipsSaveCollection;
     levelSaveCollection = resourceManager.Load ("levels.xml", typeof(LevelsSaveCollection)) as LevelsSaveCollection;
 }
Beispiel #3
0
 void PanelFlipIn(UIPanel source)
 {
     if (source.Equals (area_ammoPanel)) {
     } else if (source.Equals (area_equipmentPanel)) {
         equipmentSaveCollection = resourceManager.Load ("equipment.xml", typeof(EquipmentSaveCollection)) as EquipmentSaveCollection;
     } else if (source.Equals (area_levelPanel)) {
         levelSaveCollection = resourceManager.Load ("levels.xml", typeof(LevelsSaveCollection)) as LevelsSaveCollection;
     } else if (source.Equals (area_shipPanel)) {
         shipSaveCollection = resourceManager.Load ("ships.xml", typeof(ShipsSaveCollection)) as ShipsSaveCollection;
     }
 }
Beispiel #4
0
    public void OnResetBtnClick()
    {
        string storageDir;
        #if UNITY_IPHONE && !UNITY_EDITOR
        storageDir = Path.Combine (Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Game Editor Resources/");
        #elif UNITY_EDITOR
        storageDir = Path.Combine (Application.dataPath, "Resources/Game Editor Resources/");
        #else
        storageDir = Path.Combine (Application.dataPath, "Game Editor Resources/");
        #endif
        if (!Directory.Exists (storageDir)) {
            Directory.CreateDirectory (storageDir);
        }

        TextAsset ta = Resources.Load ("Game Editor Resources/ammo") as TextAsset;
        using (StreamWriter outfile = new StreamWriter(Path.Combine (storageDir, "ammo.xml"))) {
            outfile.Write (ta.text);
        }

        ta = Resources.Load ("Game Editor Resources/equipment") as TextAsset;
        using (StreamWriter outfile = new StreamWriter(Path.Combine (storageDir, "equipment.xml"))) {
            outfile.Write (ta.text);
        }

        ta = Resources.Load ("Game Editor Resources/levels") as TextAsset;
        using (StreamWriter outfile = new StreamWriter(Path.Combine (storageDir, "levels.xml"))) {
            outfile.Write (ta.text);
        }

        ta = Resources.Load ("Game Editor Resources/ships") as TextAsset;
        using (StreamWriter outfile = new StreamWriter(Path.Combine (storageDir, "ships.xml"))) {
            outfile.Write (ta.text);
        }

        ammoSaveCollection = resourceManager.Load ("ammo.xml", typeof(AmmoSaveCollection)) as AmmoSaveCollection;
        equipmentSaveCollection = resourceManager.Load ("equipment.xml", typeof(EquipmentSaveCollection)) as EquipmentSaveCollection;
        shipSaveCollection = resourceManager.Load ("ships.xml", typeof(ShipsSaveCollection)) as ShipsSaveCollection;
        levelSaveCollection = resourceManager.Load ("levels.xml", typeof(LevelsSaveCollection)) as LevelsSaveCollection;
    }