Ejemplo n.º 1
0
    public void SaveGame()
    {
        FileStream file = File.Create (Application.persistentDataPath + "/characters.data");

        string[] skillNames = new string[player.skills.Length];
        for (int i = 0; i < player.skills.Length; i++) {
            skillNames [i] = player.skills [i].getName ();
        }

        SaveObject saveObject = new SaveObject (player.stats, player.buff, inventory.itemListDictionary, skillNames);
        bf.Serialize (file, saveObject);
        file.Close ();
        WholeScreenTextScript.ShowText ("Game saved");
        Debug.Log ("Player saved to " + Application.persistentDataPath);
    }
Ejemplo n.º 2
0
    public void LoadGameWalkableTiles()
    {
        // load data from file (json format)
        string json = SaveSystem.LoadGameTiles();

        if (json != null)
        {
            //print("load: " + json);
            SaveObject saveObject = JsonUtility.FromJson <SaveObject>(json);
            walkableTiles = saveObject.dataArray;

            // load into game
            if (MenuGameManager.instance != null)
            {
                MenuGameManager.instance.SetGridWalkableData(walkableTiles);
            }
            else
            {
                GameManager.instance.SetGridWalkableData(walkableTiles);
            }
        }
        else
        {
            walkableTiles = new bool[gridWidth * gridHeight];
            for (int i = 0; i < gridWidth * gridHeight; i++)
            {
                walkableTiles[i] = false;
            }

            // load into game
            if (MenuGameManager.instance != null)
            {
                MenuGameManager.instance.SetGridWalkableData(walkableTiles);
            }
            else
            {
                GameManager.instance.SetGridWalkableData(walkableTiles);
            }
        }
    }
Ejemplo n.º 3
0
    //TODO: Add error checking code
    public static void Save()
    {
        saveObject = new SaveObject();

        SaveEvent(typeof(SaveManager));

        saveObject.levelsInfo = GameManager.Instance.levelsCleared;

        //Save the journal
        JournalSaveData js = new JournalSaveData();

        if (Journal.Instance != null)
        {
            js.itemsInJournal = Journal.Instance.GetAllItemsInJournal();

            //TODO: Add all acids, bases and neutral items as separate images in the resources folder.
            //Change how the images are being referenced
            //for storing the sprites, store all the textures.
            for (int i = 0; i < Journal.Instance.GetAllItemIconsInJournal().Count; i++)
            {
                js.itemIconsPath.Add(AssetDatabase.GetAssetPath(Journal.Instance.GetAllItemIconsInJournal()[i]));

                SerializableRect r = new SerializableRect(Journal.Instance.GetAllItemIconsInJournal()[i].rect.x,
                                                          Journal.Instance.GetAllItemIconsInJournal()[i].rect.y,
                                                          Journal.Instance.GetAllItemIconsInJournal()[i].rect.width,
                                                          Journal.Instance.GetAllItemIconsInJournal()[i].rect.height);


                Debug.Log("Path: " + AssetDatabase.GetAssetPath(Journal.Instance.GetAllItemIconsInJournal()[i]));
                Debug.Log("x: " + r.x + "y: " + r.y + "width: " + r.width + "Height " + r.height);
                js.spriteRect.Add(r);
            }

            js.itemsDescriptions = Journal.Instance.GetAllItemDescriptionsInJournal();

            saveObject.SaveJournal(js, localStoragePath, "Journal");
        }

        MemoryManager.Save <SaveObject>(saveObject, xmlDocument, localStoragePath, saveFileName);
    }
Ejemplo n.º 4
0
    private void FillSaveObject(SaveObject save)
    {
        for (int i = 0; i < puzzlePartSavers.Length; i++)
        {
            save.saveablePuzzleParts.Add(puzzlePartSavers[i].saveData);
        }

        for (int i = 0; i < interactableSavers.Length; i++)
        {
            save.saveableInteractables.Add(interactableSavers[i].saveData);
        }

        for (int i = 0; i < inventoryItemSavers.Length; i++)
        {
            save.saveableInventoryItems.Add(inventoryItemSavers[i].saveData);
        }

        for (int i = 0; i < eventSavers.Length; i++)
        {
            save.saveableEventTriggers.Add(eventSavers[i].saveData);
        }
    }
Ejemplo n.º 5
0
    void SaveToJSON(bool isDebug)
    {
        SetGuids();

        LevelPlaylist levels     = CreateLevelPlaylistObject();
        SaveObject    saveObject = new SaveObject()
        {
            savedWeapons = weaponTypes, playerParams = player, levelPlaylist = levels
        };
        string json = JsonUtility.ToJson(saveObject);

        Debug.Log(json);

        string file = Application.dataPath + "/Resources/DesignMaster.txt";

        if (isDebug)
        {
            file = Application.dataPath + "/Resources/DebugDesignMaster.txt";
        }

        File.WriteAllText(file, json);
    }
Ejemplo n.º 6
0
    // Update is called once per frame
    public void LoadSaveFromFile()
    {
        if (File.Exists(Application.persistentDataPath + "/gamesave.sav"))
        {
            //BinaryFormatter bf = new BinaryFormatter();
            //FileStream file = File.Open(Application.persistentDataPath + "/gamesave.sav", FileMode.Open);
            //SaveObject oldSave = (SaveObject)bf.Deserialize(file);
            //stats.LoadFromSaveObject(oldSave);
            //file.Close();

            string     json    = File.ReadAllText(Application.persistentDataPath + "/gamesave.sav");
            SaveObject oldSave = JsonUtility.FromJson <SaveObject>(json);
            stats.LoadFromSaveObject(oldSave);
            Debug.Log("Loaded game from " + Application.persistentDataPath + "/gamesave.sav");
            return;
        }

        else
        {
            Debug.LogWarning("Load Failed! File does not exist.");
        }
    }
