private void SetTurn() { //Turn tracker turn++; if (turn + 1 >= TurnOrder.Count) { turn = 0; } currentChara = TurnOrder[turn]; SetStart(currentChara); move = 0; if (TurnOrder[turn].tag == "Player") { currentTurn = CurrentTurn.Hero; } if (TurnOrder[turn].tag == "Enemy") { currentTurn = CurrentTurn.Enem; } if (TurnOrder[turn].tag == "Boss") { currentTurn = CurrentTurn.Boss; } }
public GamePanel2() { InitializeComponent(); CurrentTurn.SetTileType(TileType.board); CurrentTurn.ShowLinks(false); }
public void EndPhase() { if (CurrentTurn.CurrentPhase == Turn.Phase.Enemy) { CurrentTurn.AdvancePhase(); } }
private void SetTurn() { SetVisualTileCounts(); List <HexagonTile> posibilities = new List <HexagonTile>(); var colors = from h in hexagonList where h.TileType == this.turnOrder[this.currentTurn] select h; foreach (HexagonTile tile in colors) { FindPosibilities(tile, posibilities); } if (posibilities.Count == 0) { SkipTurn(); return; } skipTurns = 0; foreach (HexagonTile h in posibilities) { ((BoardHexagon)h.Visual).SetTileType(TileType.none); ((BoardHexagon)h.Visual).MouseLeftButtonDown += ChooseTurn; } CurrentTurn.SetTileType(this.turnOrder[this.currentTurn]); }
public void PlayerTurn() { currentTurn = CurrentTurn.Player; for (int i = 0; i < Tile.SIZE; i++) { if (Enemy.occupied[i]) { if (Enemy.enemies[i].cantAttack > 0) { Enemy.enemies[i].cantAttack--; } if (Enemy.enemies[i].cantMove > 0) { Enemy.enemies[i].cantMove--; } } } for (int i = 0; i < PlayerAttack.SIZE; i++) { PlayerAttack attack = new PlayerAttack(); if (PlayerAttack.cooldown[i] > 0) { PlayerAttack.cooldown[i]--; attack.DisplayAbility(i); } } }
private void Update() { // /// This is the fundamental game logic for our turn based strategy game. /// It ensures we rotate through each player, updating our state as we go. /// if (CurrentTurn.Completed) { // move current turn to "previous turns" PreviousTurns.Add(CurrentTurn); Turn LastTurn = PreviousTurns[PreviousTurns.Count - 1]; // increment the current player index (looping where necessary) _CurrentPlayerIndex++; if (_CurrentPlayerIndex >= Players.Length) { _CurrentPlayerIndex = 0; } PlayerController nextPlayer = Players[_CurrentPlayerIndex]; // and setup the next turn. UnderlyingTurn = new Turn(nextPlayer); } else { CurrentTurn.Update(); } /// /// Perform GUI Updates /// // Show/hide "End Attack" button. // Update Status Text string updateText = ""; switch (CurrentTurn.CurrentPlayerState()) { case Turn.PlayerState.ChooseTerritory: updateText = "Player '" + CurrentPlayer.displayName + "' is picking a Territory..."; break; case Turn.PlayerState.Reinforce: updateText = "Player '" + CurrentPlayer.displayName + "' (" + CurrentPlayer.UnassignedArmies.Length + " left) is Reinforcing..."; break; case Turn.PlayerState.Attack: updateText = "Player '" + CurrentPlayer.displayName + "' is Attacking..."; break; case Turn.PlayerState.Foritfy: updateText = "Player '" + CurrentPlayer.displayName + "' is Fortifying..."; break; } PlayerStatusTextMesh.text = updateText; }
public void MinoEndTurn() { turnTracker = CurrentTurn.playerTurn; if(OnPcTurn != null) { OnPcTurn(); } }
public void EndPhase() { //Debug.Log ("All bullets finished, ending bullet phase."); if (CurrentTurn.CurrentPhase == Turn.Phase.Bullet) { CurrentTurn.AdvancePhase(); } }
public void MinoEndTurn() { turnTracker = CurrentTurn.playerTurn; if (OnPcTurn != null) { OnPcTurn(); } }
public void EndTurn() { TurnEnding?.Invoke(this, new TurnEndedEventArgs()); CurrentTurn = CurrentTurn.Opposite(); TurnNumber++; SelectedPiece.OnDeselected(); SelectedPiece = null; TurnEnded?.Invoke(this, new TurnEndedEventArgs()); }
public void m_SwitchTurn() { if (m_ThisTurn == CurrentTurn.player) { m_ThisTurn = CurrentTurn.ai; } else { m_ThisTurn = CurrentTurn.player; } }
public GamePanel() { InitializeComponent(); CurrentTurn.SetTileType(TileType.board); CurrentTurn.ShowLinks(false); this.firstCapture = TileType.none; this.turnOrder[0] = TileType.yellow; this.currentTurn = 0; }
// Use this for initialization void Awake() { turn = CurrentTurn.player; turncheck = false; for (int i = 0; i < 4; i++) { GameObject.Find("hand").GetComponent <hand>().getcard(); } /*for (int i = 0; i < 4; i++) * GameObject.Find("ehand").GetComponent<ehand>().getcard();*/ }
public void turnchange() { if (turn == CurrentTurn.player) { turn = CurrentTurn.enemy; } else { turn = CurrentTurn.player; } turncheck = false; }
public void SetAvatars(Avatar player, Avatar enemy) { this.player = player; this.enemy = enemy; if (player.GetSpeed() >= enemy.GetSpeed()) { turn = CurrentTurn.Players; } else { turn = CurrentTurn.Enemies; } }
public Choice Continue(Decision decision) { var choiceVar = CurrentTurn.Continue(decision, this); if (choiceVar == null && Players.Count > 1) { return(StartNewTurn(CurrentTurn.NonActivePlayer, CurrentTurn.ActivePlayer)); } else { return(choiceVar); } }
public override void Update(GameTime gameTime) { PlayerIndex index; if ((cTimer > TimeSpan.FromSeconds(4) || !enemy.Alive || !player.Alive) && dTimer > TimeSpan.FromSeconds(3)) { if (!enemy.Alive || !player.Alive) { manager.PopState(); manager.PushState((BattleOverState)GameRef.BattleOverState, PlayerIndex.One); GameRef.BattleOverState.SetAvatars(player, enemy); } else { manager.PopState(); } } else if (cTimer > TimeSpan.FromSeconds(2) && first && enemy.Alive && player.Alive) { first = false; dTimer = TimeSpan.Zero; if (turn == CurrentTurn.Players) { turn = CurrentTurn.Enemies; enemy.ResoleveMove(enemyMove, player); } else { turn = CurrentTurn.Players; player.ResoleveMove(playerMove, enemy); } } else if (cTimer == TimeSpan.Zero) { dTimer = TimeSpan.Zero; if (turn == CurrentTurn.Players) { player.ResoleveMove(playerMove, enemy); } else { enemy.ResoleveMove(enemyMove, player); } } cTimer += gameTime.ElapsedGameTime; dTimer += gameTime.ElapsedGameTime; base.Update(gameTime); }
public TurnResult ResolveTurn() { var turnResult = CurrentTurn.Resolve(); TurnResults.Add(turnResult); if (turnResult.IsGameOver) { GameDone(turnResult); } TurnNum++; CurrentTurn = new Turn(TurnNum, P1, P2); return(turnResult); }
public void EndTurn() { CurrentTurn.EndTurn(); CheckGameComplete(); if (IsComplete) { Score(); Log.LogGameEnd(this.Scores); } else { _gameTurns.MoveNext(); } }
public void endTurn() { if (CurrentTurn + 1 <= maxTurn) { CurrentTurn++; HudManager.textCurrentTurn.GetComponent <TextMeshPro>().text = CurrentTurn.ToString(); for (int i = 0; i < virusList.Count; i++) { virusList[i].setOutOfAction(false); virusList[i].setHasExplored(false); } } else { lose(); } }
/// <summary> /// Process a tick of the poker game timer. Refresh the gumps of all players, try to increment the round and check for /// afk players /// </summary> public void ProcessTick() { if (IsIntermission() && HandCoolDown <= TimeSpan.FromSeconds(0)) { ResetGame(); } else if (State == PokerGameState.Showdown) { DoShowdown(); } else if (State > PokerGameState.Inactive && State < PokerGameState.Showdown) { DoRoundAction(); //if it is someones turn and they haven't done an action if (IsBettingRound && CurrentTurn != null) { CurrentTurn.TurnEnd -= TimeSpan.FromSeconds(1); if (CurrentTurn.TurnEnd == TimeSpan.FromSeconds(30) || CurrentTurn.TurnEnd == TimeSpan.FromSeconds(15) || CurrentTurn.TurnEnd == TimeSpan.FromSeconds(5)) { CurrentTurn.SendMessage("Your turn will end in " + CurrentTurn.TurnEnd.Seconds + " seconds. If you do not make a move before your time runs out, you will fold your hand."); } //thye've used up their turn grace time, force them to fold from the hand if (CurrentTurn.TurnEnd <= TimeSpan.FromSeconds(0)) { DoAction(CurrentTurn, PlayerAction.Fold); } } } else if (IsIntermission()) { var seconds = HandCoolDown.Seconds; if (seconds == 20 || seconds == 10 || seconds == 5) { PokerMessage(Dealer, "The next hand will begin in " + HandCoolDown.Seconds + " seconds."); } HandCoolDown -= TimeSpan.FromSeconds(1); } }
public string Serialize() { string state = GameOn.ToString() + "\n"; state += CurrentTurn.ToString() + "\n"; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { if (Board[x, y] != null) { Checker checker = Board[x, y]; state += $"{checker.Color}|{checker.King}|{checker.Coords.X}|{checker.Coords.Y}\n"; } } } return(state); }
public string Serialize() { StringBuilder sb = new StringBuilder(); sb.AppendLine(GameOn.ToString()); sb.AppendLine(CurrentTurn.ToString()); for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { if (Board[x, y] != null) { sb.AppendLine(Board[x, y].ToString()); } } } return(sb.ToString()); }
public IActivity GetPendingActivity(Player player) { var currentEffect = CurrentTurn.GetCurrentEffect(); if (currentEffect != null) { return(currentEffect.GetActivity(player)); } if (player == ActivePlayer) { return(CurrentTurn.GetDefaultActivity()); } else { return(new WaitingForPlayersActivity(player)); } }
public string Serialize() { string state = GameOn.ToString() + "\n"; state += CurrentTurn.ToString() + "\n"; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (Board[i, j] != null) { Checker checker = Board[i, j]; state += $"{checker.Color}|{checker.King}|{checker.Coords.X}|{checker.Coords.Y}\n"; } } } return(state); }
public string Serialize() { string state = GameOn.ToString() + '\n'; state += CurrentTurn.ToString() + '\n'; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (Board[j, i] != null) { Checker c = Board[j, i]; state += $"{c.color}|{c.King}|{c.Coords.x}|{c.Coords.y}\n"; } } } return(state); }
// Update is called once per frame public void PcEndTurn(Vector3 pcPos) { turnTracker = CurrentTurn.minoTurn; if (OnMinoTurn != null) { OnMinoTurn(); } else { if (managerScript.SpawnMinotaur(pcPos)) { print("spawn sucessful"); } else { print("spawn failed"); } MinoEndTurn(); } }
// Update is called once per frame public void PcEndTurn (Vector3 pcPos) { turnTracker = CurrentTurn.minoTurn; if(OnMinoTurn != null) { OnMinoTurn(); } else { if(managerScript.SpawnMinotaur(pcPos)) { print("spawn sucessful"); } else { print("spawn failed"); } MinoEndTurn(); } }
public static async Task DoTurn(Picture selectedPicture) { bool isRightChoice = CurrentTurn.SelectPicture(selectedPicture); if (isRightChoice) { GuessedImagesCount++; } int delay = isRightChoice ? 1000 : 3000; await Task.Delay(delay); if (CurrentTurnNumber == TurnsCount - 1) { CurrentTurnNumber = TurnsCount; return; } await Tasks[CurrentTurnNumber + 1]; CurrentTurnNumber++; }
public Move Move(string from, string to) { var fromCell = Board.GetCell(from); if (fromCell == null) { throw new ArgumentException("No cell found at location"); } var piece = fromCell.Occupant; if (piece == null) { return(Engine.Move.InvalidPlay(null, fromCell, "No piece found at location")); } if (piece.Color != CurrentTurn) { return(Engine.Move.InvalidPlay(null, fromCell, $"It is not {piece.Color}s Turn")); } var toCell = Board.GetCell(to); if (toCell == null) { return(Engine.Move.InvalidPlay(piece, fromCell, "Destination cell does not exist")); } var targetPiece = toCell.Occupant; if (targetPiece != null) { if (targetPiece.Color == piece.Color) { return(Engine.Move.InvalidPlay(piece, fromCell, $"The destination already has a {targetPiece.Color} piece")); } } bool isCheck = false; bool isCheckMate = false; if (piece.IsLegalMoveTo(toCell)) { var simulatedMove = SimulateMove(from, to); var inCheck = simulatedMove.PiecesInCheck(); if (inCheck.Any(x => x.Color == CurrentTurn)) { return(Engine.Move.InvalidPlay(piece, fromCell, $"Cannot make this move. This move would put ${piece.Color} in check.")); } if (inCheck.Any()) { isCheck = true; var inCheckMate = simulatedMove.PiecesInCheckMate(); if (inCheckMate.Any(x => x.Color == CurrentTurn)) { return(Engine.Move.InvalidPlay(piece, fromCell, $"Cannot make this move. This move would put ${piece.Color} in checkmate.")); } isCheckMate = true; } var outcome = piece.MoveTo(toCell); } else { return(Engine.Move.InvalidPlay(piece, fromCell, "This destination is not valid for this piece")); } var associatedMoves = new List <Move>();// POPULATE ON CASTLING //TODO: IMPLEMENT LOGIC CurrentTurn = CurrentTurn.GetOtherColor(); var move = Engine.Move.ValidPlay(piece, fromCell, toCell, Serial(), TimeSinceLastMove(), isCheck, isCheckMate, associatedMoves); MoveHistory.Add(move); return(move); }
private void ProcessTurns() { List <GameMessage> messages; while (true) { InfoLog.WriteInfo("Waiting for new turn", EPrefix.SimulationInfo); _nextTurnSemaphore.WaitOne(); //wait for MessageTurn if (_abort) { Thread.CurrentThread.IsBackground = true; this._turnProcessor = null; return; } lock (_turns.SyncRoot) { _currentTurn++; messages = _currentMessages.Dequeue(); } InfoLog.WriteInfo("Turn: " + CurrentTurn.ToString(), LogFiles.ProcessMsgLog); turnAsk = Environment.TickCount; if (onTurnBegin != null) { onTurnBegin(); } int turnStart = Environment.TickCount; foreach (GameMessage gm in messages) { InfoLog.WriteInfo(gm.ToString(), LogFiles.ProcessMsgLog); if (gm.Type == MessageType.CreateUnit) { this.onMessageCreate((CreateUnitMessage)gm); } else if (gm.Type == MessageType.Build) { this.OnMessageBuild((BuildMessage)gm); } else if (gm.Type == MessageType.Move) { this.onMessageMove((MoveMessage)gm); } else if (gm.Type == MessageType.Attack) { this.onMessageAttack((AttackMessage)gm); } else if (gm.Type == MessageType.Destroy) { this.onMessageDestroy((DestroyMessage)gm); } else if (gm.Type == MessageType.Harvest) { this.onMessageHarvest((HarvestMessage)gm); } else if (gm.Type == MessageType.DeployMCV) { this.onMessageDeployMCV((GMDeployMCV)gm); } else if (gm.Type == MessageType.BuildUnitMessage) { this.onMessageBuildUnit((BuildUnitMessage)gm); } else if (gm.Type == MessageType.PlayerDisconnected) { this.onMessagePlayerDisconnected((GameNumericMessage)gm); } else { throw new NotImplementedException("This message type is not supported! Refer to Simulation.cs"); } } //process all units & building & animations foreach (Player p in players.Values) { List <Ammo> ammos = p.GetAllAmmos(); foreach (Ammo a in ammos) { a.DoAI(); } } foreach (Player p in players.Values) { //get copy of buildings' list buildingsToProcess = p.GetAllBuildings(); //while there are unprocessed buildings while (buildingsToProcess.Count != 0) { Building b = buildingsToProcess[0]; buildingsToProcess.RemoveAt(0); handleBuilding(b); } unitsToProcess = p.GetAllUnits(); while (unitsToProcess.Count != 0) { Unit u = unitsToProcess[0]; unitsToProcess.RemoveAt(0); handleUnit(u); } } sandwormToProcess = new List <Unit>(sandworms.Values); while (sandwormToProcess.Count != 0) { Unit u = sandwormToProcess[0]; sandwormToProcess.RemoveAt(0); handleUnit(u); } //this.fastTurnProcessing = true; int remainingTime = Simulation.turnLength - (Environment.TickCount - turnStart); //if (!this._fastTurnProcessing) { //in server - just do turn, don't wait if (SpeedUp) { --_speedUpLength; remainingTime = (int)(remainingTime * 0.8); } if (remainingTime > 0) { Thread.Sleep(remainingTime); } //} //InfoLog.WriteInfo((Environment.TickCount - turnStart).ToString(), EPrefix.SimulationInfo); InfoLog.WriteInfo("OnTurnEnd begin", EPrefix.SimulationInfo); if (this.onTurnEnd != null) { this.onTurnEnd(); } StringBuilder sb = new StringBuilder(""); foreach (Player p in players.Values) { sb.Append(" Player " + p.Id + " : " + p.Credits); } InfoLog.WriteInfo(sb.ToString(), EPrefix.BMan); InfoLog.WriteInfo("OnTurnEnd end", EPrefix.SimulationInfo); InfoLog.WriteInfo("********* TURN " + this.CurrentTurn + " END *********", EPrefix.Test); recordFullSimulationState(_currentTurn); } // writer.Close(); // fs.Close(); }
void Start () { managerScript = GetComponent<Manager>(); turnTracker = CurrentTurn.playerTurn; }
public void m_Startup() { m_ThisTurn = CurrentTurn.player; }