public void FirstServe() { Player victim = null; foreach (Player player in players) { if (LastCarder == player.playerNum) { victim = player; } } if (victim == null) { Debug.Log("First Serve error: null victim"); } if (victim != null) { victim.AddCard(Draw()); Debug.Log("Adding card to:" + victim.playerNum); if (victim.hand.Count == 3) { CleanUp(); phase = TurnPhase.idle; PassTurn(victim.playerNum); } } }
public void PassTurn(int num = -1) { Utils.tr("LostCities:PassTurn()", "Current Player: " + players.IndexOf(CURRENT_PLAYER)); int lastPlayerNum = 0; int ndx = players.IndexOf(CURRENT_PLAYER); lastPlayerNum = players.IndexOf(CURRENT_PLAYER); if (ndx == 0) { num = 1; } else if (ndx == 1) { num = 0; } if (CURRENT_PLAYER != null) { lastPlayerNum = CURRENT_PLAYER.playerNum; // Check for Game Over and need to reshuffle discards /* * if (CheckGameOver()) * { * return; * }*/ } CURRENT_PLAYER = players[num]; phase = TurnPhase.pre; CURRENT_PLAYER.TakeTurn(); // Report the turn passing Utils.tr("LostCities:PassTurn()", "Old: " + lastPlayerNum, "New: " + CURRENT_PLAYER.playerNum); }
private void SetUI(TurnPhase phase) { switch (phase) { case TurnPhase.Initial: label2.Text = (now_player + 1).ToString(); label4.Text = players[now_player].Money.ToString(); label6.Text = players[now_player].State.ToString(); players[now_player].Image.BringToFront(); button1.Enabled = true; button2.Enabled = false; break; case TurnPhase.Walk: label6.Text = step.ToString(); button1.Enabled = false; button2.Enabled = false; break; case TurnPhase.Dice: button1.Enabled = true; button2.Enabled = false; break; case TurnPhase.End: button1.Enabled = false; button2.Enabled = true; break; } }
/// <summary> /// 要求两边都是实例,不能是prefab /// 经过一次实验,这个功能但对对dramaPhase使用,因为dramaphase默认没有next /// 如果是插入形式,会使正常流程的下一步被null替代 /// </summary> /// <param name="_toPhase">会被自动设置成为激活,等待流程激活</param> public void AppendPhase(TurnPhase _toPhase) { if (_toPhase == null) { return; } _toPhase.gameObject.SetActive(false); //TODO 保险,如果对非实例进行nextPhaseDefault的修改,就报错 if (gameObject.scene.name == null) { Debug.LogError("不应该对预制体进行这步操作"); } if (nextPhaseDefault != null && nextPhaseDefault.gameObject.scene.name == null) { Debug.LogError("不应该对预制体进行这步操作"); return; } //TurnPhase _temp = nextPhaseDefault; //if (nextPhaseDefault != null) //_toPhase.nextPhaseDefault = _temp; //接入链表 nextPhaseDefault = _toPhase; }
public void PassTurn(int num = -1) { // Если порядковый номер игрока не указан, выбрать следующего по кругу if (num == -1) { int ndx = players.IndexOf(CURRENT_PLAYER); num = (ndx + 1) % 4; } int lastPlayerNum = -1; if (CURRENT_PLAYER != null) { lastPlayerNum = CURRENT_PLAYER.playerNum; if (CheckGameOver()) { return; } } CURRENT_PLAYER = players[num]; phase = TurnPhase.pre; CURRENT_PLAYER.TakeTurn(); // Сообщить о передаче хода Utils.tr("Bartok:PassTurn()", "Old: " + lastPlayerNum, "New: " + CURRENT_PLAYER.playerNum); }
}//public void public void PassTurn(int num = -1) { if (num == -1) { int ndx = players.IndexOf(CURRENT_PLAYER); num = (ndx + 1) % 4; }//if int lastPlayerNum = -1; if (CURRENT_PLAYER != null) { lastPlayerNum = CURRENT_PLAYER.playerNum; if (CheckGameOver()) { return; } }//if CURRENT_PLAYER = players[num]; phase = TurnPhase.pre; CURRENT_PLAYER.TakeTurn(); Utils.tr("Bartok:PassTurn()", "Old: " + lastPlayerNum, "New: " + CURRENT_PLAYER.playerNum); }
public void PassTurn(int num = -1) { // if no number was passed in, pick the next player if (num == -1) { int ndx = players.IndexOf(CURRENT_PLAYER); num = (ndx + 1) % 4; } int lastPlayerNum = -1; if (CURRENT_PLAYER != null) { lastPlayerNum = CURRENT_PLAYER.playerNum; if (CheckForGameOver()) { return; } } CURRENT_PLAYER = players[num]; phase = TurnPhase.pre; CURRENT_PLAYER.TakeTurn(); Utils.tr("FlipOut: PassTurn()", "Old: " + lastPlayerNum, "New: " + CURRENT_PLAYER.playerNum); }
public void PassTurn(int num = -1) { if (num == -1) { int ndx = players.IndexOf(CURRENT_PLAYER); num = (ndx + 1) % 4; } int lastPlayerNum = -1; if (CURRENT_PLAYER != null) { lastPlayerNum = CURRENT_PLAYER.playerNum; if (CheckGameOver()) { return; } } CURRENT_PLAYER = players[num]; phase = TurnPhase.pre; CURRENT_PLAYER.TakeTurn(); Vector3 lPos = CURRENT_PLAYER.handSLotDef.pos + Vector3.back * 5; turnLight.transform.position = lPos; Utils.tr(Utils.RoundToPlaces(Time.time), "Bartok.PassTurn()", "Old: " + lastPlayerNum, "New: " + CURRENT_PLAYER.playerNum); }
public void StopAttackPhase() { selectedSlot = null; DelselectCard(); currentPhase = TurnPhase.Main; CamBehaviour.singleton.SwitchToPosition(0); }
public void PassTurn(int num = -1) { // If no number was passed in, pick the next player if (num == -1) { int ndx = players.IndexOf(CURRENT_PLAYER); num = (ndx + 1) % 4; } int lastPlayerNum = -1; if (CURRENT_PLAYER != null) { lastPlayerNum = CURRENT_PLAYER.playerNum; // Check for Game Over and need to reshuffle discards if (CheckGameOver()) { return; } } CURRENT_PLAYER = players[num]; phase = TurnPhase.pre; CURRENT_PLAYER.TakeTurn(); // Move the TurnLight to shine on the new CURRENT_PLAYER Vector3 lPos = CURRENT_PLAYER.handSlotDef.pos + Vector3.back * 5; turnLight.transform.position = lPos; // Report the turn passing Utils.tr(Utils.RoundToPlaces(Time.time), "Bartok.PassTurn()", "Old: " + lastPlayerNum, "New: " + CURRENT_PLAYER.playerNum); }
public void CardClicked(CardBartok tCB) { // If it's not the human's turn, don't respond if (CURRENT_PLAYER.type != PlayerType.human) return; // If the game is waiting on a card to move, don't respond if (phase == TurnPhase.waiting) return; // Act differently based on whether it was a card in hand // or on the drawPile that was clicked switch (tCB.state) { case CBState.drawpile: // Draw the top card, not necessarily the one clicked. CardBartok cb = CURRENT_PLAYER.AddCard( Draw() ); cb.callbackPlayer = CURRENT_PLAYER; Utils.tr (Utils.RoundToPlaces(Time.time), "Bartok.CardClicked()","Draw",cb.name); phase = TurnPhase.waiting; break; case CBState.hand: // Check to see whether the card is valid if (ValidPlay(tCB)) { CURRENT_PLAYER.RemoveCard(tCB); MoveToTarget(tCB); tCB.callbackPlayer = CURRENT_PLAYER; Utils.tr(Utils.RoundToPlaces(Time.time), "Bartok.CardClicked()", "Play",tCB.name,targetCard.name+" is target"); phase = TurnPhase.waiting; } else { // Just ignore it Utils.tr(Utils.RoundToPlaces(Time.time), "Bartok.CardClicked()", "Attempted to Play",tCB.name,targetCard.name+" is target"); } break; } }
public bool CheckGameOver() { // See if we need to reshuffle the discard pile into the draw pile if (drawPile.Count == 0) { List <Card> cards = new List <Card>(); foreach (CardBartok cb in discardPile) { cards.Add(cb); } discardPile.Clear(); Deck.Shuffle(ref cards); drawPile = UpgradeCardsList(cards); ArrangeDrawPile(); } // Check to see if the current player has won if (CURRENT_PLAYER.hand.Count == 0) { // The current player has won! if (CURRENT_PLAYER.type == PlayerType.human) { GTRoundResult.SetActive(true); } else { GTGameOver.SetActive(true); } phase = TurnPhase.gameOver; Invoke("RestartGame", 1); return(true); } return(false); }
public void PassTurn(int num = -1) { // f // If no number was passed in, pick the next player if (num == -1) { int ndx = players.IndexOf(CURRENT_PLAYER); num = (ndx + 1) % 4; } int lastPlayerNum = -1; if (CURRENT_PLAYER != null) { lastPlayerNum = CURRENT_PLAYER.playerNum; // Check for Game Over and need to reshuffle discards if (CheckGameOver()) { return; } } CURRENT_PLAYER = players[num]; phase = TurnPhase.pre; CURRENT_PLAYER.TakeTurn(); // g // Report the turn passing Utils.tr("Bartok:PassTurn()", "Old: " + lastPlayerNum, "New: " + CURRENT_PLAYER.playerNum); }
public void EndPhase() { if (currentPhase == TurnPhase.PlayFinal) currentPhase = TurnPhase.Upkeep; else currentPhase++; }
/// <summary> /// Just a simple function to help us know the order of events without having to hard code in transitions /// </summary> /// <param name="p"> /// The state we want to find the next state from /// </param> /// <returns> /// The state that occurs after p /// </returns> private TurnPhase nextPhase(TurnPhase p) { switch (p) { case TurnPhase.PreTurn: return(TurnPhase.Renewal); break; case TurnPhase.Renewal: return(TurnPhase.MainPhase); break; case TurnPhase.MainPhase: return(TurnPhase.Cleanup); break; case TurnPhase.Cleanup: return(TurnPhase.PrePass); break; case TurnPhase.PrePass: return(TurnPhase.PreTurn); break; } return(TurnPhase.PreTurn); }
private IEnumerator TurnStart() { currentPhase = TurnPhase.Start; DrawCard(1); foreach (var card in creaturesOnField) { if (card == null) { creaturesOnField.Remove(card); } else if (card.currentSlot.id_X == 1) { card.canAttack = true; } } if (CurrentMaxAp < maxAP) { CurrentMaxAp++; } currentAP = CurrentMaxAp; yield return(new WaitForSeconds(.1f)); StartCoroutine(PickingCard()); }
public void CardClicked(CardBartok tCB) { if (CURRENT_PLAYER.type != PlayerType.human) return; if (phase == TurnPhase.waiting) return; switch (tCB.state) { case CBState.drawpile: CardBartok cb = CURRENT_PLAYER.AddCard(Draw()); cb.callbackPlayer = CURRENT_PLAYER; Utils.tr(Utils.RoundToPlaces(Time.time),"Bartok.CardClicked()","Draw",cb.name); phase = TurnPhase.waiting; break; case CBState.hand: if(ValidPlay(tCB)){ CURRENT_PLAYER.RemoveCard(tCB); MoveToTarget(tCB); tCB.callbackPlayer = CURRENT_PLAYER; Utils.tr(Utils.RoundToPlaces(Time.time),"Bartok.CardClicked()","Play",tCB.name,targetCard.name + "is target"); phase = TurnPhase.waiting; }else{ Utils.tr(Utils.RoundToPlaces(Time.time),"Bartok.CardClicked()","Attempted to Play",tCB.name +" is target"); } break; } }
virtual protected void Start() { playerName = ProfileData.currentProfile != null ? ProfileData.currentProfile.profileName : "No profile"; graphicRaycaster = GetComponentInChildren <GraphicRaycaster>(); layout = handObj.GetComponent <HorizontalLayoutGroup>(); deck.Init(); curLifePoints = lifePoints; CurrentMaxAp = (isPlayerA) ? 0 : 1; field = (isPlayerA) ? Board.fieldA : Board.fieldB; playerSlot.Init(-1, -1); foreach (var slot in field) { slot.Unlock(); slot.owner = this; } deck.Shuffle(); StackDeck(); DrawCard(startingHandSize); if (isPlayerA) { StartTurn(); } else { currentPhase = TurnPhase.End; } }
public bool CheckForGameOver() { // see if we need to reshuffle the disP into the draP if (drawPile.Count == 0) { List <Card> cards = new List <Card>(); foreach (CardFlipOut cb in discardPile) { cards.Add(cb); } discardPile.Clear(); Deck.Shuffle(ref cards); drawPile = UpgradeCardsList(cards); ArrangeDrawPile(); } // check to see if the current player has won if (CURRENT_PLAYER.hand.Count == 0) { phase = TurnPhase.gameOver; Invoke("RestartGame", 1); return(true); } return(false); }
public virtual Wait StartTurn() { Wait wait = TurnTaker.StartTurn(this); Phase = TurnPhase.Tick; return(wait); }
public void CardClicked(CardBartok tCB) { if (CURRENT_PLAYER.type != PlayerType.human) { return; } if (phase == TurnPhase.waiting) { return; } switch (tCB.state) { case CBState.drawpile: CardBartok cb = CURRENT_PLAYER.AddCard(Draw()); cb.callbackPlayer = CURRENT_PLAYER; Utils.tr("Bartok:CardClicked()", "Draw", cb.name); phase = TurnPhase.waiting; break; case CBState.hand: if (ValidPlay(tCB)) { CURRENT_PLAYER.RemoveCard(tCB); MoveToTarget(tCB); tCB.callbackPlayer = CURRENT_PLAYER; Utils.tr("Bartok:CardClicked()", "Play", tCB.name, targetCard.name + " is target"); phase = TurnPhase.waiting; } else { Utils.tr("Bartok:CardClicked()", "Attempted to Play", tCB.name, targetCard.name + " is target"); } break; } }
public void NextPhase() { switch (turnPhase) { case TurnPhase.begin: turnPhase = TurnPhase.draw; break; case TurnPhase.draw: turnPhase = TurnPhase.main; break; case TurnPhase.main: turnPhase = TurnPhase.end; break; case TurnPhase.movement: turnPhase = TurnPhase.combat; break; case TurnPhase.combat: turnPhase = TurnPhase.end; break; case TurnPhase.end: ChangePlayerTurn(); break; default: break; } }
public void PassTurn(int num = -1) { // f // If no number was passed in, pick the next player if(num == -1) { int ndx = players.IndexOf(CURRENT_PLAYER); num = (ndx + 1) % 4; } int lastPlayerNum = -1; if(CURRENT_PLAYER != null) { lastPlayerNum = CURRENT_PLAYER.playerNum; if (CheckGameOver()) { return; // a } } CURRENT_PLAYER = players[num]; phase = TurnPhase.pre; CURRENT_PLAYER.TakeTurn(); // g // Report the turn passing Utils.tr("Bartok:PassTurn()", "Old: " + lastPlayerNum, // h "New: " + CURRENT_PLAYER.playerNum); // h }
public bool checkGameOver() { int done = 0; foreach (PlayerBl pl in players) { if (pl.stay == true || pl.bust == true) { done++; } } if (done == 4) { phase = TurnPhase.gameOver; foreach (PlayerBl pl in players) { pl.showHand(); } Invoke("calculateScores", 2); return(true); } else { return(false); } }
public bool CheckGameOver() { // Проверить, нужно ли перетасовать стопку сброшенных карт и перенести ее в стопку свободных карт if (drawPile.Count == 0) { List <Card> cards = new List <Card>(); foreach (CardBartok cb in discardPile) { cards.Add(cb); } discardPile.Clear(); Deck.Shuffle(ref cards); drawPile = UpgradeCardsList(cards); ArrangeDrawPile(); } // Проверить победу текущего игрока if (CURRENT_PLAYER.hand.Count == 0) { // Победивший игрок: phase = TurnPhase.gameOver; Invoke("RestartGame", 1); return(true); } return(false); }
public void cardClicked(CardBlackjack tCB) { if (CURRENT_PLAYER == null) { return; } if (CURRENT_PLAYER.type != PlayerType.human) { return; } if (phase == TurnPhase.waiting) { return; } switch (tCB.state) { case CBlState.drawpile: CardBlackjack cb = CURRENT_PLAYER.addCard(draw()); cb.callbackPlayer = CURRENT_PLAYER; Utils.tr(Utils.RoundToPlaces(Time.time), "Blackjack.cardClicked()", "Draw", cb.name); phase = TurnPhase.waiting; break; case CBlState.hand: if (CURRENT_PLAYER.type == PlayerType.human && tCB.player == 0) { print("Stay"); CURRENT_PLAYER.stay = true; passTurn(); } break; } }
public void NextPhase() { if (currentPhase == TurnPhase.Start) currentPhase = TurnPhase.Main; else if (currentPhase == TurnPhase.Main){ currentPhase = TurnPhase.End; } }
/// <summary> /// Runs the exiting state function of the passed parameter /// </summary> /// <param name="p"></param> private void runExitingStateFunction(TurnPhase p) { switch (p) { case TurnPhase.PreTurn: break; case TurnPhase.Renewal: break; case TurnPhase.MainPhase: break; case TurnPhase.Cleanup: break; case TurnPhase.PrePass: break; } }
}//end of CardClicked(CardBartok tCB) public bool CheckGameOver(){ //do we need to reshuffle the discard pile into the draw pile? if (drawPile.Count == 0) { List<Card> cards = new List<Card> (); foreach (CardBartok cb in discardPile) cards.Add (cb); discardPile.Clear (); Deck.Shuffle (ref cards); drawPile = UpgradeCardsList (cards); ArrangeDrawPile (); }//end of if //has the current player won? if(CURRENT_PLAYER.hand.Count == 0){ if (CURRENT_PLAYER.type == PlayerType.human) { GTGameOver.GetComponent<GUIText> ().text = "You Won!"; GTRoundResult.GetComponent<GUIText> ().text = ""; }//end of nested if else { GTGameOver.GetComponent<GUIText> ().text = "Game Over"; GTRoundResult.GetComponent<GUIText> ().text = "Player " + CURRENT_PLAYER.playerNum + " won"; }//end of else GTGameOver.SetActive (true); GTRoundResult.SetActive (true); phase = TurnPhase.gameOver; Invoke ("RestartGame", 3); return(true); }//end of if return false; }//end of CheckGameOver()
public bool CheckGameOver() { if (drawPile.Count == 0) { List <Card> cards = new List <Card> (); foreach (CardBartok cb in discardPile) { cards.Add(cb); } discardPile.Clear(); Deck.Shuffle(ref cards); drawPile = UpgradeCardsList(cards); ArrangeDrawPile(); } if (CURRENT_PLAYER.hand.Count == 0) { if (CURRENT_PLAYER.type == PlayerType.human) { GTGameOver.GetComponent <GUIText>().text = "You Won!"; GTRoundResult.GetComponent <GUIText>().text = ""; } else { GTGameOver.GetComponent <GUIText>().text = "Game Over"; GTRoundResult.GetComponent <GUIText>().text = "Player " + CURRENT_PLAYER.playerNum + " won"; } GTGameOver.SetActive(true); GTRoundResult.SetActive(true); phase = TurnPhase.gameOver; Invoke("RestartGame", 1); return(true); } return(false); }
void SwitchDisplay(TurnPhase newTurnPhase) { if (newTurnPhase != TurnPhase.Beginning) { return; } }
public void Advance() { if (TurnPhase != TurnPhase.CLEANUP) { TurnPhase++; return; } //on cleanup PlayerOnTurn = Players[(Players.IndexOf(PlayerOnTurn) + 1) % Players.Count]; if (StartingPlayer == PlayerOnTurn) { TurnNumber++; } //check game end triggers if (EmptyStacks == 3 || RemainingProvinces == 0) { TurnPhase = TurnPhase.GAME_END; } else { TurnPhase = TurnPhase.ACTION; } }
public bool CheckGameOver() { if (drawPile.Count == 0) { List <Card> cards = new List <Card>(); foreach (CardBartok cb in discardPile) { cards.Add(cb); } discardPile.Clear(); Deck.Shuffle(ref cards); drawPile = UpgradeCardsList(cards); ArrangeDrawPile(); } if (olympusCount >= 100) { if (winner == 1) { gtGameOver.GetComponent <GUIText> ().text = "You Won!"; } else { gtGameOver.GetComponent <GUIText>().text = "Game Over"; gtRoundResult.GetComponent <GUIText>().text = "Player " + winner + " won"; } gtGameOver.SetActive(true); gtRoundResult.SetActive(true); phase = TurnPhase.gameover; Invoke("RestartGame", 1); return(true); } return(false); }
public bool CheckGameOver() { // See if we need to reshuffle the discard pile into the draw pile if (drawPile.Count == 0) { List <Card> cards = new List <Card>(); foreach (CardBartok cb in discardPile) { cards.Add(cb); } discardPile.Clear(); Deck.Shuffle(ref cards); drawPile = UpgradeCardsList(cards); ArrangeDrawPile(); } // Check to see if the current player has won if (CURRENT_PLAYER.hand.Count == 0) { // The player that just played has won! phase = TurnPhase.gameOver; Invoke("RestartGame", 1); // b return(true); } return(false); }
public void ProgressTurn() { if(player1Turn == true){ player1Turn = false; currentPhase = TurnPhase.Start; return; } else { gameTurn ++; player1Turn = true; currentPhase = TurnPhase.Start; } }
/// <summary> /// Notify this controller than the current unit has finished its current attack order. /// </summary> protected override void UnitDoneAttacking(UnitAttackResponse response) { string debugString = string.Format ("{0} received a report that {1} finished attacking.", this.name, currentUnit.name); Debug.Log(debugString); if (response.validAttack) { hasAlreadyAttacked = true; } else { // TODO Report to user that the attack was illegal } currentPhase = TurnPhase.Finish; }
public bool CheckGameOver() { // See if we need to reshuffle the discard pile into the draw pile if (drawPile.Count == 0) { List<Card> cards = new List<Card>(); foreach (CardBartok cb in discardPile) { cards.Add(cb); } discardPile.Clear(); Deck.Shuffle(ref cards); drawPile = UpgradeCardsList(cards); ArrangeDrawPile(); } // Check to see if the current player has won if (CURRENT_PLAYER.hand.Count == 0) { // The current player has won! if (CURRENT_PLAYER.type == PlayerType.human) { GTGameOver.GetComponent<GUIText>().text = "You Won!"; GTRoundResult.GetComponent<GUIText>().text = ""; } else { GTGameOver.GetComponent<GUIText>().text = "Game Over"; GTRoundResult.GetComponent<GUIText>().text = "Player " + CURRENT_PLAYER.playerNum + " won"; } GTGameOver.SetActive(true); GTRoundResult.SetActive(true); phase = TurnPhase.gameOver; Invoke("RestartGame", 1); return (true); } return (false); }
// Update is called once per frame void Update() { //print ("PlayerMovement UPDATE"); if(bIsPlayerTurn) { if(bIsBeginningOfTurn) { CurrentLocation=Player.transform.position; bIsBeginningOfTurn=false; CurrentTurnPhase=TurnPhase.MovementPhase; } /* RaycastHit hitInfo; if (Physics.Raycast(Player.transform.position, new Vector3(0.0f,0.0f,-1.0f), out hitInfo, 100.0f) && hitInfo.normal.z > 0.999f) { if(hitInfo.transform.CompareTag("CrossTile")) { GameObject.FindGameObjectWithTag("CrossTile").GetComponent<crossTile>().tileActivate(); } else if(hitInfo.transform.CompareTag("XTile")) { GameObject.FindGameObjectWithTag("XTile").GetComponent<XTile>().tileActivate(); } else if(hitInfo.transform.CompareTag("HorizontalTile")) { GameObject.FindGameObjectWithTag("HorizontalTile").GetComponent<horizontalTile>().tileActivate(); } else if(hitInfo.transform.CompareTag("VerticalTile")) { GameObject.FindGameObjectWithTag("VerticalTile").GetComponent<verticalTile>().tileActivate(); } }*/ if(CurrentTurnPhase==TurnPhase.MovementPhase) { if(Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit) && hit.normal.z > 0.999f){ //On veut que le joueur se déplace ou on click NewLocation=hit.transform.gameObject.transform.position; //On garde le joueur sur son layer NewLocation.z=PlayerZ; //Si la tuile qu'on frappe est le néan, on ne peut pas s'y déplacer if(hit.transform.CompareTag("VoidTile")/* || hit.transform.CompareTag("TheVoid")*/) { bCanMoveToNewTile=false; } else { bCanMoveToNewTile=true; } } //On trouve le vecteur de déplacement MovementLength=NewLocation-CurrentLocation; //On détermine dans quel quandrant se trouve le déplacement //soit en haut a droite, en bas a droite //en haut a gauche, en bas a gauche ou le long d'un axe //pour une raison qui m'échape... chu f*****g fatigué. Shaft. DetermineQuadrant(MovementLength); //Ah oui, c'est pour faire ca!! if(MovementQuadrant=="AlongAxis") DesiredDisplacement=(int)MovementLength.magnitude; else { if(Mathf.Abs((int)MovementLength.x) > Mathf.Abs((int)MovementLength.y)) { DesiredDisplacement=Mathf.Abs((int)MovementLength.x); } else { DesiredDisplacement=Mathf.Abs((int)MovementLength.y); } } if(DesiredDisplacement <= AllowedSteps) { //On indique qu'on est pret a mettre a jour sa position bUpdatePosition=true; //RemainingSteps-=DesiredDisplacement; } else { //F**k yo couch. } } if(bUpdatePosition && bCanMoveToNewTile) { Player.transform.position=NewLocation; bUpdatePosition=false; } if (Input.GetKeyDown(KeyCode.Return)) { print ("enter pressed"); //end turn CurrentTurnPhase=TurnPhase.DamagePhase; } } else if(CurrentTurnPhase==TurnPhase.DamagePhase) { if (Input.GetKeyDown(KeyCode.Return)) { print ("enter pressed"); CurrentTurnPhase=TurnPhase.EndPhase; } } else if(CurrentTurnPhase==TurnPhase.EndPhase) { bIsPlayerTurn=false; bIsBeginningOfTurn=true; CurrentTurnPhase=TurnPhase.MovementPhase; CheckIfPlayerHasWon(); } } }
// Use this for initialization void Awake() { bHasWon=false; bIsPlayerTurn=false; bCanMoveToNewTile=true; bUpdatePosition=false; bIsBeginningOfTurn=true; AllowedSteps=1; RemainingSteps=AllowedSteps; Player =GameObject.FindGameObjectWithTag("Player"); GridBottomLeft =new Vector3(7.5f, -7.5f, 10.0f); GridBottomRight =new Vector3(-7.5f, -7.5f, 10.0f); GridTopLeft =new Vector3(7.5f, 7.5f, 10.0f); GridTopRight =new Vector3(-7.5f, 7.5f, 10.0f); TopRightBound =new Vector3(); TopLeftBound =new Vector3(); BotRightBound =new Vector3(); BotLeftBound =new Vector3(); MovementLength =new Vector3(); CurrentTurnPhase=TurnPhase.MovementPhase; }
private void GameStart(TextureManager textureManager, StartMenu startMenu) { currentTurn = 1; phase = TurnPhase.BookPicking; inputManager = new InputManager(players.Length); for (int i = 0; i < players.Length; i++) players[i] = new Player(textureManager, i); bookManager.archive.ClearArchive(); bookManager.GenerateBooks(); }
private void NextTurn() { currentTurn++; phase = TurnPhase.BookPicking; bookManager.archive.ClearArchive(); bookManager.GenerateBooks(); for (int i = 0; i < players.Length; i++) { players[i].phaseDone = false; players[i].RemoveOldBooks(); players[i].AgeBooks(); } market.GenerateDemand(rand); }
public bool CheckGameOver() { if (drawPile.Count == 0) { List<Card> cards = new List<Card>(); foreach (CardBartok cb in discardPile){ cards.Add (cb); } discardPile.Clear(); Deck.Shuffle(ref cards); drawPile = UpgradeCardsList(cards); ArrangeDrawPile(); } if (CURRENT_PLAYER.hand.Count == 0) { if(CURRENT_PLAYER.type == PlayerType.human){ GTGameOver.guiText.text = "You Won!"; GTRoundResult.guiText.text = ""; }else{ GTGameOver.guiText.text = "Game Over"; GTRoundResult.guiText.text = "Player " + CURRENT_PLAYER.playerNum+" won"; } GTGameOver.SetActive(true); GTRoundResult.SetActive(true); phase = TurnPhase.gameOver; Invoke("RestartGame",1); } return false; }
// Use this for initialization void Start() { currentPhase = TurnPhase.Upkeep; hand = new List<Card>(); }
/// <summary> /// Ends current turn phase for current player. /// If it's ending move phase (last phase), it goes to next player's placement phase. /// </summary> public void EndCurrentPhase() { if (CurrentPhase == TurnPhase.Placement) { Constants.CurrentHintText = Constants.AttackHint; CurrentPhase = TurnPhase.Attack; GameLog.AddEvent(Players[CurrentPlayerNumber].Name+" has finished placement and initiated attack phase."); } else if (CurrentPhase == TurnPhase.Attack) { CurrentPhase = TurnPhase.Move; Constants.CurrentHintText = Constants.MoveHint; GameLog.AddEvent(Players[CurrentPlayerNumber].Name + " has finished attacking and initiated move phase."); } else if (CurrentPhase == TurnPhase.Move) { Constants.CurrentHintText = Constants.PlacementHint; GameLog.AddEvent(Players[CurrentPlayerNumber].Name + " has finished their turn."); EndCurrentPlayerTurn(); CurrentPhase = TurnPhase.Placement; } }
// Update is called once per frame void Update() { if (currentPhase == TurnPhase.WaitingTurn && this.IsInAction()) { currentPhase = TurnPhase.MovingUnit; } }
/// <summary> /// Notify this controller than the current unit has finished its current move order. /// </summary> protected override void UnitDoneMoving(UnitMoveResponse response) { if (currentPhase != TurnPhase.MovingUnit) { Debug.LogWarning( string.Format("UnitDoneMoving unexpectedly called while {0} was in state {1}", this.name, currentPhase.ToString())); } else if (!response.validMove) { string debugString = string.Format ("{0} received a report that {1}'s move was invalid (\"{2}\").", this.name, currentUnit.name, response.responseMessage); Debug.Log(debugString); // We don't allow another move request if this one was invalid! currentPhase = TurnPhase.Attacking; // TODO: Allow the AI to retry? } else { string debugString = string.Format ("{0} received a report that {1} finished moving.", this.name, currentUnit.name); Debug.Log(debugString); currentPhase = TurnPhase.Attacking; } }
public bool CheckGameOver() { // See if we need to reshuffle the discard pile into the draw pile if (drawPile.Count == 0) { List<Card> cards = new List<Card>(); foreach (CardBartok cb in discardPile) { cards.Add (cb); } discardPile.Clear(); Deck.Shuffle( ref cards ); drawPile = ConvertListCardsToListCardBartoks(cards); ArrangeDrawPile(); } // Check to see if the current player has won if (CURRENT_PLAYER.hand.Count == 0) { // The current player has won! if (CURRENT_PLAYER.type == PlayerType.human) { Win(); } else { Lose (); } phase = TurnPhase.gameOver; /*GTGameOver.SetActive(true); GTRoundResult.SetActive(true); Invoke("RestartGame", 1);*/ return(true); } return(false); }
public void PassTurn(int num=-1) { // If no number was passed in, pick the next player if (num == -1) { int ndx = players.IndexOf(CURRENT_PLAYER); num = (ndx+1)%4; } int lastPlayerNum = -1; if (CURRENT_PLAYER != null) { lastPlayerNum = CURRENT_PLAYER.playerNum; // Check for Game Over and need to reshuffle discards if ( CheckGameOver() ) { return; } } CURRENT_PLAYER = players[num]; phase = TurnPhase.pre; CURRENT_PLAYER.TakeTurn(); // Move the TurnLight to shine on the new CURRENT_PLAYER Vector3 lPos = CURRENT_PLAYER.handSlotDef.pos + Vector3.back*5; turnLight.transform.position = lPos; // Report the turn passing Utils.tr(Utils.RoundToPlaces(Time.time), "Bartok.PassTurn()", "Old: "+lastPlayerNum,"New: "+CURRENT_PLAYER.playerNum); }
public void BuyPhase() { phase = TurnPhase.Buy; }
/// <summary> /// Handles forfeiting of the current player. All of forfeiting player's countries will be assigned to None. /// </summary> public void ForfeitCurrentPlayer() { GameLog.AddEvent(Players[CurrentPlayerNumber].Name + " has given up."); Players[CurrentPlayerNumber].IsActive = false; foreach (KeyValuePair<string, Country> entry in Countries.Where(entry => entry.Value.OwnedBy == CurrentPlayerNumber)) { entry.Value.OwnedBy = PlayerNumber.None; } CurrentPhase = TurnPhase.Placement; EndCurrentPlayerTurn(); }
public void ActionPhase() { phase = TurnPhase.Action; }
private void TurnPhaseCheck() { if (players.All(p => p.phaseDone)) { for (int i = 0; i < players.Length; i++) players[i].phaseDone = false; switch (phase) { case TurnPhase.BookPicking: phase = TurnPhase.Browsing; break; case TurnPhase.Browsing: phase = TurnPhase.Selling; break; case TurnPhase.Selling: economyManager.SellAllBooks(market, players); for (int i = 0; i < players.Length; i++) bookManager.archive.DeactivateSelection(players[i].playerID); NextTurn(); break; } } }
private void Button_Click_Proceed(object sender, RoutedEventArgs e) { switch (turnPhase) { case TurnPhase.PlaceTokens: //remember to set availablePowerTokens == to allPowerTokens turnPhase = TurnPhase.March; resources.copyAllOrderTokensToAvailable(); break; case TurnPhase.Westeros: break; case TurnPhase.Raid: break; case TurnPhase.March: //Take attacker and defender and fire an event for an attack resolveMarch.performCombat(); break; case TurnPhase.ConsolidatePower: break; } }
public void PassTurn(int num=-1) { if (num == -1) { int ndx = players.IndexOf(CURRENT_PLAYER); num = (ndx+1)%4; } int lastPlayerNum = -1; if (CURRENT_PLAYER != null) { if(CheckGameOver()){ return; } lastPlayerNum = CURRENT_PLAYER.playerNum; } CURRENT_PLAYER = players [num]; phase = TurnPhase.pre; CURRENT_PLAYER.TakeTurn (); Vector3 lPos = CURRENT_PLAYER.handSlotDef.pos + Vector3.back * 5; turnLight.transform.position = lPos; Utils.tr (Utils.RoundToPlaces (Time.time), "Bartok.PassTurn()", "Old: " + lastPlayerNum, "New: " + CURRENT_PLAYER.playerNum); }