Ejemplo n.º 7
0
    private string check_user(string username, string passwd, SaveObject saveObj)
    {
        List <UserInfo> userList  = saveObj.userInfos;
        int             userIndex = userList.FindIndex(x => x.username == username);

        if (userIndex != -1)
        {
            UserInfo user = userList[userIndex];
            if (passwd == user.passwd)
            {
                return("passwd_correct");
            }
            else
            {
                return("passwd_incorrect");
            }
        }
        else
        {
            return("no_user");
        }
    }
Ejemplo n.º 8
0
    public void OnClickLoad()
    {
        try
        {
            FilePath = StandaloneFileBrowser.OpenFilePanel("Open File", Application.persistentDataPath, FileExtension, false)[0];

            DirectoryPath = Path.GetDirectoryName(FilePath);
            FileName      = Path.GetFileNameWithoutExtension(FilePath);
            FullFileName  = FileName + "." + FileExtension;

            //Debug.Log("Loading from: " + FilePath);
        }
        catch (System.Exception)
        {
            return;
        }

        saveobject = ReadObjectFromFile(FilePath);
        ReadDataFromObject();

        paneloffsets.UpdateInputs();
    }
Ejemplo n.º 9
0
    public void Confirm()
    {
        string data = LoadTextField.text;

        //BinaryFormatter bf = new BinaryFormatter();
        //MemoryStream ms = new MemoryStream();
        //StreamWriter sw = new StreamWriter(ms);
        //sw.Write(data);
        //SaveObject oldSave = (SaveObject)bf.Deserialize(ms);
        //FindObjectOfType<StatTracker>().LoadFromSaveObject(oldSave);
        try
        {
            SaveObject so = JsonUtility.FromJson <SaveObject>(data);
            FindObjectOfType <StatTracker>().LoadFromSaveObject(so);
        }
        catch
        {
            TitleMessage.text = "Could not Load Save File!";
            return;
        }
        TitleMessage.text = "Load Successful!";
    }
Ejemplo n.º 10
0
    public void SaveAfterDeath()
    {
        string saveString = SaveSystem.Load();

        if (saveString != null)
        {
            SaveObject saveObject = JsonUtility.FromJson <SaveObject>(saveString);
            saveObject.score = playerStats.getScore();
            string jsonExist = JsonUtility.ToJson(saveObject);
            SaveSystem.SaveAfterDeath(jsonExist);
        }

        else
        {
            SaveObject saveObject = new SaveObject
            {
            };
            saveObject.score = playerStats.getScore();
            string jsonNoExist = JsonUtility.ToJson(saveObject);
            SaveSystem.SaveAfterDeath(jsonNoExist);
        }
    }
Ejemplo n.º 11
0
    private void Start()
    {
        UTYL.agentPrefab = Resources.Load("prefabs/AI") as GameObject;
        UTYL.foodPrefab  = Resources.Load("prefabs/Food") as GameObject;
        UTYL.boxPrefab   = Resources.Load("prefabs/Box") as GameObject;

        unisignedNet = new List <GNNNet>();
        SaveObject so = SaveLoadManager.Load();

        if (so == null) // No save file new sim
        {
            DB.SendData("clean_up", new Dictionary <string, string>());

            for (int i = 0; i < CONFIG.POPULATION; i++)
            {
                GNNNet net = new GNNNet();

                for (ushort o = 0; o < 4; o++)
                {
                    net.MutateLink();
                }

                net.connections = net.connections.OrderBy(x => x.innov).ToList();
                unisignedNet.Add(net);
            }
        }
        else
        {
            unisignedNet.AddRange(so.networks);
            GEN = so.GEN;
            InnovController.innovations = new List <Innovation>(so.innovations);
            unisignedNet.RemoveAt(0);
            InnovController.innov = so.innovID;
        }

        UTYL.InitFood();
        InitGeneration();
    }
Ejemplo n.º 12
0
        private void Btn_test_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                btn_connect.Content      = "Starting";
                btn_disconnect.Content   = "Stop";
                btn_connect.IsEnabled    = false;
                btn_disconnect.IsEnabled = true;

                if (System.IO.File.Exists(SaveObject.Pathsave))
                {
                    SettingClass = (SettingClass)SaveObject.Load_data(SaveObject.Pathsave);
                }
                if (SettingClass == null)
                {
                    SettingClass = new SettingClass();
                }
                if (SettingClass.PLCTimeOut == 0)
                {
                    SettingClass.PLCTimeOut = 2000;
                }
                if (SettingClass.timmer == 0)
                {
                    SettingClass.timmer = 10000;
                }
                LoadDataMQCStarting();
                tmrCallBgWorker.Interval = SettingClass.timmer > 0 ? SettingClass.timmer : 500;
                tmrCallBgWorker.Start();

                //   LoadAdress();

                //    SettingClass = (SettingClass) SaveObject.Load_data(SaveObject.Pathsave);
            }
            catch (Exception exc)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "get data first test", exc.Message);
            }
        }
