void OnTurnEvent(TurnEvent _event) { switch(_event.type) { case TurnEvent.Type.NewSeason: probabilitySeason.Clear(); int season = (int)TimeManager.Instance.season; for(int i = 0; i < 4; i++) { probabilitySeason.AddRange(Enumerable.Repeat(CFG.seasons[season].weather[i].weather, CFG.seasons[season].weather[i].probability)); } break; case TurnEvent.Type.NewDay: //Nouvelle météo basée sur la saison actualWeather = probabilitySeason.ElementAt(Random.Range(0,probabilitySeason.Count)); //Si la météo est la même qu'hier if(consecutiveWeather.ElementAt(0).Key == actualWeather) consecutiveWeather[actualWeather] = consecutiveWeather.ElementAt(0).Value+1; else { consecutiveWeather.Clear(); consecutiveWeather.Add(actualWeather, 0); } if(consecutiveWeather.ElementAt(0).Value >= CFG.disastersBeginAt) OnDisaster(actualWeather); break; } }
/// <summary> /// Checks if there are any events that should be triggered. /// </summary> public void CheckMapEvents() { for (int i = 0; i < battleMap.mapEvents.Count; i++) { TurnEvent pos = battleMap.mapEvents.GetEvent(i); if (battleMap.mapEvents.IsActivated(i) || currentFaction.value != pos.factionTurn) { continue; } bool activate = false; switch (pos.triggerType) { case TriggerType.TURN: activate = (currentTurn.value == pos.turn); break; case TriggerType.TRIGGER: activate = battleMap.triggerList.IsTriggered(pos.triggerIndex); break; case TriggerType.PLAYER_COUNT: activate = (battleMap.playerList.values.Count <= pos.turn); break; case TriggerType.ALLY_COUNT: activate = (battleMap.allyList.values.Count <= pos.turn); break; case TriggerType.ENEMY_COUNT: activate = (battleMap.enemyList.AliveCount() <= pos.turn); break; } if (activate) { battleMap.mapEvents.Activate(i); switch (pos.type) { case TurnEventType.MAPCHANGE: MapTile tile = battleMap.GetTile(pos.x, pos.y); tile.SetTerrain(pos.changeTerrain); break; case TurnEventType.MONEY: Debug.Log("Gained money: " + pos.value); break; case TurnEventType.SCRAP: Debug.Log("Gained scrap: " + pos.value); break; } } } nextTurnStateEvent.Invoke(); }
private IEnumerable <Wait> RoutineResetCooldown(TurnEvent turn) { if (turn.Creature is Enemy enemy && enemy.Skills.Any()) { var skill = enemy.Skills.Pick(Random); skill.ResetCooldown(); } yield return(Wait.NoWait); }
// [Client/Server] Parses the Match Data from MatchDataBroadcaster public void ParseTurnEvent() { Debug.Log(debugTag + "Parsing Turn Event..."); TurnEvent newTurnEvent = JsonUtility.FromJson <TurnEvent>(matchDataBroadcaster.TurnEventStr); if (this.lastKnownTurnEvent != newTurnEvent) { this.lastKnownTurnEvent = newTurnEvent; } Debug.Log(debugTag + "Turn Event as: " + this.lastKnownTurnEvent); }
public Game(int startingPlayer, params Player[] players) { TurnEvent.Subscribe(this, 0, NextTurn); this.players = players; turn = Convert.ToInt32(startingPlayer == 0); foreach (var player in players) { player.ExecuteDraw(3); } ExecuteNextTurn(); }
public virtual Card Instantiate() { var card = new Card(name, description, MANA, ATTACK, HEALTH); AttackEvent.Subscribe(card, 0, Attack); DamageEvent.Subscribe(card, 0, Damage); DeathEvent.Subscribe(card, 0, Death); PlayEvent.Subscribe(card, 0, Play); TurnEvent.Subscribe(card, 0, NewTurn); return(card); }
private void updatePlayers(TurnEvent turnEvent) { string players = ""; for (int i = 0; i < turnEvent.game.players.GetLength(0); i++) { players += turnEvent.game.players[i] + "\n"; } spieler.text = players; GameInformation.players = turnEvent.game.players; }
private void MovePiece(TurnLog turnLog, PieceMovement pieceMovement) { Square originSquare = GetSquare(pieceMovement.Piece); Square destinationSquare = GetSquare(pieceMovement.To.Id); destinationSquare.LandPiece(pieceMovement.Piece); originSquare.RemovePiece(); pieceMovement.Piece.Moved(); turnLog.AddEvent(TurnEvent.CreateMovedEvent(Position.Create(pieceMovement.From.Id), Position.Create(pieceMovement.To.Id))); }
private IEnumerable <Wait> OnWater(TurnEvent turn) { Creature creature = turn.Creature; creature.AddStatusEffect(new Wet() { Buildup = 1.0, Duration = new Slider(10), }); yield return(Wait.NoWait); }
public override sealed void OnProcessTurnEvent(GameSession game, TurnEvent e) { base.OnProcessTurnEvent(game, e); if (e.SystemID == 0) { return; } game.GameDatabase.UpdatePlayerViewWithStarSystem(game.LocalPlayer.ID, e.SystemID); int turnCount = game.GameDatabase.GetTurnCount(); game.GameDatabase.InsertExploreRecord(e.SystemID, game.LocalPlayer.ID, turnCount, true, true); }
public void Update() { // When no events are if (events != null && currentEvent == null && events.Count > 0) { // Check if the event is still running if (currentEvent == null) { currentEvent = events.Dequeue(); currentEvent.Go(); } } else if (currentEvent != null) { if (currentEvent.IsComplete()) { currentEvent = null; } } else { if (path != null && path.Count > 0) { ProcessTurn(); } } // Controls map edit mode. if (Input.GetKeyDown(KeyCode.Alpha9)) { if ((int)this.hexGrid.gridEditorMode == Enum.GetValues(typeof(GridEditorMode)).Length - 1) { this.hexGrid.gridEditorMode = 0; } else { this.hexGrid.gridEditorMode += 1; } if (this.hexGrid.gridEditorMode == GridEditorMode.PLAY) { OverworldEventManager.Instance().onHexTileClicked += ProcessTileSelection; this.hexGrid.RemoveHexEditor(); this.fogOfWar.HideAll(); } else if (this.hexGrid.gridEditorMode == GridEditorMode.EDIT) { OverworldEventManager.Instance().onHexTileClicked -= ProcessTileSelection; this.hexGrid.AddHexEditor(); this.fogOfWar.RevealAll(); } } }
public static byte GetEvReportTurnEvent(TurnEvent ev) { switch (ev) { case TurnEvent.DONE_INIT: return(EV_REPORT_INIT); case TurnEvent.TIME_END: return(EV_REPORT_TURN_TIME_END); case TurnEvent.TURN_BEGIN: return(EV_REPORT_TURN_BEGIN); case TurnEvent.TURN_COMPLETE: return(EV_REPORT_TURN_COMPLETE); } throw new System.Exception(); }
private IEnumerable <Wait> OnBog(TurnEvent turn) { Creature creature = turn.Creature; creature.AddStatusEffect(new Muddy() { Buildup = 1.0, Duration = new Slider(20), }); yield return(Wait.NoWait); //yield return creature.AttackSelf(BogAttack); }
private void CheckWebsocket() { string reply = w.RecvString(); if (reply == null) { return; } Debug.Log("got websocket message: " + reply); TurnEvent turnEvent = JsonUtility.FromJson <TurnEvent>(reply); goToGame(turnEvent); }
public void OnTurnEnd(Player player) { TurnEvent turnEndEvent = new TurnEvent() { Player = player }; TurnStartHandler.OnNext(turnEndEvent); foreach (Minion battlefieldMinion in GameManager.Instance.GetAllMinions()) { battlefieldMinion.Buffs.OnTurnEnd.OnNext(turnEndEvent); } }
public IEnumerable <Wait> FrothingTurn(TurnEvent turn) { int traitLvl = turn.Creature.GetTrait(this); Creature creature = turn.Creature; if (creature.Tiles.Any(x => x is Water)) { yield return(creature.WaitSome(10)); yield return(Scheduler.Instance.RunAndWait(RoutineExplosion(creature, 50 * Math.Pow(2, traitLvl - 1), 0))); } yield return(Wait.NoWait); }
/// <summary> /// Checks if there are any dialogues that should be shown. /// </summary> public void CheckDialogueEvents() { for (int i = 0; i < battleMap.dialogueEvents.Count; i++) { TurnEvent pos = battleMap.dialogueEvents.GetEvent(i); if (battleMap.dialogueEvents.IsActivated(i) || currentFaction.value != pos.factionTurn) { continue; } bool activate = false; switch (pos.triggerType) { case TriggerType.TURN: activate = (currentTurn.value == pos.turn); break; case TriggerType.TRIGGER: activate = battleMap.triggerList.IsTriggered(pos.triggerIndex); break; case TriggerType.PLAYER_COUNT: activate = (battleMap.playerList.values.Count <= pos.turn); break; case TriggerType.ALLY_COUNT: activate = (battleMap.allyList.values.Count <= pos.turn); break; case TriggerType.ENEMY_COUNT: activate = (battleMap.enemyList.AliveCount() <= pos.turn); break; } if (activate) { battleMap.dialogueEvents.Activate(i); currentDialogue.value = pos.dialogue; currentDialogueMode.value = (int)DialogueMode.EVENT; startDialogueEvent.Invoke(); return; } } //If no dialogues were triggered nextTurnStateEvent.Invoke(); }
private bool CheckForCapturing(TurnLog turnLog, PieceMovement pieceMovement) { bool isGameOver = false; Square destinationSquare = GetSquare(pieceMovement.To.Id); if (!destinationSquare.IsEmpty) { Piece removedPiece = destinationSquare.RemovePiece(); turnLog.AddEvent(TurnEvent.CreateCapturedEvent(Position.Create(pieceMovement.To.Id))); if (removedPiece.Type == PieceType.King) { isGameOver = true; } } return(isGameOver); }
private IEnumerable <Wait> RoutineField(TurnEvent turn) { Creature user = turn.Creature; var rays = GetRays(user); var tileRays = rays.Select(r => GetBranch(user, r, 8)).Where(r => r != null); var waits = new List <Wait>(); int traitLvl = user.GetTrait(this); foreach (var tileRay in tileRays.Take(traitLvl)) { waits.Add(RoutineBranch(user, tileRay)); yield return(new WaitTime(3)); } yield return(new WaitAll(waits)); }
public void ScheduleTurnEvent(int turn, string eventName) { if (turn <= TurnNumber) { throw new ArgumentOutOfRangeException("turn", "Must provide a turn number in the future."); } var turnEvent = new TurnEvent(turn, eventName); if (!_eventsByTurn.ContainsKey(turn)) { _eventsByTurn[turn] = new List <TurnEvent> { turnEvent }; } else { _eventsByTurn[turn].Add(turnEvent); } }
private void StartNextTurn(Game game, int score, bool removePlayer, List <TilePlacement> tilesPlayed, int tilesSwapped) { var currentPlayerConnectionId = game.CurrentTurnPlayerId; //Figure out who goes next game.NextPlayersTurn(); //Update group of turn var turnEvent = new TurnEvent { CurrentPlayerId = game.CurrentTurnPlayerId, PreviousPlayerId = currentPlayerConnectionId, TilesPlayed = tilesPlayed, Score = score, RemovePlayer = removePlayer, SwappedTiles = tilesSwapped }; _updater.UpdateGroupTurnEvent(game.GameId.ToString(), turnEvent); }
internal static void SyncTurnEventWidget( GameSession game, string panelName, TurnEvent turnEvent) { if (turnEvent == null) { game.UI.SetPropertyString("turnEventMessage", "text", ""); game.UI.SetPropertyString("turnEventImage", "sprite", ""); game.UI.SetVisible("turnEventNext", false); game.UI.SetVisible("turnEventPrevious", false); } else { game.UI.SetPropertyString("turnEventMessage", "text", turnEvent.GetEventMessage(game)); game.UI.SetPropertyString("turnEventImage", "texture", TurnEvent.GetTurnEventSprite(game, turnEvent)); game.UI.SetVisible("turnEventNext", true); game.UI.SetVisible("turnEventPrevious", true); } }
public void OnDrop(PointerEventData eventData) { InGameCard decoy = eventData.pointerDrag.GetComponent <InGameCard>(); if (decoy && decoy.HasDecoy() && cardRow is CombatCardRow) { TurnEvent ev1 = new TurnEvent(decoy.id, cardRow.rowName); TurnEvent ev2 = new TurnEvent(id, hand.rowName); hand.RemoveCard(decoy); cardRow.AddCard(decoy, true); cardRow.RemoveCard(this); hand.AddCard(this, true); GwentNetworkManager gwn = (GwentNetworkManager)FindObjectOfType(typeof(GwentNetworkManager)); gwn.SendTurn(new List <TurnEvent> { ev1, ev2 }); } else { this.transform.parent.SendMessage("OnDrop", eventData); } }
public bool BuyTile(Coordinate2 target) { int turn = matchData.Turn; // Don't want the turn changing while this is running int phase = matchData.Phase; bool purchaseSuccess = false; // Debug.Log(debug + "Player " + turn // + " (ID: " + GameManager.players[turn - 1].Id // + ") trying to buy tile " + target.ToString()); // Check against the rest of the purchasing rules before proceding if (IsValidPurchase(target, turn)) { players[turn - 1].ownedTiles.Add(target); // Server-side gridController.SetTileOwner(target.x, target.y, turn); TurnEvent turnEvent = new TurnEvent(phase, turn, "Buy", "Tile", target.x, target.y, matchDataBroadcaster.TopCardStr, JsonUtility.ToJson(new Card(gridController.GetServerTile("Tile", target.x, target.y)))); matchDataBroadcaster.TurnEventStr = JsonUtility.ToJson(turnEvent); // Debug.Log(debug + "JSON: " + turnEvent); // Debug.Log(debug + "Player " + turn // + " (ID: " + GameManager.players[turn - 1].Id // + ") bought tile " + target.ToString()); UpdatePlayersInfo(); IncrementTurn(); purchaseSuccess = true; } else { // Debug.Log(debug + "Can't purchase, tile " + target.ToString() // + " is not valid for you! \nAlready Owned?\nOut of Range?\nBankrupt Tile?"); } return(purchaseSuccess); }
public bool HandleMove(PieceMovement pieceMovement) { if (!CanBeMovedToRequestedPosition(pieceMovement)) { return(false); } TurnLog turnLog = TurnLog.Create(pieceMovement); bool isGameOver = CheckForCapturing(turnLog, pieceMovement); MovePiece(turnLog, pieceMovement); CheckForCastlingAndMove(turnLog, pieceMovement); if (isGameOver) { turnLog.AddEvent(TurnEvent.CreateGameOverEvent()); } TurnEnded?.Invoke(turnLog); return(true); }
} // OnTurnChange() public bool BuyTile(Coordinate2 target) { int turn = this.turn; // Don't want the turn changing while this is running bool purchaseSuccess = false; Debug.Log(debug + "Player " + turn + " (ID: " + GameManager.players[turn - 1].Id + ") trying to buy tile " + target.ToString()); // Check against the rest of the purchasing rules before proceding if (IsValidPurchase(target, turn)) { GameManager.players[turn - 1].ownedTiles.Add(target); // Server-side GridManager.grid[target.x, target.y].ownerId = turn; TurnEvent turnEvent = new TurnEvent(this.phase, turn, "Buy", "Tile", target.x, target.y); this.turnEventBroadcast = JsonUtility.ToJson(turnEvent); Debug.Log(debug + "JSON: " + turnEvent); // this.turnEventBroadcast = turn + "_x" + target.x + "_y" + target.y; Debug.Log(debug + "Player " + turn + " (ID: " + GameManager.players[turn - 1].Id + ") bought tile " + target.ToString()); // Debug.Log(debug + "Advancing Turn; This is a temporary mechanic!"); purchaseSuccess = true; this.IncrementTurn(); } else { Debug.Log(debug + "Can't purchase, tile " + target.ToString() + " is not valid for you! \nAlready Owned?\nOut of Range?\nBankrupt Tile?"); } return(purchaseSuccess); } // BuyTile()
public void Report(TurnEvent ev) { throw new System.NotImplementedException(); }
public void ExecuteNextTurn() { TurnEvent.Call(new TurnEventArgs(players[Convert.ToInt32(turn == 0)])); }
public static TurnEvent Pass() { TurnEvent e = new TurnEvent("", ""); return(e); }
private static void UpdateShipsKilled( GameSession game, Random rand, Dictionary <FleetInfo, List <ShipInfo> > aiPlayerShips, int randomsPlayerID, int numToKill) { int num1 = numToKill; for (int index = 0; index < numToKill && num1 > 0 && aiPlayerShips.Keys.Count > 0; ++index) { bool flag = false; while (!flag && aiPlayerShips.Keys.Count > 0) { int num2 = 0; foreach (KeyValuePair <FleetInfo, List <ShipInfo> > aiPlayerShip in aiPlayerShips) { num2 += aiPlayerShip.Value.Count; foreach (ShipInfo shipInfo in aiPlayerShip.Value) { ShipInfo ship = shipInfo; if (rand.CoinToss(50)) { num1 -= CombatAI.GetShipStrength(ship.DesignInfo.Class) / 3; if (ship.DesignInfo.IsSuulka()) { TurnEvent turnEvent = game.GameDatabase.GetTurnEventsByTurnNumber(game.GameDatabase.GetTurnCount(), aiPlayerShip.Key.PlayerID).FirstOrDefault <TurnEvent>((Func <TurnEvent, bool>)(x => x.ShipID == ship.ID)); if (turnEvent != null) { game.GameDatabase.RemoveTurnEvent(turnEvent.ID); } game.GameDatabase.InsertTurnEvent(new TurnEvent() { EventType = TurnEventType.EV_SUULKA_DIES, EventMessage = TurnEventMessage.EM_SUULKA_DIES, PlayerID = randomsPlayerID, SystemID = aiPlayerShip.Key.SystemID, ShipID = ship.ID, DesignID = ship.DesignID, TurnNumber = game.GameDatabase.GetTurnCount(), ShowsDialog = false }); SuulkaInfo suulkaByShipId = game.GameDatabase.GetSuulkaByShipID(ship.ID); if (suulkaByShipId != null) { game.GameDatabase.RemoveSuulka(suulkaByShipId.ID); } } game.GameDatabase.RemoveShip(ship.ID); aiPlayerShip.Value.Remove(ship); flag = true; break; } } if (flag) { if (aiPlayerShip.Value.Count == 0) { CombatSimulatorRandoms.FleetDestroyed(game, randomsPlayerID, aiPlayerShip.Key, (ShipInfo)null); game.GameDatabase.RemoveFleet(aiPlayerShip.Key.ID); aiPlayerShips.Remove(aiPlayerShip.Key); break; } break; } } if (num2 == 0) { break; } } } foreach (KeyValuePair <FleetInfo, List <ShipInfo> > aiPlayerShip in aiPlayerShips) { if (aiPlayerShip.Value.Count > 0) { CombatSimulatorRandoms.CheckFleetCommandPoints(game, aiPlayerShip.Key, aiPlayerShip.Value); } } }
private void SyncTurns(int from, int to) { int userItemId = 0; int num = -1; string str = ""; this._app.UI.ClearItems(this._app.UI.Path(this.ID, "eventList")); IEnumerable <TurnEvent> source = this._app.GameDatabase.GetTurnEventsByPlayerID(this._app.LocalPlayer.ID).Where <TurnEvent>((Func <TurnEvent, bool>)(x => { if (x.TurnNumber >= from) { return(x.TurnNumber <= to); } return(false); })); if (source.Count <TurnEvent>() == 0) { return; } foreach (TurnEvent e in source.Reverse <TurnEvent>()) { if (num != e.TurnNumber) { this._app.UI.AddItem(this._app.UI.Path(this.ID, "eventList"), "", e.TurnNumber, ""); str = this._app.UI.GetItemGlobalID(this._app.UI.Path(this.ID, "eventList"), "", e.TurnNumber, ""); this._app.UI.SetPropertyString(this._app.UI.Path(str, "turnNumber"), "text", App.Localize("@TURN") + " " + e.TurnNumber.ToString()); num = e.TurnNumber; } string eventMessage = e.GetEventMessage(this._app.Game); this._app.UI.AddItem(this._app.UI.Path(str, "eventItemList"), "", userItemId, ""); string itemGlobalId = this._app.UI.GetItemGlobalID(this._app.UI.Path(str, "eventItemList"), "", userItemId, ""); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "eventInfo"), "text", eventMessage); this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "eventImage"), "texture", TurnEvent.GetTurnEventSprite(this._app.Game, e)); ++userItemId; } }
public TurnEvent NextTurn() { IPlayer currentPlayer = GetCurrentPlayer(); IPlayerView currentPlayersView = _board.GetPlayerView(_whosTurn); Shot playerShot = currentPlayer.YourTurn(currentPlayersView); ShotFeedback shotFeedback = _board.FireShot(_whosTurn, playerShot); TurnEvent turnEvent = new TurnEvent(); turnEvent.Player = currentPlayer; turnEvent.PlayerNr = _whosTurn; turnEvent.Shot = playerShot; turnEvent.Hit = shotFeedback.Hits > 0; turnEvent.Turn = _turns; if (shotFeedback.Hits > 0 && _board.IsAnyPlayerDead()) { _gameOver = true; return turnEvent; } currentPlayer.ShotFeedback(shotFeedback.Hits, shotFeedback.SunkShips); EndTurn(); return turnEvent; }
public static void Send(TurnEvent _event) { EventHandler.Invoke(_event); }