Beispiel #1
0
    public void OnEnable()
    {
//		char separator = Path.DirectorySeparatorChar;
//		string dataPath = Path.GetDirectoryName(Application.dataPath);
//		string filePath = dataPath + separator + "SaveGame" + separator + "Settings.xml";
//
//		XmlReaderOptions xmlReader = new XmlReaderOptions(filePath);
//
//		if (xmlReader.IsLoaded)
//		{
//			OptionCache option = xmlReader.Read();
//
//			musicVolOption.value = option.musicVol;
//			sfxVolOption.value = option.sfxVol;
//			resolutionOption.index = option.resIndex;
//			fullscreenOption.isOn = option.fullscreen;
//
//			Debug.Log("Readed Xml options");
//		}
//		else
//		{
//			Debug.Log("Not readed Xml options");
//		}

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

        musicVolOption.value   = option.musicVol;
        sfxVolOption.value     = option.sfxVol;
        resolutionOption.index = option.resIndex;
        fullscreenOption.isOn  = option.fullscreen;
    }
    public OptionCache Read()
    {
        OptionCache option = new OptionCache();

        string root = "//Settings";

        XmlNode node_MusicVol = m_Doc.SelectSingleNode(root + "/MusicVol");

        option.musicVol = (float)XmlConvert.ToDouble(node_MusicVol.InnerXml);

        XmlNode node_SfxVol = m_Doc.SelectSingleNode(root + "/SfxVol");

        option.sfxVol = (float)XmlConvert.ToDouble(node_SfxVol.InnerXml);

        XmlNode node_Resolution = m_Doc.SelectSingleNode(root + "/Resolution");

        option.resolution = node_Resolution.InnerXml;
        option.resIndex   = (int)XmlConvert.ToDouble(((XmlElement)node_Resolution).GetAttribute("index"));

        XmlNode node_Fullscreen = m_Doc.SelectSingleNode(root + "/Fullscreen");

        option.fullscreen = XmlConvert.ToBoolean(node_Fullscreen.InnerXml);

        XmlNode node_Tutorial = m_Doc.SelectSingleNode(root + "/Tutorial");

        option.tutorial = XmlConvert.ToBoolean(node_Tutorial.InnerXml);

        return(option);
    }
Beispiel #3
0
    public void Write(OptionCache option)
    {
        XmlElement elem_MusicVol = m_Doc.CreateElement("MusicVol");

        elem_MusicVol.InnerText = option.musicVol.ToString();
        m_Root.AppendChild(elem_MusicVol);

        XmlElement elem_SfxVol = m_Doc.CreateElement("SfxVol");

        elem_SfxVol.InnerText = option.sfxVol.ToString();
        m_Root.AppendChild(elem_SfxVol);

        XmlElement elem_Resolution = m_Doc.CreateElement("Resolution");

        elem_Resolution.SetAttribute("index", option.resIndex.ToString());
        elem_Resolution.InnerText = option.resolution;
        m_Root.AppendChild(elem_Resolution);

        XmlElement elem_Fullscreen = m_Doc.CreateElement("Fullscreen");

        elem_Fullscreen.InnerText = option.fullscreen.ToString().ToLower();
        m_Root.AppendChild(elem_Fullscreen);

        XmlElement elem_Tutorial = m_Doc.CreateElement("Tutorial");

        elem_Tutorial.InnerText = option.tutorial.ToString().ToLower();
        m_Root.AppendChild(elem_Tutorial);
    }
    public void SaveSettings()
    {
//		char dash = Path.DirectorySeparatorChar;
//		string dataPath = Path.GetDirectoryName(Application.dataPath);
//		string folderPath = dataPath + dash + "SaveGame";
//		string filePath = folderPath + dash + "Settings.xml";
//
//		XmlReaderOptions xmlReader = new XmlReaderOptions(filePath);
//
//		if (xmlReader.IsLoaded)
//		{
//			OptionCache option = xmlReader.Read();
//			option.tutorial = true;
//
//			XmlWriterOptions xmlWrite = new XmlWriterOptions(filePath);
//			xmlWrite.Write(option);
//			xmlWrite.Save();
//		}
//		else
//		{
//			OptionCache option = new OptionCache();
//			option.SetDefault();
//			option.tutorial = true;
//
//			XmlWriterOptions xmlWrite = new XmlWriterOptions(filePath);
//			xmlWrite.Write(option);
//			xmlWrite.Save();
//		}

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

        option.tutorial = true;

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

        Application.LoadLevel("Menu");
    }
Beispiel #5
0
    public void Apply()
    {
        int  width      = resolutionOption.width;
        int  height     = resolutionOption.height;
        bool fullscreen = fullscreenOption.isOn;

//		char separator = Path.DirectorySeparatorChar;
//		string dataPath = Path.GetDirectoryName(Application.dataPath);
//		string folderPath = dataPath + separator + "SaveGame";
//		string filePath = folderPath + separator + "Settings.xml";

        OptionCache option = new OptionCache();

        option.musicVol   = musicVolOption.value;
        option.sfxVol     = sfxVolOption.value;
        option.resolution = resolutionOption.currentElem;
        option.resIndex   = resolutionOption.index;
        option.fullscreen = fullscreen;
        option.tutorial   = true;

//		DirectoryInfo dir = new DirectoryInfo(folderPath);
//		if (!dir.Exists) dir.Create();
//
//		XmlWriterOptions xmlWrite = new XmlWriterOptions(filePath);
//		xmlWrite.Write(option);
//		xmlWrite.Save();

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

        Screen.SetResolution(width, height, fullscreen);

        Debug.Log("Set Options -> MusicVol(" + musicVolOption.value +
                  "), SfxVol(" + sfxVolOption.value +
                  "), Resolution(" + width + "x" + height + ":" + resolutionOption.index +
                  "), Fullscreen(" + fullscreen + ")");
    }
Beispiel #6
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);
    }