Ejemplo n.º 13
0
    public static void Save(ushort GEN, List <GNNNet> nets)
    {
        SaveObject so = new SaveObject()
        {
            GEN         = GEN,
            innovations = InnovController.innovations.ToArray(),
            networks    = nets.ToArray(),
            innovID     = InnovController.innov,
        };

        try
        {
            Stream          fileStram  = File.Create(_DIR + "ra18014_savefile_new.bin");
            BinaryFormatter serializer = new BinaryFormatter();

            serializer.Serialize(fileStram, so);
            fileStram.Close();
        }
        catch (IOException e)
        {
            Debug.Log("Error:" + e.ToString());
        }
    }
Ejemplo n.º 14
0
    IEnumerator LoadingValues(SaveObject loadedSave)
    {
        while (SceneManager.GetActiveScene().buildIndex != 1)
        {
            Debug.Log("Wait");
            yield return(new WaitForSecondsRealtime(0.5f));
        }
        Debug.Log("Load Value");

        // Locate the PlayerManager script
        pm            = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerManager>();
        pm.gold       = loadedSave.Gold;
        pm.experience = loadedSave.Experience;
        pm.gameObject.transform.position = loadedSave.Position;

        for (int i = 0; i < loadedSave.ItemAmounts.Count; i++)
        {
            pm.inventory[i].itemAmount = loadedSave.ItemAmounts[i];
        }

        // Make sure that UpdateUI() is public in PlayerManager
        pm.UpdateUI();
    }
Ejemplo n.º 15
0
    public static SaveObject Load()
    {
        string fileName = _DIR + "ra18014_savefile_new.bin";

        if (File.Exists(fileName))
        {
            try
            {
                Stream          fileStram    = File.OpenRead(fileName);
                BinaryFormatter deserializer = new BinaryFormatter();
                // Deseriealize datus no faila parversot tos par sarakstu ar objektiem
                SaveObject so = (SaveObject)deserializer.Deserialize(fileStram);
                fileStram.Close();
                return(so);
            }
            catch (IOException e)
            {
                Debug.Log("Error:" + e.ToString());
            }
        }

        return(null);
    }
Ejemplo n.º 16
0
        public void add_hs_list()
        {
            FileInfo[] fis = info.GetFiles();
            foreach (FileInfo fi in fis)
            {
                if (!fi.Extension.Contains("meta"))
                {
                    int    index      = fi.Name.IndexOf("_");
                    string nume       = Path.GetFileNameWithoutExtension(fi.FullName).Substring(index + 1);
                    string saveString = SaveSystem.Load(nume);

                    if (saveString != null)
                    {
                        SaveObject          saveObject = JsonUtility.FromJson <SaveObject>(saveString);
                        ScoreboardEntryData hs_test    = new ScoreboardEntryData();
                        hs_test.entryName  = nume;
                        hs_test.entryScore = saveObject.score;

                        hs_list.Add(hs_test);
                    }
                }
            }
        }
Ejemplo n.º 17
0
    public void Load()
    {
        // Load
        string saveString = SaveSystem.Load();

        if (saveString != null)
        {
            SaveObject saveObject = JsonUtility.FromJson <SaveObject>(saveString);

            unit.transform.position = saveObject.playerPosition;
            unit.ingredients        = saveObject.ingredients;
            unit.doneIngredients    = saveObject.doneIngredients;
            unit.pizzas             = saveObject.pizzas;
            unit.cheeseIcon.color   = saveObject.cheeseIcon;
            unit.meatIcon.color     = saveObject.meatIcon;
            unit.tomatoIcon.color   = saveObject.tomatoIcon;
            unit.flourIcon.color    = saveObject.flourIcon;
            unit.timeRun            = saveObject.timeRun;
        }
        else
        {
        }
    }
Ejemplo n.º 18
0
    /**
     * In order to use the SaveObject, we need to initialize it.
     * It will create a SaveObject instance, make sure you link
     * correctly to the save object either with a string with the
     * Resources folder as root or a direct link to the prefab.
     **/
    void Start()
    {
        /**
         * You need to call SaveObject.Initialize before doing anything with SaveObject.
         **/
        if (PlayerPrefs.GetInt("usouSave") != 1)
        {
            SaveObject.Initialize(saveObject);
        }
        PlayerPrefs.SetInt("usouSave", 0);

        /**
         * Set a callback for when you load a game like this, used to do complex updates
         * when needed.
         **/
        SaveObject.SetRefreshCallback(OnRefresh);

        /**
         * It is recommended that you Load right after initialization, it makes sure that
         * you always have a game ready to be used.
         **/
        SaveObject.Load("Saved Game No1");
    }
Ejemplo n.º 19
0
    public void SaveGame()
    {
        pm = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerManager>();

        SaveObject saveObj = new SaveObject
        {
            Position    = pm.transform.position,
            Gold        = pm.gold,
            Experience  = pm.experience,
            Difficulty  = PlayerPrefs.GetInt(PrefNames.difficulty),
            Name        = PlayerPrefs.GetString(PrefNames.playerName),
            ItemAmounts = new List <int>(pm.inventory.Count)
        };

        foreach (inventorySlotProxy proxy in pm.inventory)
        {
            saveObj.ItemAmounts.Add(proxy.itemAmount);
        }

        string json = JsonUtility.ToJson(saveObj);

        SaveSystem.Save(json);
    }
