public void StartNextTurn() { (bool over, PlayerType winner) = CheckGameOver(); if (!over) { if (!Started) { currentPlayer = PlayerType.Player1; Started = true; } else if (currentPlayer == PlayerType.Player1) { currentPlayer = PlayerType.Player2; } else { currentPlayer = PlayerType.Player1; } if (ForcedMoves) { CheckForcedPieces(currentPlayer); } NextTurn?.Invoke(currentPlayer, forcedPieces); } else { GameOver?.Invoke(winner); } }
// Start is called before the first frame update void Start() { Tilemap[] Tilemaps; Tilemaps = GameObject.FindObjectsOfType <Tilemap>(); for (int i = 0; i < Tilemaps.Length; i++) { if (Tilemaps[i].tag == "tilemap") { tilemap = Tilemaps[i]; break; } } load = tilemap.GetComponent <Load>(); pathfinding = tilemap.GetComponent <pathfinding>(); Player = GameObject.FindGameObjectWithTag("Player").transform; Tilemap[] tilemaps; tilemaps = GameObject.FindObjectsOfType <Tilemap>(); for (int i = 0; i < tilemaps.Length; i++) { if (tilemaps[i].tag == "HighLight") { HighLight = tilemaps[i]; break; } } EnemyMapPosition = tilemap.WorldToCell(transform.position); transform.position = tilemap.CellToWorld(EnemyMapPosition); playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <playerMovement>(); nextTurn = GameObject.FindGameObjectWithTag("Canvas").GetComponent <NextTurn>(); }
void Awake() { GameManager.worldEvent += EventManager; GameManager.nextTurn += NextTurn; WorldManager.onHexClick += OnHexClick; worldManager = GameObject.FindObjectOfType<WorldManager>(); }
public Cart(int x, int y, Direction direction) { this.X = x; this.Y = y; this.Direction = direction; this.nextTurn = NextTurn.Left; }
void Awake() { GameManager.worldEvent += EventManager; GameManager.nextTurn += NextTurn; WorldManager.onHexClick += OnHexClick; worldManager = GameObject.FindObjectOfType <WorldManager>(); }
public static NextTurn Instance() // { if (instance == null) { instance = GameObject.FindObjectOfType <NextTurn>() as NextTurn; } return(instance); }
public void UpdateDir(Track trackType) { switch (trackType) { case Track.BackTurn: if (Direction == Direction.North) { Direction = Direction.West; } else if (Direction == Direction.East) { Direction = Direction.South; } else if (Direction == Direction.South) { Direction = Direction.East; } else if (Direction == Direction.West) { Direction = Direction.North; } break; case Track.ForwardTurn: if (Direction == Direction.North) { Direction = Direction.East; } else if (Direction == Direction.East) { Direction = Direction.North; } else if (Direction == Direction.South) { Direction = Direction.West; } else if (Direction == Direction.West) { Direction = Direction.South; } break; case Track.Intersection: if (nextTurn == NextTurn.Left) { Direction = (Direction)((((int)Direction) + 3) % 4); } else if (nextTurn == NextTurn.Right) { Direction = (Direction)((((int)Direction) + 1) % 4); } nextTurn = (NextTurn)((((int)nextTurn) + 1) % 3); break; } }
public void MartianAttack(int AttackNr) // Parameter is what number attack it is. { CombatManager.Instance().SetupEnemy(AttackNr); AttackAlertPanel.SetActive(true); //AttackResolvePanel.SetActive(true); CombatManager.Instance().SetupPlayerForces(); // this hould not be done here!!!!!!! // here we calculate attack -or maybe in it own class/method MessageManager.Instance().UpdateMessagePanel("Turn: " + NextTurn.Instance().TurnCounter + "\n", "Martian fighterbombers attacked Moonbase! " + "\n"); // Maybe result/Casualties here!? }
public void Play() { while (!IsGameOver) { RefreshDisplay?.Invoke(this, null); var diceRes = new int[2]; NextTurn?.Invoke(this, new DiceEventArgs(diceRes)); PlayNewTurn(diceRes); } Message?.Invoke(this, $"The Winner is the {Winner.Color} player!"); }
public void Advance(char nextTile) { int nextX = Direction == Direction.Top ? X - 1 : Direction == Direction.Bottom ? X + 1 : X; int nextY = Direction == Direction.Left ? Y - 1 : Direction == Direction.Right ? Y + 1 : Y; Direction nextDirection = Direction; switch (nextTile) { case '+': nextDirection = NextTurn == NextTurn.Left ? ( Direction == Direction.Top ? Direction.Left : Direction == Direction.Bottom ? Direction.Right : Direction == Direction.Right ? Direction.Top : /*Direction == Direction.Left ?*/ Direction.Bottom ) : NextTurn == NextTurn.Right ? ( Direction == Direction.Top ? Direction.Right : Direction == Direction.Bottom ? Direction.Left : Direction == Direction.Right ? Direction.Bottom : /*Direction == Direction.Left ?*/ Direction.Top ) : /*NextTurn == NextTurn.Forward */ Direction; NextTurn = NextTurn == NextTurn.Left ? NextTurn.Forward : NextTurn == NextTurn.Forward ? NextTurn.Right : NextTurn.Left; break; case '\\': nextDirection = Direction == Direction.Top ? Direction.Left : Direction == Direction.Bottom ? Direction.Right : Direction == Direction.Right ? Direction.Bottom : /*Direction == Direction.Left ?*/ Direction.Top; break; case '/': nextDirection = Direction == Direction.Top ? Direction.Right : Direction == Direction.Bottom ? Direction.Left : Direction == Direction.Right ? Direction.Top : /*Direction == Direction.Left ?*/ Direction.Bottom; break; } X = nextX; Y = nextY; Direction = nextDirection; }
public void NextStep(BodyPart bodyPart) { roundIndex++; if (roundIndex % 2 == 0) { Player0.Blocked = bodyPart; Player0.GetHit(Bot.choseBodyPart()); } else { Player1.Blocked = Bot.choseBodyPart(); Player1.GetHit(bodyPart); } NextTurn?.Invoke(this, new EventArgs()); }
public void FinishGame(NextTurn turn) { ExecuteOnMainThread.Enqueue(() => { _creatureHelper.GoToLobby.SetActive(true); FinalPanel.SetActive(true); if (GameFlow.Instance.IsGameCreator && turn.Team == Team.Red.ToString() || !GameFlow.Instance.IsGameCreator && turn.Team == Team.Blue.ToString()) { LoseMessage.SetActive(true); return; } WinMessage.SetActive(true); }); }
public void ChangeTurn(NextTurn turn) { TileBehaviour.OnMove = false; _currentCreature = _creaturesComponent.SingleOrDefault(x => x.Index == turn.CreatureIndex); if (!IsYourTurn(_currentCreature)) { _canMove = false; ExecuteOnMainThread.Enqueue(() => { UpdateTurnIterface("Enemy Turn"); }); return; } _canMove = true; ExecuteOnMainThread.Enqueue(() => { UpdateTurnIterface("Your Turn"); }); ExecuteOnMainThread.Enqueue(CheckPath); }
private int count; // for counting up eleements in the finished list public void FinishBuild() { HangarManager.Instance().FinishedItems.Add(this); // take this object and put it into the list of finished items /*HangarManager.Instance().InProductionItems.Remove(this);*/ // take this object and remove it from the list of items which is in production if (this.ItemTypeNr == 1) { HangarManager.Instance().ShipsInService.Add(this); // Maybe more here } if (this.ItemID == 6) // if this is a SolarMK2 then set its panel true. //Note.. we need to update the finished item list if it gets destroyed { HangarManager.Instance().SolagenMK2.SetActive(true); } if (this.ItemID == 7) // { HangarManager.Instance().SolagenMK2.SetActive(true); HangarManager.Instance().SolagenMK3.SetActive(true); } if (this.ItemID == 8) { HangarManager.Instance().SolagenMK2.SetActive(true); HangarManager.Instance().SolagenMK3.SetActive(true); HangarManager.Instance().SolagenMK4.SetActive(true); } this.InProduction = false; // As this item is finished we set it to false //Below here: we tell what is finished dbuild and what eventually is next in production que string NextProductionItem = "No more items in production que!"; if (HangarManager.Instance().InProductionItems.Count > 1) { NextProductionItem = "Still running! "; //+ HangarManager.Instance().InProductionItems[HangarManager.Instance().InProductionItems.Count-1].ItemName; // MAYBE -1 in the list count } MessageManager.Instance().UpdateMessagePanel("Turn: " + NextTurn.Instance().TurnCounter + ". Item Finished: \n", " " + this.ItemName + ". Production status is: " + NextProductionItem + "\n"); foreach (var FinishedItem in HangarManager.Instance().FinishedItems) // trying to read out the list of build things { Debug.Log("Finished Item nr " + count + " is:" + HangarManager.Instance().FinishedItems + FinishedItem); // Show in the Debug log whats on this list to show iterate through count++; } }
public void ChangeTurn() { addMoveNote(); LastMove = to; from.Piece = null; if (WhosPlaying == PieceColor.Black) { WhosPlaying = PieceColor.White; } else { WhosPlaying = PieceColor.Black; TurnId++; } NextTurn?.Invoke(this, null); }
protected override bool Run() { if (Count < 0 || Count > Max) { return(false); } for (var i = 0; i < Count; i++) { var nextTurn = new NextTurn().Execute(Core); if (!nextTurn.IsValid) { return(false); } } return(true); }
public void StartGame() { roundIndex = new Random().Next(0, PlayersAmount); if (Player0.HealthPoints == Player.MaxHealth && Player1.HealthPoints == Player.MaxHealth && roundIndex % 2 == 1) { NextTurn?.Invoke(this, new EventArgs()); } if (Player0.HealthPoints == 0 && roundIndex % 2 == 1) { NextTurn?.Invoke(this, new EventArgs()); } if (Player1.HealthPoints == 0 && roundIndex % 2 == 0) { NextTurn?.Invoke(this, new EventArgs()); } Player0.HealthPoints = Player.MaxHealth; Player1.HealthPoints = Player.MaxHealth; Start?.Invoke(this, new GameModelEventArgs(roundIndex)); }
public BasicCard CreateCard(CardColor color, CardType type) { BasicCard card; switch (type) { case CardType.DrawTwo: card = new Card(color, type, this.performCardAction); card = new NextTurn(card); card = new Draw(card); card = new Draw(card); break; case CardType.Skip: card = new Card(color, type, this.performCardAction); card = new NextTurn(card); break; case CardType.Reverse: card = new Card(color, type, this.performCardAction); card = new ReverseTurnOrder(card); break; case CardType.Wild: card = CreateWildCard(type); break; case CardType.WildDrawFour: card = CreateWildCard(type); break; default: card = new Card(color, type, this.performCardAction); break; } return(card); }
//Makes sure card gets a color except the Wild cards. If I allowed passing null to the above method I would be relying more on the //setter to keep thier color from being set to null. public BasicCard CreateWildCard(CardType type) { BasicCard card; switch (type) { case CardType.WildDrawFour: card = new Card(CardType.WildDrawFour, this.performCardAction); card = new NextTurn(card); card = new Draw(card); card = new Draw(card); card = new Draw(card); card = new Draw(card); card = new SetCardColor(card); break; default: card = new Card(CardType.Wild, this.performCardAction); card = new SetCardColor(card); break; } return(card); }
/// Current thinker makes its move private Winner Play() { // Get a reference to the current thinker IThinker thinker = matchData.CurrentThinker; // Determine the color of the current thinker PColor color = board.Turn; // Match result so far Winner winner = Winner.None; // Thinking start time DateTime startTime = DateTime.Now; // Real think time in milliseconds int thinkTimeMillis; // Apparent thinking time left int timeLeftMillis; // Task to execute the thinker in a separate thread Task <FutureMove> thinkTask; // Notify listeners that next turn is about to start NextTurn?.Invoke(color, thinker.ToString()); // Ask thinker to think about its next move thinkTask = Task.Run( () => thinker.Think(board.Copy(), ts.Token)); // The thinking process might throw an exception, so we wrap // task waiting in a try/catch block try { // Wait for thinker to think... until the allowed time limit if (thinkTask.Wait(timeLimitMillis)) { // Thinker successfully made a move within the time limit // Get the move selected by the thinker FutureMove move = thinkTask.Result; // Was the thinker able to chose a move? if (move.IsNoMove) { // Thinker was not able to chose a move // Raise an invalid play event and set the other // thinker as the winner of the match winner = OnInvalidPlay( color, thinker, "Thinker unable to perform move"); } else { // Thinker was able to chose a move // Perform move in game board, get column where move // was performed int row = board.DoMove(move.shape, move.column); // If the column had space for the move... if (row >= 0) { // Obtain thinking end time thinkTimeMillis = (int)(DateTime.Now - startTime) .TotalMilliseconds; // How much time left for the minimum apparent move // time? timeLeftMillis = minMoveTimeMillis - thinkTimeMillis; // Was the minimum apparent move time reached if (timeLeftMillis > 0) { // If not, wait until it is reached Thread.Sleep(timeLeftMillis); } // Notify listeners of the move performed MovePerformed?.Invoke( color, thinker.ToString(), move, thinkTimeMillis); // Get possible winner and solution winner = board.CheckWinner(solution); } else { // If we get here, column didn't have space for the // move, which means that thinker made an invalid // move and should lose the game // Raise an invalid play event and set the other // thinker as the winner of the match winner = OnInvalidPlay( color, thinker, "Tried to place piece in column " + $"{move.column}, which is full"); } } } else // Did the time limit expired? { // Notify thinker to voluntarily stop thinking ts.Cancel(); // Raise an invalid play event and set the other thinker // as the winner of the match winner = OnInvalidPlay( color, thinker, "Time limit expired"); } } catch (Exception e) { // Is this an inner exception? if (e.InnerException != null) { // If so, use it for error message purposes e = e.InnerException; } // Raise an invalid play event and set the other thinker as // the winner of the match winner = OnInvalidPlay( color, thinker, $"Thinker exception: '{e.Message}'"); } // Notify listeners that the board was updated BoardUpdate?.Invoke(board); // Return winner return(winner); }
public void StartNextTurn(PlayerType player, List <GamePiece> forcedPieces) { NextTurn?.Invoke(player, forcedPieces); }
void Awake() { button = GetComponent <Button> (); turn = FindObjectOfType <NextTurn> (); }
void OnDisable() { GameManager.worldEvent -= EventManager; GameManager.nextTurn -= NextTurn; }
public static void OnNextTurn(object sender, NextTurnEventArgs args) { NextTurn?.Invoke(sender, args); }
private void TurnManager_NextTurn(object sender, EventArgs e) { NextTurn?.Invoke(sender, e); }
void OnDisable() { GameManager.worldEvent -= EventManager; GameManager.nextTurn -= NextTurn; }