private void randomEncounter() { //This function facilitates random encounters. I'd rather do overworld encounters, but for the sake of time we in this shit Debug.Log("Being random encounter function"); if (encounterLimiter != 40) { encounterLimiter++; //This is the best tool to control encounter rate for some reason return; } int encounterGen = Random.Range(0, 100); Debug.Log(encounterGen); int encounterRate = 20; // set high for testing sake if (encounterGen < encounterRate) { Player playerScript = this.GetComponent <Player> (); GameManager.instance.SaveState(); string sceneName = "battlescene"; inBattle = true; int whichEnemy = Random.Range(1, 1); InfoTransition.setEnemyName(demoEnemyList[whichEnemy]); //This will be changed to randomly draw from a document with encounter data Scene scene = SceneManager.GetActiveScene(); InfoTransition.setSceneName(scene.name); InfoTransition.setPosition(playerScript.transform.position.x, playerScript.transform.position.y); UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName); } encounterLimiter = 0; }
// Update is called once per frame private void Update() { // reset move delta if (SceneManager.GetActiveScene().name != "battlescene") { inBattle = false; } if (!canMove || inBattle || InfoTransition.getInBattle() == 1) { return; } float x = Input.GetAxisRaw("Horizontal"); float y = Input.GetAxisRaw("Vertical"); moveDelta = new Vector3(x, y, 0); if (Input.GetKey("a") || Input.GetKey("d") || Input.GetKey("w") || Input.GetKey("s")) { animator.SetInteger("State", 1); } else { animator.SetInteger("State", 0); } //swap direction for right/left if (moveDelta.x > 0) { transform.localScale = new Vector3(1, 1, 1); Debug.Log("Is this where the random encounter should be"); randomEncounter(); } else if (moveDelta.x < 0) { transform.localScale = new Vector3(-1, 1, 1); Debug.Log("Is this where the random encounter should be"); randomEncounter(); } if (moveDelta.y != 0) { Debug.Log("Is this where the random encounter should be"); randomEncounter(); } hit = Physics2D.BoxCast(transform.position, boxCollider.size, 0, new Vector2(0, moveDelta.y), Mathf.Abs(moveDelta.y * Time.deltaTime), LayerMask.GetMask("Actor", "Blocking")); if (hit.collider == null || hit.collider.tag == "Trigger") { transform.Translate(0, moveDelta.y * Time.deltaTime, 0); } hit = Physics2D.BoxCast(transform.position, boxCollider.size, 0, new Vector2(moveDelta.x, 0), Mathf.Abs(moveDelta.x * Time.deltaTime), LayerMask.GetMask("Actor", "Blocking")); if (hit.collider == null || hit.collider.tag == "Trigger") { transform.Translate(moveDelta.x * Time.deltaTime, 0, 0); } }
public override void OnInteract() { Player playerScript = player.GetComponent <Player>(); if (playerScript.canMove && numMessages == 4) { playerScript.canMove = false; Debug.Log("demo"); txt.text = "This demo is mostly a showing of the tiles we have so far"; canvas.SetActive(true); numMessages--; } else if (numMessages == 3) { txt.text = "It's divided into two distinct areas for the tiles we have"; numMessages--; } else if (numMessages == 2) { txt.text = "As far as systems are concerned, basically everything except the battle system is completed"; numMessages--; } else if (numMessages == 1) { txt.text = "This isn't a lot, but having this base completed will let us build much faster over the next quarter. Enjoy!"; numMessages--; } else if (!playerScript.canMove && numMessages == 0) { canvas.SetActive(false); playerScript.canMove = true; numMessages = 4; Debug.Log("Battle activated"); GameManager.instance.SaveState(); string sceneName = "battlescene"; InfoTransition.setEnemyName("elonmuskrat"); Scene scene = SceneManager.GetActiveScene(); InfoTransition.setSceneName(scene.name); InfoTransition.setPosition(playerScript.transform.position.x, playerScript.transform.position.y); UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName); } //if(Input.GetButtonDown("Cancel")) //playerScript.canMove = true; }
IEnumerator startEnemyTurn() { //Random rnd = new Random(); if (health <= 0) { //Show defeat text General.text = defeat; InfoTransition.setInBattle(0); UnityEngine.SceneManagement.SceneManager.LoadScene(InfoTransition.getSceneName()); Player playerScript = player.GetComponent <Player>(); playerScript.leaveBattle(); float[] position = InfoTransition.getPosition(); playerScript.transform.position = new Vector3(position[0], position[1], 0); // playerScript.transform.position.y = position[1]; } else { int pickMove = Random.Range(0, 3); Debug.Log("enemy Turn"); Debug.Log(pickMove); Debug.Log(enemyPT [pickMove]); General.text = enemyPT [pickMove]; Text indicator = GameObject.Find("Damage Indicator").GetComponent <Text> (); indicator.text = enemyD [pickMove].ToString(); indicator.enabled = true; yield return(new WaitForSeconds(1)); indicator.enabled = false; while (!Input.GetButtonDown("Submit")) { Debug.Log("pp"); yield return(null); } General.enabled = false; Action1.enabled = true; Action2.enabled = true; Action3.enabled = true; Action4.enabled = true; ActionSet.SetActive(true); } }
// Use this for initialization void Start() { InfoTransition.setInBattle(1); internalName = InfoTransition.getEnemyName(); //Figure out how to send this value Debug.Log("give me muskrat or give me death"); SpriteRenderer rndr = GetComponent <SpriteRenderer>(); enemyDoc = XDocument.Load("Assets/Resources/data/enemy-data.xml"); Debug.Log(enemyDoc); items = enemyDoc.Descendants("enemy").Elements(); Debug.Log(items); foreach (var item in items) { Debug.Log("loopy"); Debug.Log(item.Parent.Attribute("internalname").Value.ToString()); Debug.Log(internalName); if (item.Parent.Attribute("internalname").Value.ToString() == internalName) { health = int.Parse(item.Parent.Element("health").Value); Debug.Log("Are we actually entering into the loop or is this a problem of name check?"); name = item.Parent.Element("Name").Value; introText = item.Parent.Element("Intro-Text").Value.Trim(); spriteName = item.Parent.Element("sprite-info").Value.Trim(); Debug.Log("introText"); Debug.Log(spriteName); actions[0] = item.Parent.Element("A1Text").Value.Trim(); actions[1] = item.Parent.Element("A2Text").Value.Trim(); actions[2] = item.Parent.Element("A3Text").Value.Trim(); actions[3] = item.Parent.Element("A4Text").Value.Trim(); performanceText[0] = item.Parent.Element("A1Performance-Text").Value.Trim(); performanceText[1] = item.Parent.Element("A2Performance-Text").Value.Trim(); performanceText[2] = item.Parent.Element("A3Performance-Text").Value.Trim(); performanceText[3] = item.Parent.Element("A4Performance-Text").Value.Trim(); reactionText[0] = item.Parent.Element("A1Reaction-Text").Value.Trim(); reactionText[1] = item.Parent.Element("A2Reaction-Text").Value.Trim(); reactionText[2] = item.Parent.Element("A3Reaction-Text").Value.Trim(); reactionText[3] = item.Parent.Element("A4Reaction-Text").Value.Trim(); damage[0] = int.Parse(item.Parent.Element("A1Damage").Value); damage[1] = int.Parse(item.Parent.Element("A2Damage").Value); damage[2] = int.Parse(item.Parent.Element("A3Damage").Value); damage[3] = int.Parse(item.Parent.Element("A4Damage").Value); effects[0] = int.Parse(item.Parent.Element("A1Effect").Value); effects[1] = int.Parse(item.Parent.Element("A2Effect").Value); effects[2] = int.Parse(item.Parent.Element("A3Effect").Value); effects[3] = int.Parse(item.Parent.Element("A4Effect").Value); enemyPT[0] = item.Parent.Element("EA1PT").Value.Trim(); enemyPT[1] = item.Parent.Element("EA2PT").Value.Trim(); enemyPT[2] = item.Parent.Element("EA3PT").Value.Trim(); enemyPT[3] = item.Parent.Element("EA4PT").Value.Trim(); enemyD[0] = int.Parse(item.Parent.Element("EA1D").Value); enemyD[1] = int.Parse(item.Parent.Element("EA2D").Value); enemyD[2] = int.Parse(item.Parent.Element("EA3D").Value); enemyD[3] = int.Parse(item.Parent.Element("EA4D").Value); defeat = item.Parent.Element("DText").Value.Trim(); //Debug.Log ("R we getting here prquel\t"); } } Debug.Log("R we getting here"); rndr.sprite = Resources.Load <Sprite> (spriteName); //"Assets/Artwork/sprites/EnemySprites/ElonMuskrat"; Debug.Log(introText); General.text = introText; Action1.text = actions [0]; Action2.text = actions [1]; Action3.text = actions [2]; Action4.text = actions [3]; Debug.Log(actions [0]); Debug.Log(actions [1]); Debug.Log(actions [2]); Debug.Log(actions [3]); btn1.onClick.AddListener(turn1); btn2.onClick.AddListener(turn2); btn3.onClick.AddListener(turn3); btn4.onClick.AddListener(turn4); Debug.Log("WTF"); //rndr.color = new Color(200,0,0); }