Ejemplo n.º 20
0
        public override void SetData(string saveString, params object[] otherData)
        {
            SaveObject ds = JsonUtility.FromJson <SaveObject>(saveString);

            ID    = ds.ID;
            Level = ds.Level;

            EnemyData original;

            if (otherData[0] is PersistentSetFollowerData)
            {
                PersistentSetFollowerData allFollowers = (PersistentSetFollowerData)otherData[0];
                original = allFollowers.First(it => it.ID == ID) as EnemyData;
            }
            else
            {
                original = otherData[0] as EnemyData;
                if (Idle == original.Idle)
                {
                    return;     // This object may have been create based on the original. In which case, we don't need to do any copying
                }
            }

            // Copy Original Values
            Idle                = original.Idle;
            Flinch              = original.Flinch;
            BeforeAttack        = original.BeforeAttack;
            AttackExecute       = original.AttackExecute;
            AfterAttack         = original.AfterAttack;
            Death               = original.Death;
            Dead                = original.Dead;
            Walking             = original.Walking;
            ElementalWeaknesses = original.ElementalWeaknesses;
            ElementalDamageType = original.ElementalDamageType;

            base.SetData(saveString, original);
        }
Ejemplo n.º 21
0
    public void Save()
    {
        List <int>  costs     = new List <int>();
        List <bool> purchased = new List <bool>();
        List <int>  levels    = new List <int>();

        foreach (Button button in buttons)
        {
            costs.Add(button.GetComponent <SkillTreeButton>().cost);
            purchased.Add(button.GetComponent <SkillTreeButton>().purchased);
            levels.Add(button.GetComponent <SkillTreeButton>().tier);
        }

        SaveObject saveObject = new SaveObject
        {
            maxHealth     = maxHealth,
            laserStrength = laserStrength,
            totalXP       = totalXP,

            unlockedLevel = unlockedLevel,

            NumUnlockedL1 = NumUnlockedL1,
            NumUnlockedL2 = NumUnlockedL2,
            NumUnlockedL3 = NumUnlockedL3,

            NumL1ToUnlockL2 = NumL1ToUnlockL2,
            NumL2ToUnlockL3 = NumL2ToUnlockL3,

            costs     = costs,
            purchased = purchased,
            levels    = levels,
        };

        string json = JsonUtility.ToJson(saveObject);

        SaveSkillTreeSystem.Save(json);
    }
Ejemplo n.º 22
0
    public void Save()
    {
        linePoints = renderObject.GetComponentsInChildren <CurvedLinePoint>();

        linePositions = new Vector3[linePoints.Length];
        for (int i = 0; i < linePoints.Length; i++)
        {
            linePositions[i] = linePoints[i].transform.position;
        }
        ;


        if (linePoints != null)
        {
            SaveObject saveObject = new SaveObject
            {
                linePoints = linePositions,
            };
            string json = JsonUtility.ToJson(saveObject);

            File.WriteAllText(Application.dataPath + "/save.txt", json);
            Debug.Log("Json Saved!");
        }
    }
Ejemplo n.º 23
0
    public static void Save()
    {
        //Checks if save folder exists
        if (!Directory.Exists(SAVE_FOLDER))
        {
            //Creates save folder if non is found
            Directory.CreateDirectory(SAVE_FOLDER);
        }

        string filePath = DateTime.Now.ToString();

        filePath = filePath.Replace(":", ".").Replace("/", "-");
        filePath = SAVE_FOLDER + "Test Result " + filePath + ".txt";
        Debug.Log(filePath);
        SaveObject saveObject = new SaveObject {
            dateTime   = DateTime.Now.ToString(),
            scoreLeft  = LogmarScoreLeft.score,
            scoreRight = LogmarScoreRight.score
        };
        string json = JsonUtility.ToJson(saveObject);

        Debug.Log(json);
        File.WriteAllText(filePath, json);
    }
Ejemplo n.º 24
0
    public void LoadFile()
    {
        string json = "";

        // Open the stream and read it back.
        using (StreamReader sr = File.OpenText(filePath))
        {
            string s = "";
            while ((s = sr.ReadLine()) != null)
            {
                json += s;
            }
        }

        // Debug.Log(json);

        //deserialize the object
        SaveObject saveObject = JsonConvert.DeserializeObject <SaveObject>(json);

        for (int i = 0; i < saveObject.plantObjects.Count; i++)
        {
            Debug.Log(saveObject.plantObjects[i].Name);
        }
    }
Ejemplo n.º 25
0
    string SaveData()
    {
        List <PlantObject> plants = new List <PlantObject>();

        //get all attributes of all plants in list
        for (int i = 0; i < plantCollection.Count; i++)
        {
            string name = plantCollection[i].name;

            //get plant's' attributes
            float lighting   = getVal(plantCollection[i], "Lighting");
            float temp       = getVal(plantCollection[i], "Temperature");
            float water      = getVal(plantCollection[i], "Water");
            float fertiliser = getVal(plantCollection[i], "Fertiliser");

            List <float> depVals = new List <float>();
            depVals.Add(lighting);
            depVals.Add(temp);
            depVals.Add(water);
            depVals.Add(fertiliser);

            PlantObject plantObject = new PlantObject {
                Name       = name,
                Attributes = depVals,
            };

            plants.Add(plantObject);
        }
        ;

        SaveObject saveObject = new SaveObject {
            plantObjects = plants,
        };

        return(JsonConvert.SerializeObject(saveObject, Formatting.Indented));
    }
