예제 #1
0
 public PuzzleCache()
 {
     if (current == null)
     {
         current = this;
     }
 }
예제 #2
0
    public void Read()
    {
        PuzzleCache puzzleCache = new PuzzleCache();
        string      root        = "//SaveGame";

        XmlNodeList node_Puzzles = m_Doc.SelectNodes(root + "/Puzzle");

        puzzleCache.Length = node_Puzzles.Count;
        puzzleCache.SetDefault();

        for (int i = 0; i < node_Puzzles.Count; i++)
        {
            puzzleCache.puzzles[i].num     = (int)XmlConvert.ToDouble(((XmlElement)node_Puzzles[i]).GetAttribute("num"));
            puzzleCache.puzzles[i].stars   = (int)XmlConvert.ToDouble(((XmlElement)node_Puzzles[i]).GetAttribute("stars"));
            puzzleCache.puzzles[i].time    = (float)XmlConvert.ToDouble(((XmlElement)node_Puzzles[i]).GetAttribute("time"));
            puzzleCache.puzzles[i].blocked = XmlConvert.ToBoolean(((XmlElement)node_Puzzles[i]).GetAttribute("blocked"));
        }
    }
예제 #3
0
    public void Start()
    {
        m_Animator = GetComponent <Animator>();

//		char dash = Path.DirectorySeparatorChar;
//		string dataPath = Path.GetDirectoryName(Application.dataPath);
//		string folderPath = dataPath + dash + "SaveGame";
//		string filePath = folderPath + dash + "Settings.xml";
//
//		DirectoryInfo dir = new DirectoryInfo(folderPath);
//		if (!dir.Exists) dir.Create();
//
//		XmlReaderOptions xmlReader = new XmlReaderOptions(filePath);
//
//		if (xmlReader.IsLoaded)
//		{
//			option = xmlReader.Read();
//
//			// Set Audio
//			mainMixer.SetFloat("musicVol", option.musicVol);
//			mainMixer.SetFloat("sfxVol", option.sfxVol);
//
//			// Set Resolution
//			int separator = option.resolution.LastIndexOf('x');
//			int width = int.Parse(option.resolution.Substring(0, separator));
//			int height = int.Parse(option.resolution.Substring(separator + 1));
//
//			Screen.SetResolution(width, height, option.fullscreen);
//		}
//		else
//		{
//			option = new OptionCache();
//			option.SetDefault();
//
//			// Set Audio
//			mainMixer.SetFloat("musicVol", option.musicVol);
//			mainMixer.SetFloat("sfxVol", option.sfxVol);
//
//			// Set Resolution
//			int separator = option.resolution.LastIndexOf('x');
//			int width = int.Parse(option.resolution.Substring(0, separator));
//			int height = int.Parse(option.resolution.Substring(separator + 1));
//			Screen.SetResolution(width, height, option.fullscreen);
//		}

        PerlipManager.Open();

        if (PerlipManager.settingsLip.HasKey("Option"))
        {
            option = PerlipManager.settingsLip.GetValue <OptionCache>("Option");

            // Set Audio
            mainMixer.SetFloat("musicVol", option.musicVol);
            mainMixer.SetFloat("sfxVol", option.sfxVol);

            // Set Resolution
            int separator = option.resolution.LastIndexOf('x');
            int width     = int.Parse(option.resolution.Substring(0, separator));
            int height    = int.Parse(option.resolution.Substring(separator + 1));

            Screen.SetResolution(width, height, option.fullscreen);
        }
        else
        {
            option = new OptionCache();
            option.SetDefault();

            PerlipManager.settingsLip.SetValue("Option", option);
            PerlipManager.settingsLip.Save();

            // Set Audio
            mainMixer.SetFloat("musicVol", option.musicVol);
            mainMixer.SetFloat("sfxVol", option.sfxVol);

            // Set Resolution
            int separator = option.resolution.LastIndexOf('x');
            int width     = int.Parse(option.resolution.Substring(0, separator));
            int height    = int.Parse(option.resolution.Substring(separator + 1));

            Screen.SetResolution(width, height, option.fullscreen);
        }

        if (PerlipManager.saveGameLip.HasKey("Puzzle0"))
        {
            PuzzleCache cache = new PuzzleCache();
            cache.puzzles = new PuzzleCache.PuzzleParam[cache.Length];

            for (int i = 0; i < cache.Length; i++)
            {
                cache.puzzles[i] = PerlipManager.saveGameLip.GetValue <PuzzleCache.PuzzleParam>("Puzzle" + i);
            }
        }
        else
        {
            PuzzleCache cache = new PuzzleCache();
            cache.SetDefault();

            for (int i = 0; i < cache.Length; i++)
            {
                PerlipManager.saveGameLip.SetValue("Puzzle" + i, PuzzleCache.current.puzzles[i]);
            }

            PerlipManager.saveGameLip.Save();
        }

        m_Animator.SetTrigger("Show");
        Invoke("GoNextScene", animClip.length);
    }