public void BattleMove() { TalkBox Talk = TextBox.GetComponent <TalkBox> (); BattleExit BatExit = TextBox.GetComponent <BattleExit> (); Rigidbody2D Rb = gameObject.GetComponent <Rigidbody2D> (); if (BatExit.InBattle) { if (Talk.Talking == false) { MoveX = Input.GetAxisRaw("Horizontal"); MoveY = Input.GetAxisRaw("Vertical"); Rb.velocity = new Vector2(MoveX * speed, MoveY * speed); } // if (Input.GetAxisRaw ("Horizontal") == 0 && Input.GetAxisRaw ("Vertical") == 0) { // Rb.drag = 10000; // } // else // {Rb.drag = 0f; // } // transform.position += move * speed * Time.deltaTime;(OLD MOVEMENT NOT TOO GOOD) } else { Rb.velocity = new Vector2(0, 0); } }
// Update is called once per frame void Update() // AudioSource Sm=gameObject.GetComponent<AudioSource>(); { Mercy Mer = MercyMove.GetComponent <Mercy>(); Act Ac = ActMove.GetComponent <Act> (); Item Ite = ItemMove.GetComponent <Item> (); Fight Fig = FightMove.GetComponent <Fight> (); BattleExit BE = TextBox.GetComponent <BattleExit> (); MouseFunc(); Quitting(); if (Mer.OnMercyMenu == false && Ite.OnItemMenu == false && Ac.OnActMenuNmb == 0 && Fig.OnFightMenu == false) { if (BE.InBattle == false) { if (EventSystem.current.currentSelectedGameObject == null) { EventSystem.current.SetSelectedGameObject(lastselect); } else { lastselect = EventSystem.current.currentSelectedGameObject; } } } }
public void Battle1() { BattleExit BatExit = TextBox.GetComponent <BattleExit> (); Animator TxtAnim = AtkDamage.GetComponent <Animator> (); HealthBar_Enemy HBE = EnemyHealthBar.GetComponent <HealthBar_Enemy> (); BatExit.InBattle = true; TextBox.enabled = true; //AtkDamage.enabled = false; HBEH.enabled = false; HBEHDamage.enabled = false; //TxtAnim.enabled = false; }
// Update is called once per frame void Update() { Animator Attack_0 = gameObject.GetComponent <Animator> (); PlayerHealth Health = Heart.GetComponent <PlayerHealth> (); BattleExit BE = TextBox.GetComponent <BattleExit> (); if (Health.Invulnerable) { if (BE.InBattle) { StartCoroutine("Idle", duration); } else { StopAllCoroutines(); Attack_0.Play("Idle"); Health.Invulnerable = false; } } }
public void TalkBoxSc() { GameObject item = GameObject.Find("ItemMove"); Item IScript = item.GetComponent <Item> (); TalkBox Talk = TextBox.GetComponent <TalkBox> (); UITextTypeWriterTalkBox TypeTalk = TalkBox.GetComponent <UITextTypeWriterTalkBox> (); BattleExit BatExit = TextBox.GetComponent <BattleExit> (); Attacks Attack = Attacks.GetComponent <Attacks> (); HealthBar_Enemy HBE = HealthBar_Enemy_GameObject.GetComponent <HealthBar_Enemy> (); if (Talk.Talking) { if (TalkBoxFinished) { //Talk.StopAllCoroutines (); Talk.StartCoroutine("TalkProgress", 4); if (Input.GetAxisRaw("Submit") == 1) { if (IScript.NOfClicks > 1) { Talk.TalkingProgress = false; Talk.TalkBoxText.enabled = false; Talk.TalkBoxImage.enabled = false; TypeTalk.StopAllCoroutines(); BatExit.InBattle = true; if (HBE.Betrayed == false && HBE.Dead == false) { Talk.Talking = false; if (Attack.AttackNumber == 0) //AtkNumber in Attack GameObject { BatExit.StartCoroutine("BattleDuration", 4); Attack.ChoseAttack(); } else if (Attack.AttackNumber == 1) { BatExit.StartCoroutine("BattleDuration", 6); Attack.ChoseAttack(); } else if (Attack.AttackNumber == 2) { BatExit.StartCoroutine("BattleDuration", 1000000); Attack.ChoseAttack(); } } else { if (Spareable == false) { FadeToBlackAnim.Play("FadeToBlack"); SceneManager.LoadScene(3); } } } } if (Talk.TalkingProgress) { Talk.TalkingProgress = false; Talk.TalkBoxText.enabled = false; Talk.TalkBoxImage.enabled = false; TypeTalk.StopAllCoroutines(); BatExit.InBattle = true; if (HBE.Betrayed == false && HBE.Dead == false) { Talk.Talking = false; if (Attack.AttackNumber == 0) //AtkNumber in Attack GameObject { BatExit.StartCoroutine("BattleDuration", 4); } else if (Attack.AttackNumber == 1) { BatExit.StartCoroutine("BattleDuration", 6); } else if (Attack.AttackNumber == 2) { BatExit.StartCoroutine("BattleDuration", 1000000); } } else { if (Spareable == false) { FadeToBlackAnim.Play("FadeToBlack"); SceneManager.LoadScene(3); } } } } } // if(Talk.Talking){ // if(TalkBoxFinished){ // Talk.StartCoroutine ("TalkProgress"); // if() // // // } // // } }
public void SpawnLaser() { BattleExit BE = TextBox.GetComponent <BattleExit> (); SpriteRenderer LG = LaserGreen.GetComponent <SpriteRenderer> (); HealthBar_Enemy HB = EnemyH.GetComponent <HealthBar_Enemy> (); if (BE.InBattle) { if (LaserSpawn) { LG.enabled = true; Vector3 LaserPosition = new Vector3(Random.Range(spawnLU.position.x, spawnRU.position.x), spawnLU.position.y, 0); LaserSpawn = false; GameObject LaserClone = (GameObject)Instantiate(LaserGreen, LaserPosition, Quaternion.identity); //Rigidbody2D LCRB = LaserClone.AddComponent <Rigidbody2D>()as Rigidbody2D; //LCRB.AddForce (LaserForce); LaserClone.transform.SetParent(Attack1Parent); Lasers.Add(LaserClone); for (int i = 0; i < Lasers.Count; i++) { LaserGreen L = Lasers [i].GetComponent <LaserGreen> (); //LaserClone.transform.SetParent (LaserGreenParent); LaserClone.name = "Laser " + Lasers.IndexOf(LaserClone); LaserClone.tag = "LaserClone"; L.Tm = 0; } // GameObject LaserC=GameObject.f } } int n = Lasers.Count; for (int i = 0; i < n; i++) { if (Lasers.Count != 0) { Vector3 LaserPosition = new Vector3(Random.Range(spawnLU.position.x, spawnRU.position.x), Random.Range(spawnLU.position.y, spawnRU.position.y), 0); SpriteRenderer S = Lasers[i].GetComponent <SpriteRenderer> (); LaserGreen L = Lasers [i].GetComponent <LaserGreen> (); if (HB.CurrentHealth != 0) { speed = (1 / (HB.CurrentHealth + 1)); } Lasers [i].transform.position += LaserForce * speed * Time.deltaTime; if (Lasers [i].transform.position.y < spawnLD.position.y) { Lasers [i].transform.position = LaserPosition; S.enabled = false; } else if (Lasers [i].transform.position.y >= spawnLU.position.y) { S.enabled = false; } else if (Lasers [i].transform.position.y < spawnLU.position.y) { S.enabled = true; } if (CancelSpawn) { CancelSpawn = false; CancelSpawn = true; Destroy(Lasers [0]); Lasers.Remove(Lasers [0]); Debug.Log(Lasers.Count); } } } }