Ejemplo n.º 26
0
        static void Main(string[] args)
        {
            DeserializingManager deserializer = new DeserializingManager();

            //IPodcast a = deserializer.DeserializeRssXml("http://joeroganexp.joerogan.libsynpro.com/rss");

            //IPodcast a = deserializer.DeserializeRssXml("http://podcast.wdr.de/quarks.xml");

            //IPodcast a = deserializer.DeserializeRssXml("http://web.ard.de/radiotatort/rss/podcast.xml");

            //IPodcast a = deserializer.DeserializeRssXml("https://www1.wdr.de/radio/podcasts/wdr2/kabarett132.podcast");

            IPodcast a = deserializer.DeserializeRssXml("http://www1.swr.de/podcast/xml/swr2/forum.xml");

            //FileDataTarget dal = new FileDataTarget();
            //dal.SavePodcast(a);

            SaveObject blSave = new SaveObject();

            blSave.SavePodcastAsXml(a);

            GetObjects     blGet      = new GetObjects();
            List <ISeries> seriesList = blGet.GetSeriesList();
        }
Ejemplo n.º 27
0
    // Load
    public void Load()
    {
        string saveString = SaveSkillTree.Load();

        SaveObject saveObject = JsonUtility.FromJson <SaveObject>(saveString);

        unlockedTier = saveObject.unlockedTier;

        NumUnlockedT1 = saveObject.NumUnlockedT1;
        NumUnlockedT2 = saveObject.NumUnlockedT2;
        NumUnlockedT3 = saveObject.NumUnlockedT3;
        NumUNlockedT4 = saveObject.NumUllockedT4;

        NumT1ToUnlockT2 = saveObject.NumT1ToUnlockT2;
        NumT2ToUnlockT3 = saveObject.NumT2ToUnlockT3;
        NumT3ToUnlockT4 = saveObject.NumT3ToUnlockT4;

        for (int i = 0; i < toggles.Count; i++)
        {
            toggles[i].GetComponent <SkillTreeButton>().cost      = saveObject.costs[i];
            toggles[i].GetComponent <SkillTreeButton>().purchased = saveObject.purchased[i];
            toggles[i].GetComponent <SkillTreeButton>().tier      = saveObject.tiers[i];
        }
    }
Ejemplo n.º 28
0
    // Update is called once per frame
    public void Update()
    {
        if (song != null)
        {
            string highScoreValue = "-";
            bool   clearedValue   = false;
            songName.text = song.songName;
            genre.text    = "Genre: " + song.genre;
            artist.text   = "Artist: " + song.artist;
            duration.text = "Duration: " + (int)song.duration / 60 + ":" + song.duration % 60;
            //load data
            SaveObject save = new SaveObject(0, false);
            if (MainValue.Instance.saveObjects.TryGetValue(song.songName, out save))
            {
                Debug.Log(save.highScore);
                highScoreValue = save.highScore.ToString();
                clearedValue   = save.cleared;
            }
            highScore.text = "High score: " + highScoreValue;
            cleared.SetActive(clearedValue);
        }

        //TODO make high score look up
    }
Ejemplo n.º 29
0
    // Start is called before the first frame update
    void Awake()
    {
        saveObject = new SaveObject();

        sushis       = new List <GameObject>();
        saucebottles = new List <GameObject>();

        tuna       = GameObject.Find("Tuna");
        yellowfish = GameObject.Find("Yellowfish");
        salmon     = GameObject.Find("Salmon");
        roeboat    = GameObject.Find("RoeBoat");
        shrimp     = GameObject.Find("Shrimp");

        hot     = GameObject.Find("HotSauce");
        xeno    = GameObject.Find("XenoSauce");
        tron    = GameObject.Find("TronSauce");
        trek    = GameObject.Find("TrekSauce");
        monster = GameObject.Find("MonsterSauce");
        scifi   = GameObject.Find("SciFiSauce");
        digital = GameObject.Find("DigitalSauce");
        target  = GameObject.Find("TargetSauce");

        vendingManager = GameObject.Find("Screen").GetComponent <VendingManager>();
    }
Ejemplo n.º 30
0
    public void Save()
    {
        Load();
        saveObject[length]               = new SaveObject();
        saveObject[length].id            = length;
        saveObject[length].score         = 0;
        saveObject[length].teleportCount = 0;
        saveObject[length].distance      = 0;
        saveObject[length].height        = System.Math.Round(float.Parse(heightText.text), 2);
        saveObject[length].group         = groupDropdown.options[groupDropdown.value].text;
        saveObject[length].gender        = genderDropdown.options[genderDropdown.value].text;


        string json = JsonHelper.ToJson(saveObject);

        File.WriteAllText(Application.dataPath + "/save.txt", json);
        PlayerPrefs.SetInt("score", 0);
        PlayerPrefs.SetInt("triggerCount", 0);
        PlayerPrefs.SetInt("distance", 0);
        PlayerPrefs.SetString("group", groupDropdown.options[groupDropdown.value].text);
        PlayerPrefs.SetInt("preTest", 1);
        //PlayerPrefs.SetFloat("playerHeight", System.Math.Round(float.Parse(heightText.text), 2));
        SceneManager.LoadScene("Training");
    }
Ejemplo n.º 31
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            var saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.RestoreDirectory = true;

            if (saveFileDialog1.ShowDialog() != true) return;
            var toSave = new SaveObject(recordingDuration, timesForNote, textBackup, saveFileDialog1.FileName + "\\recording.wav");
            Directory.CreateDirectory(saveFileDialog1.FileName);
            Stream stream = File.Open(saveFileDialog1.FileName+"\\data", FileMode.Create);
            var bFormatter = new BinaryFormatter();
            bFormatter.Serialize(stream, toSave);
            stream.Close();
            File.Move(savedRecordingAs+".wav", saveFileDialog1.FileName + "\\recording.wav");
        }
