public void saveMap() { convertToString(); CheckMap cm = new CheckMap(dMap.getMap(), 21, 21); bool temp = cm.isMapAccepted(); Debug.Log("Accepted : " + temp); printDebug(); if (temp) { Debug.Log("if : " + temp); printDebug(); WriteTxt(); MapStatus.getInstance().setIndex(3); SceneManager.LoadScene("LoadingScreen"); CurcorController.cursorCon = false; } else { Debug.Log("else : " + temp); isShown = true; canvas.SetActive(isShown); } }
public void readTxt() { int value = 0, value2 = 0; try { string temp; string path = "Assets/Resources/TextController.txt"; StreamReader theReader = new StreamReader(path, Encoding.Default); using (theReader) { temp = theReader.ReadLine(); //Debug.Log(temp); value = int.Parse(temp); //Debug.Log(value); MapStatus.getInstance().setChoosenMap(value); temp = theReader.ReadLine(); value2 = int.Parse(temp); //Debug.Log(value2); MapStatus.getInstance().setAllStatus(value2); //Debug.Log("MS : " + MapStatus.getInstance().getStatus()); theReader.Close(); } }catch (Exception e) { Console.WriteLine("No Txt"); value = 0; MapStatus.getInstance().setChoosenMap(value); value2 = 0; MapStatus.getInstance().setAllStatus(value2); } //string temp; //int value=0,value2=0; //string path = "Assets/Resources/TextController.txt"; //StreamReader theReader = new StreamReader(path, Encoding.Default); ////StreamReader theReader = new StreamReader(path); //using (theReader) //{ // temp = theReader.ReadLine(); // //Debug.Log(temp); // value = int.Parse(temp); // //Debug.Log(value); // MapStatus.getInstance().setChoosenMap(value); // temp = theReader.ReadLine(); // value2 = int.Parse(temp); // //Debug.Log(value2); // MapStatus.getInstance().setAllStatus(value2); // //Debug.Log("MS : " + MapStatus.getInstance().getStatus()); // theReader.Close(); //} }
public void updateText() { string path = "Assets/Resources/TextController.txt"; StreamWriter writer = new StreamWriter(path, false); writer.WriteLine(MapStatus.getInstance().getChoosenMap()); writer.WriteLine(MapStatus.getInstance().getStatus()); writer.Close(); //AssetDatabase.ImportAsset(path); //TextAsset asset = Resources.Load<TextAsset>("TextController.txt"); }
public void WriteTxt() { string path = ""; string db = "Map"; if (MapStatus.getInstance().isAvailable(1) == false) { path = "Assets/Resources/Map1.txt"; db = db + "1.txt"; MapStatus.getInstance().setStatus(1); MapStatus.getInstance().setChoosenMap(2); } else if (MapStatus.getInstance().isAvailable(2) == false) { path = "Assets/Resources/Map2.txt"; db = db + "2.txt"; MapStatus.getInstance().setStatus(2); MapStatus.getInstance().setChoosenMap(3); } else if (MapStatus.getInstance().isAvailable(3) == false) { path = "Assets/Resources/Map3.txt"; db = db + "3.txt"; MapStatus.getInstance().setStatus(3); MapStatus.getInstance().setChoosenMap(4); } else { path = "Assets/Resources/Map1.txt"; db = db + "1.txt"; MapStatus.getInstance().setStatus(1); MapStatus.getInstance().setChoosenMap(2); } TxtController.getInstance().updateText(); StreamWriter writer = new StreamWriter(path, false); for (int i = 0; i < 21; i++) { writer.WriteLine(mapstr[i]); } writer.Close(); //AssetDatabase.ImportAsset(path); //TextAsset asset = Resources.Load<TextAsset>(db); }
//private float lastTimer = 0; //private float timer = 0; //private void changeText() //{ // UnityEngine.UI.Text change = txt.GetComponent<UnityEngine.UI.Text>(); // //string percentage = (lastTimer-timer)*20 + " %"; // //if((lastTimer- timer)*20 >=100 ) percentage = 100 + " %"; // //change.text = percentage; //} // Use this for initialization void Start() { //timer = Time.time; //lastTimer = Time.time; //txt = GameObject.FindGameObjectWithTag("Txt0"); if (MapStatus.getInstance().getIndex() == 2) { StartCoroutine(loadingAsyn.Loading(2)); //SceneManager.LoadScene("DesignMap"); } if (MapStatus.getInstance().getIndex() == 3) { StartCoroutine(loadingAsyn.Loading(0)); //SceneManager.LoadScene("MenuScene"); } if (MapStatus.getInstance().getIndex() == 1) { StartCoroutine(loadingAsyn.Loading(1)); //SceneManager.LoadScene("GameScene"); } }
void Update() { DisplayMap.map.coor[playerRow, playerCol].value = DesignController.FLOOR; playerRow = Mathf.RoundToInt(transform.position.x); playerCol = Mathf.RoundToInt(transform.position.z); //Debug.Log(playerX + "dan y : " + playerY); DisplayMap.map.coor[playerRow, playerCol].value = DesignController.PLAYER; //Debug.Log(DisplayMap.map.coor[2, 9].value); //Map.getSpot(playerY, playerX)= DesignController.PLAYER; UnityEngine.UI.Text change = txt.GetComponent <UnityEngine.UI.Text>(); change.text = "Health : " + health; if (health <= 0) { isDeath = true; } moveY += 2 * Input.GetAxis("Mouse X"); moveX -= 2 * Input.GetAxis("Mouse Y"); transform.eulerAngles = new Vector3(moveX, moveY, 0); if (Input.GetKey(KeyCode.W)) { //animator.SetBool("isWalk", true); if (Input.GetKey(KeyCode.LeftShift)) { transform.Translate(new Vector3(0, 0, Time.deltaTime * 2f)); } transform.Translate(new Vector3(0, 0, Time.deltaTime * 4f)); } if (Input.GetKey(KeyCode.A)) { //animator.SetBool("isWalk", true); if (Input.GetKey(KeyCode.LeftShift)) { transform.Translate(new Vector3(Time.deltaTime * -2f, 0, 0)); } transform.Translate(new Vector3(Time.deltaTime * -4f, 0, 0)); } if (Input.GetKey(KeyCode.S)) { //animator.SetBool("isWalk", true); if (Input.GetKey(KeyCode.LeftShift)) { transform.Translate(new Vector3(0, 0, Time.deltaTime * -2f)); } transform.Translate(new Vector3(0, 0, Time.deltaTime * -4f)); } if (Input.GetKey(KeyCode.D)) { //animator.SetBool("isWalk", true); if (Input.GetKey(KeyCode.LeftShift)) { transform.Translate(new Vector3(Time.deltaTime * 2f, 0, 0)); } transform.Translate(new Vector3(Time.deltaTime * 4f, 0, 0)); } if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.D)) { //animator.SetBool("isWalk", false); } if (Input.GetKey(KeyCode.Space)) { transform.Translate(new Vector3(0, Time.deltaTime * 4f, 0)); } if (Input.GetKey(KeyCode.Escape)) { DisplayMap.removeEnemy(DisplayMap.xRand, DisplayMap.yRand); DisplayMap.removeTreasure(DisplayMap.xTRand, DisplayMap.yTRand); MapStatus.getInstance().setToPlay(false); if (MapStatus.getInstance().getChoosenMap() == 1) { MapStatus.getInstance().setChoosenMap(0); } TxtController.getInstance().updateText(); SceneManager.LoadScene("MenuScene"); } }