// Use this for initialization void Awake() { if (!Directory.Exists(DataPool.path())) { Directory.CreateDirectory(DataPool.path()); } if (!Directory.Exists(DataPool.patho())) { Directory.CreateDirectory(DataPool.patho()); } if (!Directory.Exists(DataPool.pathp())) { Directory.CreateDirectory(DataPool.pathp()); } if (!GameObject.Find("Options")) { Instantiate(optionsOb); GameObject.Find("Options(Clone)").name = "Options"; } GameObject.Find("Options").GetComponent <Options>().LoadOptions(); if (!File.Exists(DataPool.optionPath())) { Options optionsObj = GameObject.Find("Options").GetComponent <Options>(); OptionsClass options = new OptionsClass(optionsObj.soundVolume, optionsObj.musicVolume, optionsObj.mute); options.Save(); } }
private Options readOptions() { try { string asmDir = Path.GetDirectoryName(Application.StartupPath); string cfgFile = Path.Combine(Application.StartupPath, "dsv.cfg"); using (StreamReader sr = new StreamReader(cfgFile)) { Options opt = new OptionsClass(); while (!sr.EndOfStream) { string line = sr.ReadLine().Trim(); if (line != "") { string[] values = line.Split('='); switch (values[0]) { case "ncycles": opt.cycles = uint.Parse(values[1]); break; case "nsteps": opt.steps = uint.Parse(values[1]); break; case "nIterations": opt.iterations = int.Parse(values[1]); break; case "temperature": opt.temperature = double.Parse(values[1]); break; case "minTemperature": opt.minTemperature = double.Parse(values[1]); break; case "reduction": opt.reduction = double.Parse(values[1]); break; case "xpos": opt.weightingX = double.Parse(values[1]); break; case "ypos": opt.weightingY = double.Parse(values[1]); break; case "direction": opt.weightingDirection = double.Parse(values[1]); break; case "curvature": opt.weightingCurvature = double.Parse(values[1]); break; case "unlinked": opt.weightingUnlinked = double.Parse(values[1]); break; case "removelink": opt.removeLink = double.Parse(values[1]); break; case "linkRange": opt.linkRange = double.Parse(values[1]); break; default: throw new Exception("Unknown option value"); } } } return(opt); } } catch (Exception) { } return(null); }
public static void LoadOptions() { if (!OptionList.ContainsKey("Options.xml")) { OptionsClass tmp = OptionsClass.Load(); OptionList.Add("Options.xml", tmp); } }
// Update is called once per frame void FixedUpdate() { int choice = 0; if (Input.GetKeyDown(KeyCode.Alpha5) && topLeft.GetComponent <GUIText>().text != "") //GetKeyDown functions that runs one of the invoke functions and turns the three other sprite renderers off { Invoke("deactivateQuestionScreen", timeout); botRight.GetComponent <GUIText>().enabled = false; botLeft.GetComponent <GUIText>().enabled = false; topRight.GetComponent <GUIText>().enabled = false; choice = 1; } if (Input.GetKeyDown(KeyCode.Alpha6) && topRight.GetComponent <GUIText>().text != "") { Invoke("deactivateQuestionScreen", timeout); botRight.GetComponent <GUIText>().enabled = false; botLeft.GetComponent <GUIText>().enabled = false; topLeft.GetComponent <GUIText>().enabled = false; choice = 2; } if (Input.GetKeyDown(KeyCode.Alpha7) && botRight.GetComponent <GUIText>().text != "") { Invoke("deactivateQuestionScreen", timeout); topLeft.GetComponent <GUIText>().enabled = false; botLeft.GetComponent <GUIText>().enabled = false; topRight.GetComponent <GUIText>().enabled = false; choice = 3; } if (Input.GetKeyDown(KeyCode.Alpha8) && botLeft.GetComponent <GUIText>().text != "") { Invoke("deactivateQuestionScreen", timeout); botRight.GetComponent <GUIText>().enabled = false; topLeft.GetComponent <GUIText>().enabled = false; topRight.GetComponent <GUIText>().enabled = false; choice = 4; } if (choice != 0) { question.GetComponent <GUIText>().enabled = false; action.GetComponent <GUIText>().text = OptionsClass.performActions(choice); } if (Input.GetKeyDown(KeyCode.Space)) //test func that makes all GUI texts appear on screen { botRight.GetComponent <GUIText>().enabled = true; botLeft.GetComponent <GUIText>().enabled = true; topLeft.GetComponent <GUIText>().enabled = true; topRight.GetComponent <GUIText>().enabled = true; question.GetComponent <GUIText>().enabled = true; action.GetComponent <GUIText>().enabled = true; optionBackground.GetComponent <SpriteRenderer>().enabled = true; } }
public static OptionsClass Load() { string Path = DataPool.optionPath(); OptionsClass container; var serializer = new XmlSerializer(typeof(OptionsClass)); if (File.Exists(Path)) { var stream = new FileStream(Path, FileMode.Open); container = serializer.Deserialize(stream) as OptionsClass; stream.Close(); container.Save(); } else { container = new OptionsClass(); container.Save(); } return(container); }
// Update is called once per frame void FixedUpdate() { //Constantly move player to the desired position with movement speed. Vector2 vectorToDesiredPoint = desiredPosition - new Vector2(transform.position.x, transform.position.y); if (vectorToDesiredPoint.magnitude > 0.1f) { playerRigidbody.velocity = vectorToDesiredPoint; playerRigidbody.velocity = playerRigidbody.velocity.normalized * movementSpeed; int angle = (int)Helpfunctions.getAngle(vectorToDesiredPoint, new Vector2(0, 0)) + 90; if (angle > 180 - 45 && angle < 180 + 45) { movingInDirection = 1; //right } else if (angle > 0 - 45 && angle < 0 + 45) { movingInDirection = 2; //left } else if (angle > 270 - 45 && angle < 270 + 45) { movingInDirection = 3; //up } else if (angle > 90 - 45 && angle < 90 + 45) { movingInDirection = 4; //down } animator.SetInteger("direction", movingInDirection); } else { movingInDirection = 0; animator.SetInteger("direction", movingInDirection); playerRigidbody.velocity = Vector2.zero; OptionsClass.getChoices(); } }
public void SaveOptions() { OptionsClass options = new OptionsClass(this.soundVolume, this.musicVolume, this.mute); options.Save(); }
public PointToPoint() { _p2pStruct = P2P_Create(); _options = new OptionsClass(_p2pStruct); _impedances = new ImpedanceSet(_p2pStruct, NbFreq); _path = new Path(); }