Ejemplo n.º 32
0
 public void add(SaveObject toAdd)
 {
     Array.Resize(ref saveArray, saveArray.Length + 1);
     saveArray[saveArray.Length - 1] = toAdd;
 }
Ejemplo n.º 33
0
    //This method should be called when you want to save the object. For example, OnDestroy()
    public static void SaveObjectState(string Name,SaveObject.States State)
    {
        //When we add and object, fist we try to find it on the current list to avoid duplicity errors
        bool Finded = false;
        foreach (SaveObject savedObject in LevelList)
        {
            if(savedObject.Name == Name && savedObject.Level == Application.loadedLevel)
            {
                Finded = true;
                savedObject.State = State;
                break;
            }
        }
        if(!Finded)
        {
            //No finded on the list, so add it
            int Level = Application.loadedLevel;
            SaveObject newSaveObject = new SaveObject(Name,State,Level);

            LevelList.Add(newSaveObject);
        }
    }
Ejemplo n.º 34
0
 // This method is used on LoadLevel
 // Used to read all the data stored on PlayerPrefabs and return SaveObjects
 public static SaveObject[] LoadLevelFromDisk(int Level)
 {
     if (PlayerPrefs.HasKey(Level.ToString()))
     {
         string[] stringArray = PlayerPrefs.GetString(CurrentUser + Level.ToString()).Split("|"[0]);
         SaveObject[] SaveObjectArray = new SaveObject[stringArray.Length/3];
         if(stringArray.Length/3 > 0)
         {
             int objectIndex = 0;
             int SavedObjectArrayIndex = -1;
             for (int i = 0; i < stringArray.Length; i++)
             {
                 if(objectIndex == 0)
                 {
                     SavedObjectArrayIndex++;
                     SaveObjectArray[SavedObjectArrayIndex] = new SaveObject("0",SaveObject.States.Active,0);
                     SaveObjectArray[SavedObjectArrayIndex].Name = stringArray[i];
                     objectIndex = 1;
                 }
                 else if(objectIndex == 1)
                 {
                     if(stringArray[i] == "Active")
                     {
                         SaveObjectArray[SavedObjectArrayIndex].State = SaveObject.States.Active;
                     }
                     else if(stringArray[i] == "Destroyed")
                     {
                         SaveObjectArray[SavedObjectArrayIndex].State = SaveObject.States.Destroyed;
                     }
                     objectIndex = 2;
                 }
                 else if(objectIndex == 2)
                 {
                     SaveObjectArray[SavedObjectArrayIndex].Level = Convert.ToInt32(stringArray[i]);
                     objectIndex = 0;
                 }
             }
             return SaveObjectArray;
         }
     }
     return new SaveObject[0];
 }
Ejemplo n.º 35
0
 void Awake()
 {
     myTarget = (SaveObject)target;
     nextLoad = SaveObject.saveName;
     resetChange();
 }
