private void checkStateEndOfAction() { if (targetsInRange.Count > 0) { foreach (GameObject target in targetsInRange) { if (target.activeInHierarchy) { target.SendMessage("disableLight"); } } targetsInRange.Clear(); } if (getSelectedManager().numActions == SquadManager.MAX_ACTIONS || getSelectedManager().numActions == 0) { currentStage = TurnStage.None; if (checkTurnComplete()) { nextTurn(); } else { selectNextAvalibleSquad(); } } else { currentStage = TurnStage.InBetween; } }
private void checkNewAction() { //start move if (Input.GetAxis("DpadH") == -1) { if (getSelectedManager().numActions > 0) { move.Play(); changeUnit.enabled = false; currentStage = TurnStage.Moving; getSelectedManager().startMovement(); updateUI(); } } //start start combat if (Input.GetAxis("DpadH") == 1) { if (getSelectedManager().numActions > 0) { attack.Play(); currentStage = TurnStage.Combat; TutorialCombat.findTargets(selectedRB.gameObject); updateUI(); } } }
private void CheckWinAfterPlayerTurn() { if (GameManager.Instance.warTable.PlayerCanWin) { currentTurnStage = TurnStage.fight_enemy; } else { // lose bool needSelection; GameManager.Instance.warTable.OnLose(out needSelection); if (needSelection) { currentTurnStage = TurnStage.select_cards; } else { currentTurnStage = TurnStage.completion; Server.Instance.Send_EndFight(playerWin: false); } } SendChangeTurn(); }
public void EndEnemyTurn() { //called after AI takes turn Debug.Log("Ending enemy turn"); _stage = TurnStage.PlayerTurn; _delegate.StartPlayerTurn(); }
//Called when command is confirmed, action has executed and turn changed public void switchNextStage() { if (battleStage == BattleStage.TURN_DECIDING) { battleStage = BattleStage.TURN_EXECUTING; Debug.Log("Action for turn now being executed!"); return; } else if (battleStage == BattleStage.TURN_EXECUTING) { battleStage = BattleStage.CHANGING_TURN; if (!isEnemy(turnOwner)) { StopCoroutine("WaitForPlayerTurn"); } turnStage = TurnStage.TURN_SET; Debug.Log("Switching to next actor!"); turnManagement(); } else if (battleStage == BattleStage.CHANGING_TURN) { battleStage = BattleStage.TURN_DECIDING; turnManagement(); } }
public void NextTurnEvent() { Debug.Log("next turn event..."); //based on what the current stage is will move to the next one switch (_stage) { case TurnStage.BattleStart: _stage = TurnStage.PlayerTurn; _delegate.StartPlayerTurn(); return; case TurnStage.PlayerTurn: _stage = TurnStage.PlayerAction; _delegate.StartPlayerAction(); return; case TurnStage.PlayerAction: _stage = TurnStage.ResolvePlayerActions; _delegate.ResolvePlayerActions(); return; case TurnStage.ResolvePlayerActions: _stage = TurnStage.EnemyTurn; _delegate.StartEnemyTurn(); return; } }
public void StartBattle() { //called when the battle starts Debug.Log("Starting Battleee"); _stage = TurnStage.BattleStart; _delegate.WaitBeforeTurn(1.8f); }
private void AfterWait() { GameManager.Instance.warTable.UseCardInWT(CurPlayerTurnNum); currentTurnStage = TurnStage.after_door; SendChangeTurn(); }
private void StartGame() { currentTurnStage = TurnStage.preparation; endTurnButton.textMesh.text = "Open Door"; StartCoroutine(TurnFunc(20)); }
public void StatFirstTurn() { currentTurnStage = TurnStage.preparation; turnNumber = 0; SendChangeTurn(); StartCoroutine(TurnFunc()); }
public void gameOver(int playerWinner) { Debug.Log("GAME OVER! PLAYER " + playerWinner + " victory!"); Application.Quit(); isRunning = false; currentStage = TurnStage.None; updateUI(); return; }
public void MonsterPlayed() { StopAllCoroutines(); currentTurnStage = TurnStage.fight_player; SendChangeTurn(); StartCoroutine(TurnFunc()); }
public void OpenDoor(bool isMonster) { if (isMonster) { currentTurnStage = TurnStage.fight_player; } else { currentTurnStage = TurnStage.waiting; } SendChangeTurn(); }
//call at end of turn public void nextRound() { foreach (GameObject g in allSquads) { if (g.activeInHierarchy) { g.GetComponent <TutorialManager>().resetActions(); } } isRoundOver = false; isOtherRoundOver = false; currentStage = TurnStage.None; }
public void ChangeTurn(TurnStage newStage, bool isPlayerTurn, int time) { StopAllCoroutines(); playerTurn = isPlayerTurn; currentTurnStage = newStage; turnStageText.text = currentTurnStage.ToString(); bool isButtonEnable = (isPlayerTurn ^ (newStage == TurnStage.fight_enemy)) && (newStage != TurnStage.waiting); endTurnButton.SetActive(isButtonEnable); StartCoroutine(TurnFunc(time)); }
public void nextTurn() //What happens if the last dude to go dies, but hasn't called end of round? { if (checkRoundComplete() && isOtherRoundOver) { nLogicView.RPC("nextRound", RPCMode.All, true); //Call everyone to reset round setTurn(false); nLogicView.RPC("setTurn", RPCMode.Others, true); //This player went last, so other player goes first } else { currentStage = TurnStage.None; nLogicView.RPC("setTurn", RPCMode.Others, true); setTurn(false); } }
private void OnNewStage(int turnClientNumber, TurnStage turnStage, int time) { GameManager.Instance.enemyDropCardsText.SetActive(false); // TODO: Remove // just for now if (turnStage != TurnStage.fight_enemy && turnStage != TurnStage.fight_player && turnStage != TurnStage.waiting && turnStage != TurnStage.after_door) { GameManager.Instance.warTable.ClearTable(); } // GameManager.Instance.turnController.ChangeTurn(turnStage, GameManager.Instance.player.info.number == turnClientNumber, time); }
private void CheckWinAfterEnemyTurn() { if (GameManager.Instance.warTable.PlayerCanWin) { // win GameManager.Instance.OnPlayerWinFight(); currentTurnStage = TurnStage.completion; Server.Instance.Send_EndFight(playerWin: true); } else { currentTurnStage = TurnStage.fight_player; } SendChangeTurn(); }
public void executeSkill() { if (!isEnemy(turnOwner)) { StopCoroutine("WaitForPlayerTurn"); _bm._gm._GUI.hideActionMenu(); } getTurnOwner().GetComponent <Actor>()._base.curMana -= curSkill.cost; if (!isEnemy(getTurnOwner())) { _bm._gm._GUI.updatePartyValues(); } battleStage = BattleStage.TURN_EXECUTING; turnStage = TurnStage.AUTOMATION; finalTargets = getMarkedActors(); curSkill.useSkill(this); }
public void ChangeTurn() { StopAllCoroutines(); switch (currentTurnStage) { case TurnStage.preparation: GameManager.Instance.OpenDoor(); break; case TurnStage.waiting: AfterWait(); break; case TurnStage.after_door: GameManager.Instance.GiveOneDoor(); currentTurnStage = TurnStage.preparation; turnNumber++; SendChangeTurn(); break; case TurnStage.fight_player: CheckWinAfterPlayerTurn(); break; case TurnStage.fight_enemy: CheckWinAfterEnemyTurn(); break; case TurnStage.select_cards: currentTurnStage = TurnStage.completion; SendChangeTurn(); break; case TurnStage.completion: currentTurnStage = TurnStage.preparation; turnNumber++; SendChangeTurn(); break; } StartCoroutine(TurnFunc()); }
private void checkNewAction() { //start move if (Input.GetAxis("DpadH") == -1) { if (getSelectedManager().numActions > 0) { move.Play(); changeUnit.enabled = false; currentStage = TurnStage.Moving; getSelectedManager().startMovement(); updateUI(); } } //start start combat if (Input.GetAxis("DpadH") == 1) { if (getSelectedManager().numActions > 0) { attack.Play(); currentStage = TurnStage.Combat; Combat.findTargets(selectedRB.gameObject); updateUI(); } } /*//skip * if (Input.GetAxis("DpadV") == -1) * { * if (getSelectedManager().numActions > 0) * { * currentStage = TurnStage.InBetween; * getSelectedManager().skipAction(); * } * if (getSelectedManager().numActions == 0) * { * currentStage = TurnStage.None; * } * checkStateEndOfAction(); * } */ }
private void checkNewAction() { //start move if (Input.GetAxis("DpadH") == -1) { if (getSelectedManager().numActions > 0) { currentStage = TurnStage.Moving; getSelectedManager().startMovement(); } } //start start combat if (Input.GetAxis("DpadH") == 1) { if (getSelectedManager().numActions > 0) { currentStage = TurnStage.Combat; targetsInRange = getTargets(selectedRB.position, 20, currentPlayersTurn); selectedTargetIndex = 0; Debug.Log("Number of targets within range: " + targetsInRange.Count.ToString()); //foreach (GameObject target in targetsInRange) //{ // target.SendMessage("withinRange"); //} } } //skip if (Input.GetAxis("DpadV") == -1) { if (getSelectedManager().numActions > 0) { currentStage = TurnStage.InBetween; getSelectedManager().skipAction(); } if (getSelectedManager().numActions == 0) { currentStage = TurnStage.None; } checkStateEndOfAction(); } }
public void checkStateEndOfAction() { TutorialCombat.reset(); currentAttack = AttackType.Basic; getSelectedManager().disableSelect(); attackProj.enabled = false; changeUnit.enabled = false; if (GameObject.FindGameObjectsWithTag("Player0Squad").Length == 0) { gameOver(2); return; } if (GameObject.FindGameObjectsWithTag("Player1Squad").Length == 0) { gameOver(1); return; } if (getSelectedManager().numActions == SquadManager.MAX_ACTIONS) { currentStage = TurnStage.None; } else if (getSelectedManager().numActions == 0) { //getSelectedManager().nView.RPC("activeSquadColor", RPCMode.All, false); getSelectedManager().activeSquadColor(false); nextTurn(); } else { currentStage = TurnStage.InBetween; } updateUI(); }
public void playerUsedCommand(GameObject myButton) { //Debug.Log ("Player clicked " + myButton.GetComponent<Button>().name); BattleComandButton bcb = myButton.GetComponent <BattleComandButton>(); if (bcb.myLinkedMenu == -1) { Debug.Log("Player selected to use " + bcb.myLinkedSkill.name + " skill!"); cameFromSubMenu = false; //Target Select turnStage = TurnStage.SELECTING_TARGET; curSkill = bcb.myLinkedSkill; curTargetType = curSkill.targetType; usableOnDead = curSkill.useOnDead; if (curSkill.cost < getTurnOwnerTarget().actor.GetComponent <Actor>()._base.curMana) { infoBox.text = curSkill.description; _bm._gm._GUI.hideActionMenu(); if (curSkill.targetType == TargetType.TARGET) { //Debug.Log ("Skill requires enemy target. Target must be selected to confirm!"); targetSingle(getLivingActor(false)); } else if (curSkill.targetType == TargetType.PARTY_MEMBER) { //Debug.Log ("Skill requires party target. Target must be selected to confirm!"); targetSingle(getLivingActor()); } else if (curSkill.targetType == TargetType.SELF) { //Debug.Log ("Skill requires self. Confirmation required!"); targetSelf(); } else if (curSkill.targetType == TargetType.ALL_TARGET) { //Debug.Log ("Skill will hit all enemies. Confirmation required!"); targetEntireParty(); } else if (curSkill.targetType == TargetType.ALL_PARTY) { //Debug.Log ("Skill will hit all party. Confirmation required!"); targetEntireEnemies(); } } else { //Inform the cost } } else if (bcb.myLinkedSkill == null) { Debug.Log("Player selected sub-menu " + bcb.myLinkedMenu); cameFromSubMenu = true; string submenu = ""; if (bcb.myLinkedMenu == 0) { submenu = "skill"; } else if (bcb.myLinkedMenu == 1) { submenu = "blackmagic"; } else if (bcb.myLinkedMenu == 2) { submenu = "whitemagic"; } else if (bcb.myLinkedMenu == 3) { submenu = "items"; } else { submenu = null; } if (submenu != null) { _bm._gm._GUI.showSubMenu(turnOwner, submenu); } else { Debug.LogError("Invalid submenu was called. Terminating..."); Application.Quit(); } } }
private void checkNewAction() { //start move if (Input.GetAxis("DpadH") == -1) { if (getSelectedManager().numActions > 0) { move.Play(); changeUnit.enabled = false; currentStage = TurnStage.Moving; getSelectedManager().startMovement(); updateUI(); } } //start start combat if (Input.GetAxis("DpadH") == 1) { if (getSelectedManager().numActions > 0) { attack.Play(); currentStage = TurnStage.Combat; TutorialCombat.findTargets(selectedRB.gameObject); updateUI(); } } }
public void checkStateEndOfAction() { Combat.reset(); currentAttack = AttackType.Basic; getSelectedManager().disableSelect(); attackProj.enabled = false; changeUnit.enabled = false; if (GameObject.FindGameObjectsWithTag("Player0Squad").Length == 0) { nLogicView.RPC("gameOver", RPCMode.All, 2); return; } if (GameObject.FindGameObjectsWithTag("Player1Squad").Length == 0) { nLogicView.RPC("gameOver", RPCMode.All, 1); return; } if (getSelectedManager ().numActions == SquadManager.MAX_ACTIONS) { currentStage = TurnStage.None; } else if(getSelectedManager ().numActions == 0) { getSelectedManager().nView.RPC("activeSquadColor", RPCMode.All, false); nextTurn(); } else currentStage = TurnStage.InBetween; updateUI(); }
// Update is called once per frame void Update() { if (!isRunning) return; if (squads == null || !isTurn) { //checkRound(); return; } if (squads.Length > 0) { if (currentStage == TurnStage.None) { //skip turn button if (Input.GetButtonDown("Select")) { nextTurn(); } if (isRoundOver) nextTurn(); checkChangeSquad(); checkNewAction(); } else if (currentStage == TurnStage.InBetween) { checkNewAction(); } else if (currentStage == TurnStage.Moving) { //if the squad is no longer moving (triggered if max distance is met) if (!getSelectedManager().midMovement) { //if we have another action if (getSelectedManager().numActions > 0) { currentStage = TurnStage.InBetween; } else currentStage = TurnStage.None; } //user undo else if (Input.GetButtonDown("Circle")) //B { getSelectedManager().undoMove(); checkStateEndOfAction(); getMainCamController().setCameraTarget(squads[selectedSquadIndex].transform.position); changeUnit.enabled = true; } //user ends early else if (Input.GetButtonDown("Cross")) //A { getSelectedManager().endMovement(); changeUnit.enabled = true; checkStateEndOfAction(); } else { selectedRB = squads[selectedSquadIndex].GetComponent<Rigidbody>(); float v = Input.GetAxis("JoystickLV"); float h = Input.GetAxis("JoystickLH"); selectedRB.velocity = (Quaternion.Euler(0, getMainCamController().angle, 0) * new Vector3(h, 0, v).normalized) * 20; getMainCamController().setCameraTarget(squads[selectedSquadIndex].transform.position,true); attackProj.transform.position = new Vector3(getSelectedManager().transform.position.x, 9, getSelectedManager().transform.position.z); } } else if (currentStage == TurnStage.Combat) { //TODO: enable combat in squad //skip if (Input.GetAxis("DpadV") == -1) { getSelectedManager().skipAction(); checkStateEndOfAction(); } if (currentAttack == AttackType.Basic) { if (Combat.UpdateTarget(selectedRB.GetComponent<SquadManager>())) //A { getMainCamController().freezeCamera (2); Debug.Log("I shot someone!"); StartCoroutine(Combat.fightTarget(selectedRB.gameObject,getSelectedManager().getPower())); getSelectedManager().skipAction(); checkStateEndOfAction(); updateUI(); } if (Input.GetButtonDown("Circle")) //B { if (getSelectedManager().numActions == 2) currentStage = TurnStage.None; if (getSelectedManager().numActions == 1) currentStage = TurnStage.InBetween; Combat.reset(); checkStateEndOfAction(); getMainCamController().setCameraTarget(squads[selectedSquadIndex].transform.position, true); } if (Input.GetButtonUp("Square")) { currentAttack = AttackType.Unit; Combat.reset(); attackProj.enabled = false; Debug.Log("Unit Ability"); getSelectedManager().unitAbility(); } if (Input.GetButtonUp("Triangle")) { currentAttack = AttackType.Squad; Combat.reset(); attackProj.enabled = false; changeUnit.enabled = true; getSelectedManager().squadAbility(); Debug.Log("Squad Ability"); } } else if(currentAttack == AttackType.Squad && getSelectedManager() != null) // && Input.GetButtonUp("Triangle") { getSelectedManager().squadAbilityUpdate(); } else if(currentAttack == AttackType.Unit && getSelectedManager() != null) // && Input.GetButtonUp("Square") { getSelectedManager().unitAbilityUpdate(); } if(Input.GetButtonUp("Circle")) //Reset to basic ability { currentAttack = AttackType.Basic; Combat.findTargets(selectedRB.gameObject); } } setLight(); } }
private void checkNewAction() { //start move if (Input.GetAxis("DpadH") == -1) { if (getSelectedManager().numActions > 0) { move.Play(); changeUnit.enabled = false; currentStage = TurnStage.Moving; getSelectedManager().startMovement(); updateUI(); } } //start start combat if (Input.GetAxis("DpadH") == 1) { if (getSelectedManager().numActions > 0) { attack.Play(); currentStage = TurnStage.Combat; Combat.findTargets(selectedRB.gameObject); updateUI(); } } /*//skip if (Input.GetAxis("DpadV") == -1) { if (getSelectedManager().numActions > 0) { currentStage = TurnStage.InBetween; getSelectedManager().skipAction(); } if (getSelectedManager().numActions == 0) { currentStage = TurnStage.None; } checkStateEndOfAction(); } */ }
public void nextTurn() { //What happens if the last dude to go dies, but hasn't called end of round? if (checkRoundComplete() && isOtherRoundOver) { nLogicView.RPC("nextRound", RPCMode.All, true); //Call everyone to reset round setTurn(false); nLogicView.RPC("setTurn", RPCMode.Others, true); //This player went last, so other player goes first } else { currentStage = TurnStage.None; nLogicView.RPC("setTurn", RPCMode.Others, true); setTurn(false); } }
//call at end of turn public void nextRound() { foreach (GameObject g in allSquads) { if(g.activeInHierarchy) g.GetComponent<SquadManager>().resetActions(); } isRoundOver = false; isOtherRoundOver = false; currentStage = TurnStage.None; }
public void gameOver(int playerWinner) { Debug.Log("GAME OVER! PLAYER " + playerWinner + " victory!"); Application.Quit(); isRunning = false; currentStage = TurnStage.None; updateUI(); return; }
// Update is called once per frame void Update() { debugText.text = "Player:" + currentPlayersTurn; debugText.text += " Remaining Actions:" + getSelectedManager().numActions; debugText.text += " Current Stage: "; switch (currentStage) { case TurnStage.None: debugText.text += "None"; break; case TurnStage.Moving: debugText.text += "Moving"; break; case TurnStage.InBetween: debugText.text += "In Between"; break; case TurnStage.Combat: debugText.text += "Combat"; break; }; if (squads.Length > 0) { if (currentStage == TurnStage.None) { //skip turn button if (Input.GetButtonDown("Select")) { nextTurn(); } checkChangeSquad(); checkNewAction(); } else if (currentStage == TurnStage.InBetween) { checkNewAction(); } else if (currentStage == TurnStage.Moving) { //if the squad is no longer moving (triggered if max distance is met) if (!getSelectedManager().midMovement) { //if we have another action if (getSelectedManager().numActions > 0) { currentStage = TurnStage.InBetween; } else currentStage = TurnStage.None; } //user undo else if (Input.GetButtonDown("Circle")) { getSelectedManager().undoMove(); checkStateEndOfAction(); } //user ends early else if (Input.GetButtonDown("Cross")) { getSelectedManager().endMovement(); checkStateEndOfAction(); } else { selectedRB = squads[selectedSquadIndex].GetComponent<Rigidbody>(); float v = Input.GetAxis("JoystickLV"); float h = Input.GetAxis("JoystickLH"); selectedRB.velocity = (Quaternion.Euler(0, getMainCamController().angle, 0) * new Vector3(h, 0, v).normalized) * 20; getMainCamController().setCameraTarget(squads[selectedSquadIndex].transform.position,true); } } else if (currentStage == TurnStage.Combat) { //TODO: enable combat in squad //skip if (Input.GetAxis("DpadV") == -1) { getSelectedManager().skipAction(); checkStateEndOfAction(); } if (Input.GetButtonUp("R1") && targetsInRange.Count > 0) { targetsInRange[selectedTargetIndex].SendMessage("disableLight"); selectedTargetIndex++; selectedTargetIndex %= targetsInRange.Count; targetsInRange[selectedTargetIndex].SendMessage("enableLight"); } if (Input.GetButtonUp("L1") && targetsInRange.Count > 0) { targetsInRange[selectedTargetIndex].SendMessage("disableLight"); selectedTargetIndex--; if (selectedTargetIndex < 0) selectedTargetIndex = targetsInRange.Count - 1; targetsInRange[selectedTargetIndex].SendMessage("enableLight"); } if (Input.GetButtonDown("Cross") && targetsInRange.Count > 0) //A { //if (getSelectedManager().numActions == 2) currentStage = TurnStage.None; //if (getSelectedManager().numActions == 1) currentStage = TurnStage.InBetween; Debug.Log("I shot someone!"); targetsInRange[selectedTargetIndex].SendMessage("takeDamage", 5); getSelectedManager().skipAction(); checkStateEndOfAction(); } if (Input.GetButtonDown("Circle")) //B { if (getSelectedManager().numActions == 2) currentStage = TurnStage.None; if (getSelectedManager().numActions == 1) currentStage = TurnStage.InBetween; //getSelectedManager().skipAction(); checkStateEndOfAction(); } else { //this is where aiming would happen } } setLight(); } }
// Update is called once per frame void Update() { if (!isRunning) { return; } if (squads == null || !isTurn) { //checkRound(); return; } if (squads.Length > 0) { if (currentStage == TurnStage.None) { //skip turn button if (Input.GetButtonDown("Select")) { nextTurn(); } if (isRoundOver) { nextTurn(); } checkChangeSquad(); checkNewAction(); } else if (currentStage == TurnStage.InBetween) { checkNewAction(); } else if (currentStage == TurnStage.Moving) { //if the squad is no longer moving (triggered if max distance is met) if (!getSelectedManager().midMovement) { //if we have another action if (getSelectedManager().numActions > 0) { currentStage = TurnStage.InBetween; } else { currentStage = TurnStage.None; } } //user undo else if (Input.GetButtonDown("Circle")) //B { getSelectedManager().undoMove(); checkStateEndOfAction(); getMainCamController().setCameraTarget(squads[selectedSquadIndex].transform.position); changeUnit.enabled = true; } //user ends early else if (Input.GetButtonDown("Cross")) //A { getSelectedManager().endMovement(); changeUnit.enabled = true; checkStateEndOfAction(); } else { selectedRB = squads[selectedSquadIndex].GetComponent <Rigidbody>(); float v = Input.GetAxis("JoystickLV"); float h = Input.GetAxis("JoystickLH"); selectedRB.velocity = (Quaternion.Euler(0, getMainCamController().angle, 0) * new Vector3(h, 0, v).normalized) * 20; getMainCamController().setCameraTarget(squads[selectedSquadIndex].transform.position, true); attackProj.transform.position = new Vector3(getSelectedManager().transform.position.x, 9, getSelectedManager().transform.position.z); } } else if (currentStage == TurnStage.Combat) { //TODO: enable combat in squad //skip if (Input.GetAxis("DpadV") == -1) { getSelectedManager().skipAction(); checkStateEndOfAction(); } if (currentAttack == AttackType.Basic) { if (TutorialCombat.UpdateTarget(selectedRB.GetComponent <TutorialManager>())) //A { getMainCamController().freezeCamera(2); Debug.Log("I shot someone!"); StartCoroutine(TutorialCombat.fightTarget(selectedRB.gameObject, getSelectedManager().getPower())); getSelectedManager().skipAction(); checkStateEndOfAction(); updateUI(); } if (Input.GetButtonDown("Circle")) //B { if (getSelectedManager().numActions == 2) { currentStage = TurnStage.None; } if (getSelectedManager().numActions == 1) { currentStage = TurnStage.InBetween; } //getSelectedManager().skipAction(); checkStateEndOfAction(); getMainCamController().setCameraTarget(squads[selectedSquadIndex].transform.position, true); } if (Input.GetButtonUp("Square")) { currentAttack = AttackType.Unit; TutorialCombat.reset(); attackProj.enabled = false; Debug.Log("Unit Ability"); getSelectedManager().unitAbility(); } if (Input.GetButtonUp("Triangle")) { currentAttack = AttackType.Squad; TutorialCombat.reset(); attackProj.enabled = false; changeUnit.enabled = true; getSelectedManager().squadAbility(); Debug.Log("Squad Ability"); } } else if (currentAttack == AttackType.Squad && getSelectedManager() != null) // && Input.GetButtonUp("Triangle") { getSelectedManager().squadAbilityUpdate(); } //else if(currentAttack == AttackType.Unit && getSelectedManager() != null) // && Input.GetButtonUp("Square") //{ // getSelectedManager().unitAbilityUpdate(); //} if (Input.GetButtonUp("Circle")) //Reset to basic ability { currentAttack = AttackType.Basic; TutorialCombat.findTargets(selectedRB.gameObject); } } setLight(); } }
private void checkNewAction() { //start move if (Input.GetAxis("DpadH") == -1) { if (getSelectedManager().numActions > 0) { currentStage = TurnStage.Moving; getSelectedManager().startMovement(); } } //start start combat if (Input.GetAxis("DpadH") == 1) { if (getSelectedManager().numActions > 0) { currentStage = TurnStage.Combat; targetsInRange = getTargets(selectedRB.position, 20, currentPlayersTurn); selectedTargetIndex = 0; Debug.Log("Number of targets within range: " + targetsInRange.Count.ToString()); //foreach (GameObject target in targetsInRange) //{ // target.SendMessage("withinRange"); //} } } //skip if (Input.GetAxis("DpadV") == -1) { if (getSelectedManager().numActions > 0) { currentStage = TurnStage.InBetween; getSelectedManager().skipAction(); } if (getSelectedManager().numActions == 0) { currentStage = TurnStage.None; } checkStateEndOfAction(); } }
private void DestinationSelectedTimer_Tick(object sender, EventArgs e) { DestinationSelectedTimer.Stop(); AllMoves = null; Game.Move(new ChessMove(Game.Board.Fields[this.StartField], this.StartField, this.DestinationField)); Stage = TurnStage.Waiting; }
void OnGUI() { //Player 1's hp bar float hpRatio = (float)player1.hpCurrent / (float)player1.hpMax; float targetBarWidth = healthBar.width * hpRatio; float deltaValue = targetBarWidth - healthBar1Width; healthBar1Width += deltaValue / 8; if (Mathf.Abs(deltaValue) < .02f) healthBar1Width = targetBarWidth; if (healthBar1Width == targetBarWidth) targetHealthReached = true; GUI.DrawTexture(new Rect(10, Screen.height - healthBack.height - 20, healthBack.width, healthBack.height), healthBack, ScaleMode.StretchToFill); GUI.DrawTexture(new Rect(10, Screen.height - healthBar.height - 20, healthBar1Width, healthBar.height), healthBar, ScaleMode.StretchToFill); GUI.Label(new Rect(10, Screen.height - 20, 100, 25), player1.hpCurrent + "/" + player1.hpMax); //Player 2's hp bar hpRatio = (float)player2.hpCurrent / (float)player2.hpMax; targetBarWidth = healthBar.width * hpRatio; healthBar2Width += (targetBarWidth - healthBar2Width) / 8; if (Mathf.Abs(targetBarWidth - healthBar2Width) < .02f) healthBar2Width = targetBarWidth; if (healthBar1Width == targetBarWidth) targetHealthReached2 = true; GUI.DrawTexture(new Rect(Screen.width - healthBack.width - 10, Screen.height - healthBack.height - 20, healthBack.width, healthBack.height), healthBack, ScaleMode.StretchToFill); GUI.DrawTexture(new Rect(Screen.width - healthBar2Width - 10, Screen.height - healthBar.height - 20, healthBar2Width, healthBar.height), healthBar, ScaleMode.StretchToFill); GUI.Label(new Rect(Screen.width - 40, Screen.height - 20, 50, 25), player2.hpCurrent + "/" + player2.hpMax); //Player 1's endurance bar float enduranceRatio = (float)player1.enduranceCurrent / (float)player1.enduranceMax; float barHeight = enduranceBar.height * enduranceRatio; enduranceBar1Height += (barHeight - enduranceBar1Height) / 8; if (Mathf.Abs(barHeight - enduranceBar1Height) < .02f) enduranceBar1Height = barHeight; if (enduranceBar1Height == barHeight && playerTurn == PlayerIndex.One) targetEnduranceReached = true; GUI.DrawTexture(new Rect(10, Screen.height - enduranceBack.height - 60, enduranceBack.width, enduranceBack.height), enduranceBack, ScaleMode.StretchToFill); GUI.DrawTexture(new Rect(10, Screen.height - enduranceBar1Height - 60, enduranceBar.width, enduranceBar1Height), enduranceBar, ScaleMode.StretchToFill); GUI.Label(new Rect(15 + enduranceBar.width, Screen.height - 85, 100, 25), player1.enduranceCurrent + "/" + player1.enduranceMax); //Player 2's endurance bar enduranceRatio = (float)player2.enduranceCurrent / (float)player2.enduranceMax; barHeight = enduranceBar.height * enduranceRatio; enduranceBar2Height += (barHeight - enduranceBar2Height) / 8; if (Mathf.Abs(barHeight - enduranceBar2Height) < .02f) enduranceBar2Height = barHeight; if (enduranceBar2Height == barHeight && playerTurn == PlayerIndex.Two) targetEnduranceReached = true; GUI.DrawTexture(new Rect(Screen.width - enduranceBack.width - 10, Screen.height - enduranceBack.height - 60, enduranceBack.width, enduranceBack.height), enduranceBack, ScaleMode.StretchToFill); GUI.DrawTexture(new Rect(Screen.width - enduranceBar.width - 10, Screen.height - enduranceBar2Height - 60, enduranceBar.width, enduranceBar2Height), enduranceBar, ScaleMode.StretchToFill); GUI.Label(new Rect(Screen.width - enduranceBar.width - 45, Screen.height - 85, 100, 25), player2.enduranceCurrent + "/" + player2.enduranceMax); switch (turnStage) //Depending on the turn stage, the GUI does different things { case TurnStage.PlayerStart: //Player must hit button to start their turn string playerString = ""; if (playerTurn == PlayerIndex.One) playerString = "Player 1"; else playerString = "Player 2"; if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 2, 100, 20), playerString + " Start!")) { turnStage = TurnStage.RecoverEndurance; } break; case TurnStage.RecoverEndurance: //Labels the stage GUI.Label(new Rect(Screen.width / 2 - 100, 50, 200, 20), "Recovery Stage"); break; case TurnStage.ChooseAttack: //Labels the stage GUI.Label(new Rect(Screen.width / 2 - 100, 50, 200, 20), "Choose Attack"); for (int i = 0; i < attacker.attackList.Count; i++) //Goes through all the attack options for the current attacker { //Creates a button for each attack option AttackOption atk = attacker.attackList[i]; float cellHeight = 60; //If player has enough endurance, button is green. If not, button is red if (attacker.enduranceCurrent < atk.enduranceCost) GUI.color = Color.red; else GUI.color = Color.green; float yValue = (Screen.height / 2 - (float)attacker.attackList.Count / 2 * cellHeight) + (i * cellHeight) + 10; if (GUI.Button(new Rect(Screen.width / 2 - 200, yValue, 400, 40), "|" + atk.attackName + "| " + atk.attackGroup.ToString() + " " + atk.attackMethod.ToString() + " Power: " + atk.basePower + " Cost: " + atk.enduranceCost + "\n" + atk.attackDescription)) { if(attacker.enduranceCurrent >= atk.enduranceCost){ currentAttack = atk; turnStage = TurnStage.ChooseAttackType; } } } //Player can choose to not attack GUI.color = Color.green; if(GUI.Button (new Rect(Screen.width / 2 - 100, Screen.height / 2 + 200, 200, 40), "Don't Attack")){ currentAttack = null; turnStage = TurnStage.ChooseDefense; } break; case TurnStage.ChooseAttackType: //Player can choose either rock, paper, or scissors for their attack type //Creates a button for each GUI.Label(new Rect(Screen.width / 2 - 100, 50, 200, 20), "Jan-ken Attack!"); float cellHeight2 = 60; float yValue2 = (Screen.height / 2 - 3f / 2 * cellHeight2) + (0 * cellHeight2) + 10; if (GUI.Button(new Rect(Screen.width / 2 - 200, yValue2, 400, 40), "ROCK")) { actionAttack = ActionType.Rock; turnStage = TurnStage.ExecuteAttack; } cellHeight2 = 60; yValue2 = (Screen.height / 2 - 3f / 2 * cellHeight2) + (1 * cellHeight2) + 10; if (GUI.Button(new Rect(Screen.width / 2 - 200, yValue2, 400, 40), "PAPER")) { actionAttack = ActionType.Paper; turnStage = TurnStage.ExecuteAttack; } cellHeight2 = 60; yValue2 = (Screen.height / 2 - 3f / 2 * cellHeight2) + (2 * cellHeight2) + 10; if (GUI.Button(new Rect(Screen.width / 2 - 200, yValue2, 400, 40), "SCISSORS")) { actionAttack = ActionType.Scissors; turnStage = TurnStage.ExecuteAttack; } break; case TurnStage.ChooseDefense: //Labels the stage GUI.Label(new Rect(Screen.width / 2 - 100, 50, 200, 20), "Choose Defense"); for (int i = 0; i < attacker.defendList.Count; i++) //Goes through all the defend options for the current player { //Creates a button for each defend option DefendOption def = attacker.defendList[i]; float cellHeight = 60; //If player has enough endurance, button is green, if not, button is red if (attacker.enduranceCurrent < def.enduranceCost) GUI.color = Color.red; else GUI.color = Color.green; float yValue = (Screen.height / 2 - (float)attacker.attackList.Count / 2 * cellHeight) + (i * cellHeight) + 10; if (GUI.Button(new Rect(Screen.width / 2 - 200, yValue, 400, 40), "|" + def.defendName + "| " + def.defendGroup.ToString() + " " + " Defense strength: " + def.baseDefense + " Cost: " + def.enduranceCost + "\n" + def.defendDescription)) { if(attacker.enduranceCurrent >= def.enduranceCost){ currentDefend = def; turnStage = TurnStage.ChooseDefenseType; attacker.UseEndurance(currentDefend.enduranceCost); } } } //Player can choose to not defend GUI.color = Color.green; if(GUI.Button (new Rect(Screen.width / 2 - 100, Screen.height / 2 + 100, 200, 40), "Don't Defend")){ currentDefend = null; turnStage = TurnStage.ChooseDefenseType; } break; case TurnStage.ChooseDefenseType: //If the player has chosen to defend, they can choose rock, paper, or scissors for defend type if(currentDefend != null){ GUI.Label(new Rect(Screen.width / 2 - 100, 50, 200, 20), "Jan-ken Attack!"); cellHeight2 = 60; yValue2 = (Screen.height / 2 - 3f / 2 * cellHeight2) + (0 * cellHeight2) + 10; if (GUI.Button(new Rect(Screen.width / 2 - 200, yValue2, 400, 40), "ROCK")) { actionDefend = ActionType.Rock; turnStage = TurnStage.PlayerStart; if(playerTurn == PlayerIndex.One) playerTurn = PlayerIndex.Two; else playerTurn = PlayerIndex.One; DefendParticleGo(); } cellHeight2 = 60; yValue2 = (Screen.height / 2 - 3f / 2 * cellHeight2) + (1 * cellHeight2) + 10; if (GUI.Button(new Rect(Screen.width / 2 - 200, yValue2, 400, 40), "PAPER")) { actionDefend = ActionType.Paper; turnStage = TurnStage.PlayerStart; if(playerTurn == PlayerIndex.One) playerTurn = PlayerIndex.Two; else playerTurn = PlayerIndex.One; DefendParticleGo(); } cellHeight2 = 60; yValue2 = (Screen.height / 2 - 3f / 2 * cellHeight2) + (2 * cellHeight2) + 10; if (GUI.Button(new Rect(Screen.width / 2 - 200, yValue2, 400, 40), "SCISSORS")) { actionDefend = ActionType.Scissors; turnStage = TurnStage.PlayerStart; if(playerTurn == PlayerIndex.One) playerTurn = PlayerIndex.Two; else playerTurn = PlayerIndex.One; DefendParticleGo(); } } else //If there was no defend chosen, then we just skip ahead { turnStage = TurnStage.PlayerStart; if(playerTurn == PlayerIndex.One) playerTurn = PlayerIndex.Two; else playerTurn = PlayerIndex.One; } break; case TurnStage.EndOfBattle: //Displays which player won and provides a button that will take players to the upgrade screen playerString = ""; if (losingPlayer.playerIndex == PlayerIndex.Two) playerString = "Player 1"; else playerString = "Player 2"; if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 2, 100, 20), playerString + " Wins!")) { battleEnd = true; } break; } }
/// <summary> /// Handle mouse clicks /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BoardPictureBox_MouseClick(object sender, MouseEventArgs e) { // Do not allow play if computer turn if (Game.PlayerTypes[Game.Board.Turn] == PlayerType.Computer || Game.GameResult != GameResult.Undecided) return; // Get all possible moves if (AllMoves == null) AllMoves = Game.Board.GetAllMoves(Game.Board.Turn); int field = (e.X / 30) + ((240-e.Y) / 30) * 8; bool drawSquare = false; Pen squarePen = null; if (Stage == TurnStage.Waiting) { StartField = field; if (Game.Board.Fields[StartField] != ChessPiece.None && Game.Board.Turn == (Game.Board.Fields[StartField] & ChessPiece.Suit)) { Stage = TurnStage.StartSelected; drawSquare = true; squarePen = new Pen(Color.Red); } } else if (Stage == TurnStage.StartSelected) { DestinationField = field; if (DestinationField == StartField) { DrawGame(); Stage = TurnStage.Waiting; } //else if (Game.Board.IsLegalMove(Game.Board.Fields[StartField], DestinationField)) else if (AllMoves.Any(m => m.From == StartField && m.To == DestinationField)) { Stage = TurnStage.DestinationSelected; drawSquare = true; squarePen = new Pen(Color.Red); DestinationSelectedTimer.Start(); } } if (drawSquare) { squarePen.Width = 2; Graphics graphics = Graphics.FromImage(BoardImage); int x = (field % 8) * 30; int y = 210 - (field / 8) * 30; graphics.DrawRectangle(squarePen, x, y, 30, 30); BoardPictureBox.Image = BoardImage; } }
private void checkStateEndOfAction() { if (targetsInRange.Count > 0) { foreach (GameObject target in targetsInRange) { if(target.activeInHierarchy) target.SendMessage("disableLight"); } targetsInRange.Clear(); } if (getSelectedManager ().numActions == SquadManager.MAX_ACTIONS|| getSelectedManager ().numActions == 0) { currentStage = TurnStage.None; if (checkTurnComplete ()) nextTurn (); else selectNextAvalibleSquad(); } else currentStage = TurnStage.InBetween; }
//Does turn stage stuff void ExecuteTurn() { //Execute the turn based on which stage we're in switch (turnStage) { case TurnStage.RecoverEndurance: if (turnCounter == 0) //Recover endurance and start particle effect { attacker.RecoverEndurance(attacker.enduranceRegen); targetEnduranceReached = false; Instantiate(enduranceParticle, attacker.profileObject.transform.position, Quaternion.identity); turnCounter++; } if (targetEnduranceReached) //Once the endurance bar has reached its target value, we move on { turnStage = TurnStage.ChooseAttack; turnCounter = 0; } break; case TurnStage.ExecuteAttack: //We now attack based on the attack option and type previously selected if(turnCounter == 0){ targetHealthReached = false; targetEnduranceReached = false; if ( currentAttack.attackMethod == AttackMethod.Attack){ attacker.UseEndurance(currentAttack.enduranceCost); //check for defense up int damage = currentAttack.basePower; switch (currentAttack.attackGroup) { case ActionGroup.Group1: Instantiate(attack1Particle, defender.profileObject.transform.position, Quaternion.identity); break; case ActionGroup.Group2: Instantiate(attack2Particle, defender.profileObject.transform.position, Quaternion.identity); break; case ActionGroup.Group3: Instantiate(attack3Particle, defender.profileObject.transform.position, Quaternion.identity); break; } if(currentDefend != null){ float defence = currentDefend.baseDefense; //rock paper scissors //attacker wins, defense 50% //tie, defense 100% //defender win, defense 150% float efffectiveness = 1.0f; //a tie if(actionAttack == actionDefend) efffectiveness = 1.0f; //cases when attacker wins if(actionAttack == ActionType.Rock && actionDefend == ActionType.Scissors) efffectiveness = 0.5f; if(actionAttack == ActionType.Paper && actionDefend == ActionType.Rock) efffectiveness = 0.5f; if(actionAttack == ActionType.Scissors && actionDefend == ActionType.Paper) efffectiveness = 0.5f; //cases defender wins if(actionDefend == ActionType.Rock && actionAttack == ActionType.Scissors) efffectiveness = 1.5f; if(actionDefend == ActionType.Paper && actionAttack == ActionType.Rock) efffectiveness = 1.5f; if(actionDefend == ActionType.Scissors && actionAttack == ActionType.Paper) efffectiveness = 1.5f; defence *= efffectiveness; Debug.Log (efffectiveness); Debug.Log (defence); damage -= (int)defence; } if (damage < 0) { if(-damage > attacker.hpCurrent) damage = -attacker.hpCurrent; attacker.LoseHP(-damage); defender.chiPoints += damage / 10; } else { if(damage > defender.hpCurrent) damage = defender.hpCurrent; defender.LoseHP(damage); attacker.chiPoints += damage / 10; } } //If meditated instead of attacked else if (currentAttack.attackMethod == AttackMethod.Meditation){ attacker.RecoverEndurance(currentAttack.basePower); Instantiate(enduranceParticle, attacker.profileObject.transform.position, Quaternion.identity); currentDefend = new DefendOption("gimp", currentAttack.attackGroup, -((int)currentAttack.attackGroup)*5, 0, "gimped by meditation"); } turnCounter++; } if(targetEnduranceReached){ //If ether player has reached zero HP, then the battle is over if(player1.hpCurrent <= 0 || player2.hpCurrent <= 0) { //Set the losing player if (player1.hpCurrent <= 0) { losingPlayer = player1; } else { losingPlayer = player2; } turnStage = TurnStage.EndOfBattle; turnCounter = 0; break; } if (currentAttack.attackMethod == AttackMethod.Attack) turnStage = TurnStage.ChooseDefense; else { turnStage = TurnStage.ChooseDefenseType; } turnCounter = 0; } break; case TurnStage.EndOfBattle: //Battle is over, set the loser on fire and wait for someone to hit the button if (turnCounter == 0) { Instantiate(dyingFlames, losingPlayer.profileObject.transform.position, Quaternion.identity); turnCounter++; } break; } if( battleEnd) EndBattle(); }
// Update is called once per frame void Update() { debugText.text = "Player:" + currentPlayersTurn; debugText.text += " Remaining Actions:" + getSelectedManager().numActions; debugText.text += " Current Stage: "; switch (currentStage) { case TurnStage.None: debugText.text += "None"; break; case TurnStage.Moving: debugText.text += "Moving"; break; case TurnStage.InBetween: debugText.text += "In Between"; break; case TurnStage.Combat: debugText.text += "Combat"; break; } ; if (squads.Length > 0) { if (currentStage == TurnStage.None) { //skip turn button if (Input.GetButtonDown("Select")) { nextTurn(); } checkChangeSquad(); checkNewAction(); } else if (currentStage == TurnStage.InBetween) { checkNewAction(); } else if (currentStage == TurnStage.Moving) { //if the squad is no longer moving (triggered if max distance is met) if (!getSelectedManager().midMovement) { //if we have another action if (getSelectedManager().numActions > 0) { currentStage = TurnStage.InBetween; } else { currentStage = TurnStage.None; } } //user undo else if (Input.GetButtonDown("Circle")) { getSelectedManager().undoMove(); checkStateEndOfAction(); } //user ends early else if (Input.GetButtonDown("Cross")) { getSelectedManager().endMovement(); checkStateEndOfAction(); } else { selectedRB = squads[selectedSquadIndex].GetComponent <Rigidbody>(); float v = Input.GetAxis("JoystickLV"); float h = Input.GetAxis("JoystickLH"); selectedRB.velocity = (Quaternion.Euler(0, getMainCamController().angle, 0) * new Vector3(h, 0, v).normalized) * 20; getMainCamController().setCameraTarget(squads[selectedSquadIndex].transform.position, true); } } else if (currentStage == TurnStage.Combat) { //TODO: enable combat in squad //skip if (Input.GetAxis("DpadV") == -1) { getSelectedManager().skipAction(); checkStateEndOfAction(); } if (Input.GetButtonUp("R1") && targetsInRange.Count > 0) { targetsInRange[selectedTargetIndex].SendMessage("disableLight"); selectedTargetIndex++; selectedTargetIndex %= targetsInRange.Count; targetsInRange[selectedTargetIndex].SendMessage("enableLight"); } if (Input.GetButtonUp("L1") && targetsInRange.Count > 0) { targetsInRange[selectedTargetIndex].SendMessage("disableLight"); selectedTargetIndex--; if (selectedTargetIndex < 0) { selectedTargetIndex = targetsInRange.Count - 1; } targetsInRange[selectedTargetIndex].SendMessage("enableLight"); } if (Input.GetButtonDown("Cross") && targetsInRange.Count > 0) //A { //if (getSelectedManager().numActions == 2) currentStage = TurnStage.None; //if (getSelectedManager().numActions == 1) currentStage = TurnStage.InBetween; Debug.Log("I shot someone!"); targetsInRange[selectedTargetIndex].SendMessage("takeDamage", 5); getSelectedManager().skipAction(); checkStateEndOfAction(); } if (Input.GetButtonDown("Circle")) //B { if (getSelectedManager().numActions == 2) { currentStage = TurnStage.None; } if (getSelectedManager().numActions == 1) { currentStage = TurnStage.InBetween; } //getSelectedManager().skipAction(); checkStateEndOfAction(); } else { //this is where aiming would happen } } setLight(); } }
void SwitchStage() { nextStageTimer = stageWaitTime; if (ts == TurnStage.end) { ts = TurnStage.start; } else { ts = ts + 1; } switch (ts) { case TurnStage.start: break; case TurnStage.prepare: break; case TurnStage.play: break; case TurnStage.curse: for (int i = 0; i < battleField.GetCards().Count; i++) { Card item = battleField.GetCard(i); bool ret = item.OnCurse(); if (PlayerPrefs.GetInt("Difficult") >= 3) { bool ret2 = item.OnCurse(); ret = (ret || ret2); } if (ret) { GameObject go = item.GetCursedCard(); if (go is null) { Debug.LogError("Invalid null cursed card"); } else { GameObject go_tmp = GameObject.Instantiate(go, cardsInstance.transform); go_tmp.GetComponent <Card>().SetLastCursed(); battleField.SetCard(i, go_tmp.GetComponent <Card>()); } } } break; case TurnStage.wrath: int index = 0; foreach (var item in battleField.GetCards()) { bool ret = item.OnWrath(); //if (ret) //{ // Vector3 pos = battleField.GetCardPos(index); // FangAnim.transform.position = pos; // GameObject go = GameObject.Instantiate(FangAnim); // Destroy(go, 35.0f/60.0f); //} index++; } break; case TurnStage.discard: hand.DiscardAll(); break; case TurnStage.draw: playedCards.DiscardAll(); hand.DrawCards(drawEveryTurn); break; case TurnStage.end: gold = 0; attack = 0; if (battleDeck.GetCount() == 0) { bool winFlag = true; foreach (var item in battleField.GetCards()) { if (item.getCostType() == CostType.attack) { winFlag = false; } } if (winFlag) { PlayerPrefs.SetInt("score", score); SceneManager.LoadScene("end_victory"); } } break; default: break; } RefreshUI_All(); }
public void Send_ChangeTurn(TurnStage stage, int playerTurnNumber, int time) { string msg = SendNames.newstage + "|" + playerTurnNumber + "|" + stage + "|" + time; Send(msg, reliableChannel); }