//initialization of state void Start() { currentState = turnState.START; playerInput = PlayerGUI.ACTIVATE; PlayerInBattle.AddRange(GameObject.FindGameObjectsWithTag("Player")); PlayerInBattle.AddRange(GameObject.FindGameObjectsWithTag("AI")); }
//initialization of state void Start() { ani.GetComponent <Animator>(); c1.GetComponent <Animator>(); c2.GetComponent <Animator>(); currentState = turnState.START; playerInput = PlayerGUI.ACTIVATE; PlayerInBattle.AddRange(GameObject.FindGameObjectsWithTag("Player")); PlayerInBattle.AddRange(GameObject.FindGameObjectsWithTag("AI")); //player objects leftR = GameObject.Find("Left_Rock"); leftP = GameObject.Find("Left_Paper"); leftS = GameObject.Find("Left_Scissors"); rightR = GameObject.Find("Right_Rock"); rightP = GameObject.Find("Right_Paper"); rightS = GameObject.Find("Right_Scissors"); //enemies e1 = GameObject.Find("Enemy 1"); e2 = GameObject.Find("Enemy 2"); e3 = GameObject.Find("Enemy 3"); // canvas battleCanvas = GameObject.Find("BattleCanvas"); classSelectCanvas = GameObject.Find("ClassSelectionCanvas"); resultCanvas = GameObject.Find("ResultCanvas"); battleCanvas.SetActive(false); classSelectCanvas.SetActive(true); resultCanvas.SetActive(false); }
// Use this for initialization void Start() { currentState = turnState.START; player.LeftHand_state = true; player.RightHand_state = true; CSM = GameObject.Find("BattleManager").GetComponent <Combat_statemachine> (); }
private IEnumerator TimeForAction() { if (actionStarted) { yield break; } Hurt(); actionStarted = true; { yield return(null); } //wait a bit yield return(new WaitForSeconds(0.5f)); //do damage DoDamage(); //remove this performer from the list in BSM BSM.PerformList.RemoveAt(0); //reset BSM -> Wait BSM.battleState = BattleStateMachine.performAction.Wait; //end coroutine actionStarted = false; //reset this enemy state currentCooldown = 1f; currentState = turnState.processing; }
void Start() { createEnemyDisplay(); currentState = turnState.processing; BSM = GameObject.Find("BattleManager").GetComponent <BattleStateMachine>(); startPosition = transform.position; }
public void init() { tiles = GameObject.FindGameObjectsWithTag("Tile"); state = turnState.SELECTING; halfHeight = GetComponent <Collider>().bounds.extents.y; //TurnManager.AddUnit(this); }
public void Update() { //Debug.Log (currentState); switch (currentState) { case (turnState.processing): Hurt(); UpgradeProgressBar(); break; case (turnState.chooseAction): ChooseAction(); currentState = turnState.waiting; break; case (turnState.waiting): //idle state break; case (turnState.action): StartCoroutine(TimeForAction()); break; case (turnState.dead): if (alive == true) { return; } else { alive = false; //change tag of enemy this.gameObject.tag = "DeadEnemy"; //not attackable BSM.EnemyInBattle.Remove(this.gameObject); for (int i = 0; i < BSM.PerformList.Count; i++) { if (BSM.PerformList[i].AttacksGameObject = this.gameObject) { BSM.PerformList.Remove(BSM.PerformList[i]); } if (BSM.PerformList[i].AttackersTarget == this.gameObject) { BSM.PerformList[i].AttackersTarget = BSM.EnemyInBattle[Random.Range(0, BSM.EnemyInBattle.Count)]; } } //dead animation this.gameObject.GetComponent <SpriteRenderer>().color = new Color32(105, 105, 105, 255); BSM.battleState = BattleStateMachine.performAction.CheckAlive; } break; } }
// inintialized enemy state void Start() { currentState = turnState.START; enemy.LeftHand_state = true; enemy.RightHand_state = true; CSM = GameObject.Find("BattleManager").GetComponent <Combat_statemachine> (); startPosition = transform.position; }
void Start() { //create panel, fill in info createPlayerDisplay(); currentState = turnState.alive; BSM = GameObject.Find("BattleManager").GetComponent <BattleStateMachine>(); startPosition = transform.position; }
public void TakeDamage(float getDamageAmount) { player.currentHP -= getDamageAmount; if (player.currentHP <= 0) { currentState = turnState.dead; Debug.Log("Game Over"); } }
void UpgradeProgressBar() { currentCooldown = currentCooldown + Time.deltaTime; if (currentCooldown >= maxCooldown) { currentState = turnState.chooseAction; } }
// Update is called once per frame void Update() { switch (currentState) { case (turnState.START): //check if the player lost all the hands if (player.LeftHand_state == false && player.RightHand_state == false) { currentState = turnState.LOSE; } else { currentState = turnState.CHOOSEACTION; } break; case (turnState.CHOOSEACTION): if ((CSM.playerChoice.AttackTarget != null && CSM.playerChoice.LeftAttackType != HandleTurn.janken.NONE && CSM.playerChoice.RightAttackType != HandleTurn.janken.NONE) || (player.LeftHand_state == false && CSM.playerChoice.RightAttackType != HandleTurn.janken.NONE) || (player.RightHand_state == false && CSM.playerChoice.LeftAttackType != HandleTurn.janken.NONE)) { readyToBattle(); //Extraturn; currentState = turnState.WAITING; } else { //Debug.Log ("Complete your actions!!"); } break; case (turnState.WAITING): // change to ACTION once all player have chosen a move if (CSM.PerformList.Count <= 4) { currentState = turnState.ACTION; } break; case (turnState.ACTION): // idle if (player.LeftHand_state == false && player.RightHand_state == false) //check if the player lost all the hands { currentState = turnState.LOSE; } else { currentState = turnState.START; } break; case (turnState.LOSE): Debug.Log("You Lose"); //Application.Quit(); break; } }
void Hurt() { UpdateEnemyDisplay(); if (enemy.currentHP <= 0f) { alive = false; enemy.currentHP = 0; currentState = turnState.dead; } }
public void TakeDamage(float getDamageAmount) { player.currentHP -= getDamageAmount; UpdatePlayerDisplay(); if (player.currentHP <= 0) { player.currentHP = 0; currentState = turnState.dead; } }
void UpgradeProgressBar() { currentCooldown = currentCooldown + Time.deltaTime; float calc_cooldown = currentCooldown / maxCooldown; progressbar.transform.localScale = new Vector3(Mathf.Clamp(calc_cooldown, 0, 1), progressbar.transform.localScale.y, progressbar.transform.localScale.z); if (currentCooldown >= maxCooldown) { currentState = turnState.chooseAction; } }
// inintialized enemy state void Start() { ani.GetComponent <Animator>(); currentState = turnState.START; enemy.LeftHand_state = true; enemy.RightHand_state = true; ani.SetBool("lefthand", true); ani.SetBool("righthand", true); CSM = GameObject.Find("BattleManager").GetComponent <Combat_statemachine>(); startPosition = transform.position; }
// Update is called once per frame void Update() { switch (currentState) { case (turnState.START): //check if the enemy lost all the hands if (enemy.LeftHand_state == false && enemy.RightHand_state == false) { currentState = turnState.LOSE; } else { currentState = turnState.CHOOSEACTION; } break; case (turnState.CHOOSEACTION): if (CSM.PSM.currentState == Player_statemachine.turnState.WAITING) { chooseAction(); currentState = turnState.WAITING; } break; case (turnState.WAITING): // change to ACTION once all player have chosen a move int c = CSM.PerformList.Count; if (c <= 4) { currentState = turnState.ACTION; } break; case (turnState.ACTION): // idle //check if the enemy lost all the hands if (enemy.LeftHand_state == false && enemy.RightHand_state == false) { currentState = turnState.LOSE; } else if (CSM.currentState == Combat_statemachine.turnState.START) { myAttack = new HandleTurn(); currentState = turnState.START; } break; case (turnState.LOSE): Debug.Log(enemy.name + " is destroyed"); this.gameObject.SetActive(false); break; } }
public void MoveToTile(Tile tile) { path.Clear(); tile.target = true; moving = true; state = turnState.MOVING; Tile next = tile; while (next != null) { path.Push(next); next = next.parent; } }
void Update() { //Debug.Log (currentState); switch (currentState) { case (turnState.processing): UpgradeProgressBar(); break; case (turnState.chooseAction): ChooseAction(); currentState = turnState.waiting; break; case (turnState.waiting): //idle state break; case (turnState.action): StartCoroutine(TimeForAction()); break; case (turnState.dead): if (!alive) { return; } else { //change tag of enemy this.gameObject.tag = "DeadEnemy"; //not attackable BSM.EnemyInBattle.Remove(this.gameObject); //dead animation //this.gameObject.GetComponent<SpriteRenderer>(). alive = false; } break; } }
public void Move() { if (path.Count > 0) { Tile t = path.Peek(); Vector3 target = t.transform.position; //calculate the unit's position on top of the target tile target.y += halfHeight + t.GetComponent <Collider>().bounds.extents.y; if (Vector3.Distance(transform.position, target) >= .05f) { bool jump = transform.position.y >= target.y + .5f; if (jump) { Debug.Log("JUMP!!!!!!"); Jump(target); } else { CalculateHeading(target); SetHorizontalVelocity(); } transform.forward = heading; transform.position += velocity * Time.deltaTime; } else { transform.position = target; path.Pop(); } } else { removeSelectTiles(); RemoveAttTiles(); moving = false; state = turnState.WAIT; currentTile = null; } }
void Start() { currentState = turnState.alive; BSM = GameObject.Find("BattleManager").GetComponent <BattleStateMachine>(); startPosition = transform.position; }
// Update is called once per frame void Update() { GameResult(); //how the battle is progressed each turn //Debug.Log ("currentState: "+ currentState); switch (currentState) { case (turnState.START): PerformList = new List <HandleTurn> (); playerChoice = new HandleTurn(); currentState = turnState.PLAYERCHOICE; break; case (turnState.PLAYERCHOICE): if (playerInput == PlayerGUI.DONE) { currentState = turnState.ENEMYCHOICE; } break; case (turnState.ENEMYCHOICE): switch (playerChoice.skill) { case HandleTurn.skills.DoubleAttack: if (PerformList.Count == PlayerInBattle.Count + 1) { currentState = turnState.ACTION; } break; case HandleTurn.skills.Attack: if (PerformList.Count == PlayerInBattle.Count) { currentState = turnState.ACTION; } break; case HandleTurn.skills.AttackAll: if (PerformList.Count == PlayerInBattle.Count + 2) { currentState = turnState.ACTION; } break; case HandleTurn.skills.Recover: //if (PerformList.Count == PlayerInBattle.Count -1) //{ currentState = turnState.ACTION; //} break; case HandleTurn.skills.DeniService: currentState = turnState.ACTION; break; case HandleTurn.skills.ExtraTurn: if (PerformList.Count == PlayerInBattle.Count + 1) { currentState = turnState.ACTION; } break; case HandleTurn.skills.MinRisk: if (PerformList.Count == PlayerInBattle.Count) { currentState = turnState.ACTION; } break; case HandleTurn.skills.Sleep: if (PerformList.Count == PlayerInBattle.Count - 1) { currentState = turnState.ACTION; } break; case HandleTurn.skills.SplashAttack: if (PerformList.Count == PlayerInBattle.Count + 1) { currentState = turnState.ACTION; } break; case HandleTurn.skills.Wall: if (PerformList.Count == PlayerInBattle.Count) { currentState = turnState.ACTION; } break; } break; case (turnState.ACTION): //put in the logic here skillused(); // Replace with transition animation currentState = turnState.START; break; } //how the player turn is progressed //Debug.Log ("playerInput: "+ playerInput); switch (playerInput) { case (PlayerGUI.ACTIVATE): playerInput = PlayerGUI.INPUT; break; case (PlayerGUI.INPUT): if (playerChoice.AttackTarget != null) { playerInput = PlayerGUI.DONE; } break; case (PlayerGUI.DONE): if (currentState == turnState.PLAYERCHOICE) { playerInput = PlayerGUI.ACTIVATE; } break; } }
// Update is called once per frame void Update() { Debug.Log(currentState); //how the battle is progressed each turn switch (currentState) { case (turnState.START): //DelayedAttribute (100);// Replace with transition animation currentState = turnState.PLAYERCHOICE; break; case (turnState.PLAYERCHOICE): if (playerInput == PlayerGUI.DONE) { currentState = turnState.ENEMYCHOICE; } break; case (turnState.ENEMYCHOICE): currentState = turnState.ACTION; break; case (turnState.ACTION): //put in the logic here if (playerChoice.AttackType == HandleTurn.janken.ROCK) { for (int i = 1; i < 3; i++) { if (PerformList [i].AttackType == HandleTurn.janken.SCISSORS) { //win } else if (PerformList [i].AttackType == HandleTurn.janken.PAPER) { //lose } else { //draw } } } if (playerChoice.AttackType == HandleTurn.janken.PAPER) { for (int i = 1; i < 3; i++) { if (PerformList [i].AttackType == HandleTurn.janken.ROCK) { //win } else if (PerformList [i].AttackType == HandleTurn.janken.SCISSORS) { //lose } else { //draw } } } if (playerChoice.AttackType == HandleTurn.janken.SCISSORS) { for (int i = 1; i < 3; i++) { if (PerformList [i].AttackType == HandleTurn.janken.PAPER) { //win } else if (PerformList [i].AttackType == HandleTurn.janken.ROCK) { //lose } else { //draw } } } //DelayedAttribute (100);// R eplace with transition animation currentState = turnState.START; break; } //how the player turn is progressed switch (playerInput) { case (PlayerGUI.ACTIVATE): //DelayedAttribute (100);// Replace with transition animation playerInput = PlayerGUI.INPUT; break; case (PlayerGUI.INPUT): break; case (PlayerGUI.DONE): if (currentState == turnState.PLAYERCHOICE) { playerInput = PlayerGUI.ACTIVATE; } break; } }
// Update is called once per frame void Update() { switch (currentState) { case (turnState.START): //check if the enemy lost all the hands if (enemy.LeftHand_state == false && enemy.RightHand_state == false) { currentState = turnState.LOSE; ; } else { currentState = turnState.CHOOSEACTION; } break; case (turnState.CHOOSEACTION): if (CSM.PSM.currentState == Player_statemachine.turnState.WAITING) { chooseAction(); currentState = turnState.WAITING; } break; case (turnState.WAITING): // change to ACTION once all player have chosen a move int c = CSM.PerformList.Count; if (c <= 4) { currentState = turnState.ACTION; } break; case (turnState.ACTION): // idle //check if the enemy lost all the hands if (enemy.name == "e1") { ani.SetBool("lr", false); ani.SetBool("lp", false); ani.SetBool("ls", false); ani.SetBool("rr", false); ani.SetBool("rp", false); ani.SetBool("rs", false); if (enemy.LeftHand_state == true && enemy.RightHand_state == false) { ani.SetBool("righthand", false); ani.SetTrigger("losingright"); ani.SetBool("1hand", true); } if (enemy.LeftHand_state == false && enemy.RightHand_state == true) { ani.SetBool("lefthand", false); ani.SetTrigger("losingleft"); ani.SetBool("1hand", true); } } else if (enemy.name == "e2") { ani.SetBool("lr", false); ani.SetBool("lp", false); ani.SetBool("ls", false); ani.SetBool("rr", false); ani.SetBool("rp", false); ani.SetBool("rs", false); if (enemy.LeftHand_state == true && enemy.RightHand_state == false) { ani.SetBool("righthand", false); ani.SetTrigger("losingright"); ani.SetBool("1hand", true); } if (enemy.LeftHand_state == false && enemy.RightHand_state == true) { ani.SetBool("lefthand", false); ani.SetTrigger("losingleft"); ani.SetBool("1hand", true); } } else if (enemy.name == "e3") { ani.SetBool("lr", false); ani.SetBool("lp", false); ani.SetBool("ls", false); ani.SetBool("rr", false); ani.SetBool("rp", false); ani.SetBool("rs", false); if (enemy.LeftHand_state == true && enemy.RightHand_state == false) { ani.SetBool("righthand", false); ani.SetTrigger("losingright"); ani.SetBool("1hand", true); } if (enemy.LeftHand_state == false && enemy.RightHand_state == true) { ani.SetBool("lefthand", false); ani.SetTrigger("losingleft"); ani.SetBool("1hand", true); } } if (enemy.LeftHand_state == false && enemy.RightHand_state == false) { currentState = turnState.LOSE; } else if (CSM.currentState == Combat_statemachine.turnState.START) { myAttack = new HandleTurn(); currentState = turnState.START; } break; case (turnState.LOSE): if (enemy.name == "e3") { ani.SetBool("lefthand", false); ani.SetBool("righthand", false); ani.SetTrigger("death"); } else if (enemy.name == "e1") { ani.SetBool("lefthand", false); ani.SetBool("righthand", false); ani.SetTrigger("death"); } else if (enemy.name == "e2") { ani.SetBool("lefthand", false); ani.SetBool("righthand", false); ani.SetTrigger("death"); } Debug.Log(enemy.name + " is destroyed"); //this.gameObject.SetActive(false); break; } }