Ejemplo n.º 36
0
        public Map1()
            : base(100)
        {
            var saveObject1 = new SaveObject(new Point(1408, 480)).AddTo(this);
            var saveObject2 = new SaveObject(new Point(3744, 448)).AddTo(this);
            var saveObject3 = new SaveObject(new Point(2560, 224)).AddTo(this);
            var saveObject4 = new SaveObject(new Point(5376, 224)).AddTo(this);

            var eringi1 = new MotionlessKiller(new Point(448, 224),Skin.EringiUp).AddTo(this);
            var eringi2 = new MotionlessKiller(new Point(800, 480),Skin.EringiUp).AddTo(this);
            var eringi3 = new MotionlessKiller(new Point(1536,288),Skin.EringiUp).AddTo(this);
            var eringi4 = new MotionlessKiller(new Point(1696, 544),Skin.EringiUp).AddTo(this);
            var eringi5 = new MotionlessKiller(new Point(1728,544),Skin.EringiUp).AddTo(this);
            var eringi6 = new MotionlessKiller(new Point(2496,544),Skin.EringiUp).AddTo(this);
            var eringi7 = new LongEringi(new Point(2560,416)).AddTo(this);
            var eringi8 = new EringiDown(new Point(896,352)).AddTo(this);
            var eringi9 = new EringiLeft(new Point(1440,352)).AddTo(this);
            var eringi10 = new EringiRight(new Point(1984,192)).AddTo(this);
            var eringi13 = new EringiDown(new Point(1760,0)).AddTo(this);
            var eringi14 = new EringiDown(new Point(1792, 0)).AddTo(this);
            var eringi15 = new EringiDown(new Point(1824, 0)).AddTo(this);
            var eringi16 = new MotionlessKiller(new Point(4544, 480), Skin.EringiUp).AddTo(this);
            var eringi17 = new MotionlessKiller(new Point(3870,224), Skin.LongEringiTrap01).AddTo(this);

            var siratama1 = new Siratama(new Point(1184, 352)).AddTo(this);

            var invisBlock1 = new InvisibleBlock(new Point(0, 64)).AddTo(this);
            var invisBlock2 = new InvisibleBlock(new Point(0, 96)).AddTo(this);
            var invisBlock3 = new InvisibleBlock(new Point(0, 128)).AddTo(this);
            var invisBlock4 = new InvisibleBlock(new Point(0, 160)).AddTo(this);
            var invisBlock5 = new InvisibleBlock(new Point(4292, 64)).AddTo(this);
            var invisBlock6 = new InvisibleBlock(new Point(4292, 96)).AddTo(this);
            var invisBlock7 = new InvisibleBlock(new Point(4292, 128)).AddTo(this);
            var invisBlock8 = new InvisibleBlock(new Point(5056, 448)).AddTo(this);
            var invisBlock9 = new InvisibleBlock(new Point(5088, 448)).AddTo(this);

            var motionEringi1 = new MotionKiller(new Point(2304,383),new Point(2464,320),new Size(32,64),5,0,Skin.EringiUp).AddTo(this);
            var motionEringi2 = new MotionKiller(new Point(4193, 224), new Point(4192, 192), new Size(101, 32), 0, 15, Skin.EringiUp).AddTo(this);
            var motionEringi3 = new MotionKiller(new Point(4226, 224), new Point(4192, 192), new Size(101, 32), 0, 15, Skin.EringiUp).AddTo(this);
            var motionEringi4 = new MotionKiller(new Point(4259, 224), new Point(4192, 192), new Size(101, 32), 0, 15, Skin.EringiUp).AddTo(this);
            var motionEringi5 = new MotionKiller(new Point(4736,481), new Point(4896,480), new Size(32,32), 6, 0,Skin.EringiUp).AddTo(this);
            var motionEringi6 = new MotionKiller(new Point(3903,224), new Point(3904,320), new Size(32,32), 0, 5, Skin.LongEringiTrap02).AddTo(this);

            //var vanEringi1 = new VanishKiller(new Point(224,160),new Point(128,96), new Size(32,32),Skin.EringiUp ).AddTo(this);
            var vanEringi2 = new VanishKiller(new Point(2144,480), new Point(2336,320), new Size(32,96), Skin.EringiUp).AddTo(this);
            var vanEringi3 = new VanishKiller(new Point(2144, 416), new Point(2336, 320), new Size(32, 96), Skin.EringiDown).AddTo(this);
            var vanEringi4 = new VanishKiller(new Point(2144,192), new Point(1952,256), new Size(32,96), Skin.LongEringiDown).AddTo(this);
            var vanEringi5 = new VanishKiller(new Point(2144, 288), new Point(1952, 256), new Size(32, 96), Skin.LongEringiUp).AddTo(this);

            //var clearObject1 = new ClearObject(new Point(6016,192)).AddTo(this);

            var floor1 = new Rock1(new Point(0,0), new Size(736, 64)).AddTo(this);
            var floor2 = new Rock1(new Point(0,192), new Size(256, 416)).AddTo(this);
            var floor3 = new Rock1(new Point(352,256),new Size(224,352) ).AddTo(this);
            var floor4 = new Rock1(new Point(704,512), new Size(320, 96)).AddTo(this);
            var floor5 = new Rock1(new Point(736,0),new Size(256,352) ).AddTo(this);
            var floor6 = new Rock1(new Point(1024,416),new Size(32,192) ).AddTo(this);
            var floor7 = new Rock1(new Point(1056,384),new Size(256,224) ).AddTo(this);
            var floor8 = new Rock1(new Point(1312,416),new Size(32,192) ).AddTo(this);
            var floor9 = new Rock1(new Point(1344,512),new Size(352,96) ).AddTo(this);
            var floor10 = new Rock1(new Point(992,0),new Size(224,192) ).AddTo(this);
            var floor11 = new Rock1(new Point(1216,0),new Size(192,192) ).AddTo(this);
            var floor12 = new Rock1(new Point(1408,0),new Size(64,352) ).AddTo(this);
            var floor13 = new Rock1(new Point(1504,256),new Size(32,160) ).AddTo(this);
            var floor14 = new Rock1(new Point(1536,320),new Size(224,96) ).AddTo(this);
            var floor15 = new Rock1(new Point(1472,192),new Size(32,224) ).AddTo(this);
            var floor16 = new Rock1(new Point(1472,0),new Size(288,64) ).AddTo(this);
            var floor17 = new Rock1(new Point(1760,512),new Size(64,96) ).AddTo(this);
            var floor18 = new Rock1(new Point(1824,448),new Size(32,160) ).AddTo(this);
            var floor19 = new Rock1(new Point(1856,384),new Size(32,224) ).AddTo(this);
            var floor20 = new Rock1(new Point(1888,128),new Size(64,480) ).AddTo(this);
            var floor21 = new Rock1(new Point(1600,128),new Size(288,96) ).AddTo(this);
            var floor22 = new Rock1(new Point(1952,128),new Size(32,128) ).AddTo(this);
            var floor23 = new Rock1(new Point(1952,352),new Size(32,256) ).AddTo(this);
            var floor24 = new Rock1(new Point(1984,416),new Size(32,192) ).AddTo(this);
            //var floor25 = new Rock1(new Point(2016,448),new Size(32,160) ).AddTo(this);
            var floor26 = new Rock1(new Point(2016,512),new Size(160,96) ).AddTo(this);
            var floor27 = new Rock1(new Point(1984,128),new Size(224,64) ).AddTo(this);
            var floor28 = new Rock1(new Point(2080,352),new Size(96,64) ).AddTo(this);
            var floor29 = new Rock1(new Point(2304,416),new Size(160,64) ).AddTo(this);
            var floor30 = new Rock1(new Point(2176,576),new Size(352,32) ).AddTo(this);
            var floor31 = new Rock1(new Point(2304,256),new Size(256,64) ).AddTo(this);
            var floor32 = new Rock1(new Point(2528,480),new Size(64,128) ).AddTo(this);
            var floor33 = new Rock1(new Point(2560,256),new Size(32,96) ).AddTo(this);
            var floor34 = new Rock1(new Point(1856,0),new Size(160,64) ).AddTo(this);
            var floor35 = new Rock1(new Point(2016,0),new Size(256,32) ).AddTo(this);
            var floor36 = new Rock1(new Point(2272,0),new Size(224,160) ).AddTo(this);
            var floor37 = new Rock1(new Point(2496,0),new Size(224,160) ).AddTo(this);
            var floor38 = new Rock1(new Point(2720,0),new Size(224,160) ).AddTo(this);
            var floor39 = new Rock1(new Point(2944,0),new Size(224,160) ).AddTo(this);
            var floor40 = new Rock1(new Point(3168,0),new Size(224,160) ).AddTo(this);
            var floor41 = new Rock1(new Point(2912,256),new Size(192,352) ).AddTo(this);
            var floor42 = new Rock1(new Point(3104,256),new Size(32,96) ).AddTo(this);
            var floor43 = new Rock1(new Point(3360,480),new Size(32,32) ).AddTo(this);
            //var floor44 = new Rock1(new Point(3456,480),new Size(32,32) ).AddTo(this);
            var floor45 = new Rock1(new Point(3648,480),new Size(192,128) ).AddTo(this);
            var floor46 = new Rock1(new Point(3840, 416), new Size(32, 192)).AddTo(this);
            var floor47 = new Rock1(new Point(3872,352),new Size(64,256) ).AddTo(this);
            var floor48 = new Rock1(new Point(3392,0),new Size(192,320) ).AddTo(this);
            var floor49 = new Rock1(new Point(3584,0),new Size(192,320) ).AddTo(this);
            var floor50 = new Rock1(new Point(3776,256),new Size(32,64) ).AddTo(this);
            var floor51 = new Rock1(new Point(3776,0),new Size(320,64) ).AddTo(this);
            var floor52 = new Rock1(new Point(4096,0),new Size(320,64) ).AddTo(this);
            var floor53 = new Rock1(new Point(3872,160),new Size(64,64) ).AddTo(this);
            var floor54 = new Rock1(new Point(3936,160),new Size(64,448) ).AddTo(this);
            var floor55 = new Rock1(new Point(4000,160),new Size(192,96) ).AddTo(this);
            var floor56 = new Rock1(new Point(4064,352),new Size(128,96) ).AddTo(this);
            var floor57 = new Rock1(new Point(4292,160),new Size(64,96) ).AddTo(this);
            var floor58 = new Rock1(new Point(4000,512),new Size(576,96) ).AddTo(this);
            var floor78 = new Rock1(new Point(4192, 416), new Size(128, 32)).AddTo(this);
            var floor60 = new Rock1(new Point(4416,0),new Size(64,448) ).AddTo(this);
            var floor59 = new Rock1(new Point(4292, 352), new Size(128, 96)).AddTo(this);
            var floor61 = new Rock1(new Point(4480,0),new Size(128,288) ).AddTo(this);
            var floor62 = new Rock1(new Point(4608,0),new Size(224,288) ).AddTo(this);
            var floor63 = new Rock1(new Point(4576,448),new Size(32,160)).AddTo(this);
            var floor64 = new Rock1(new Point(4704,448),new Size(32,160) ).AddTo(this);
            var floor65 = new Rock1(new Point(4608,384),new Size(96,224) ).AddTo(this);
            var floor66 = new Rock1(new Point(4736,514),new Size(608,96)).AddTo(this);
            var floor67 = new Rock1(new Point(4832,0),new Size(224,480) ).AddTo(this);
            var floor68 = new Rock1(new Point(5056,0),new Size(64,384)).AddTo(this);
            var floor69 = new Rock1(new Point(5120,0),new Size(128,480) ).AddTo(this);
            var floor70 = new Rock1(new Point(5248,352),new Size(32,64) ).AddTo(this);
            var floor71 = new Rock1(new Point(5248,0),new Size(320,160) ).AddTo(this);
            var floor72 = new Rock1(new Point(5344,448), new Size(32, 160)).AddTo(this);
            var floor73 = new Rock1(new Point(5376,256),new Size(256,352) ).AddTo(this);
            var floor74 = new Rock1(new Point(5344,256),new Size(32,64) ).AddTo(this);
            var floor75 = new Rock1(new Point(5792,256),new Size(288,352) ).AddTo(this);
            var floor76 = new Rock1(new Point(2592,256),new Size(64,352) ).AddTo(this);
            var floor77 = new Rock1(new Point(1696,576),new Size(64,32) ).AddTo(this);

            var eringi11 = new MotionlessKiller(new Point(1792,160), Skin.EringiUp).AddTo(this);
            var eringi12 = new MotionlessKiller(new Point(1824, 160), Skin.EringiUp).AddTo(this);
            var vanfloor1 = new VanishBlock(new Point(1696, 512), new Size(64, 32)).AddTo(this);
            var vanfloor2 = new VanishBlock(new Point(1760,0),new Size(96,64) ).AddTo(this);

            var movingfloor1 = new MovingFloor(new Point(2726,256)).AddTo(this);
            var movingfloor2 = new MovingFloor(new Point(3136, 480),true).AddTo(this);
            var movingfloor3 = new MovingFloor(new Point(3456, 480)).AddTo(this);
            var boss = new Boss(new Point(6316, 92)).AddTo(this);
            UpdateElement();
        }