/// <summary> /// Processes the players turn start. /// </summary> public virtual void ProcessTurnStart() { ActionsPerformed = 0; LevelUpLandmarkedUnits(); SpawnUnits(); OnTurnStart?.Invoke(this, new EventArgs()); }
private void AddCard(object sender, OnCardSelectEventArgs e) { if (turnedCards.Count >= maxCardsTurned) { return; } e.selectedCard.FlipCard(); turnedCards.Add(e.selectedCard); if (turnedCards.Count >= maxCardsTurned) { if (Check(turnedCards)) { StartCoroutine(DestroyAllCards(turnedCards)); IPlayer player = (IPlayer)sender; player.Score += 1; if (totalCards <= 0) { GameEnd(); return; } else { OnTurnStart?.Invoke(this, new OnTurnStartEventArgs { playerName = players[currPlayer].Name, next = false }); } } else { StartCoroutine(TurnAllCards(turnedCards)); NextPlayer(); } } }
public static OnTurnStart alloc(ActionPointGUIComponent p_actionPointGUIComponent) { OnTurnStart l_instance = new OnTurnStart(); l_instance.ActionPointGUIComponent = p_actionPointGUIComponent; return(l_instance); }
public void StartTurn() { OnTurnStart?.Invoke(); HandleTurnStart(); //EndTurn(); }
public void EndTurn() { OnTurnEnd?.Invoke(this, new TurnEventArgs(turnNumber, currentPlayer)); MoveToNextPlayer(); m_TurnNumber++; OnTurnStart?.Invoke(this, new TurnEventArgs(turnNumber, currentPlayer)); }
private void Start() { m_entityRegistrationComponent = RuntimeObject.FindComponent <EntityRegistrationComponent>(); cachedActionPointEntityComponent = CachedEntityComponent <ActionPoint> .build(m_entityRegistrationComponent.AssociatedEntity); gameObject.SetActive(false); MyEvent <Entity> .IEventCallback l_onTurnStart = OnTurnStart.alloc(this); MyEvent <Entity> .IEventCallback l_onTurnEnd = OnTurnEnd.alloc(this); MyEvent <Entity> .register(ref m_entityRegistrationComponent.AssociatedEntity.OnEntityTurnStart, ref l_onTurnStart); MyEvent <Entity> .register(ref m_entityRegistrationComponent.AssociatedEntity.OnEntityTurnEnd, ref l_onTurnEnd); }
private void NextPlayer() { players[currPlayer].EndTurn(); currPlayer++; if (currPlayer >= players.Count) { currPlayer = 0; } OnTurnStart?.Invoke(this, new OnTurnStartEventArgs { playerName = players[currPlayer].Name }); players[currPlayer].StartTurn(); }
public void PlayTurn() { TurnCount++; if (!GameCanContinue()) { return; } Card player1Card = _player1.PlayCard(); Card player2Card = _player2.PlayCard(); OnTurnStart?.Invoke(this, new StartEventArgs(player1Card, player2Card)); if (player1Card.Value > player2Card.Value) { _player1.AddCards(player1Card, player2Card); OnTurnFinish?.Invoke(this, new FinishEventArgs("Player 1")); } else if (player2Card.Value > player1Card.Value) { _player2.AddCards(player2Card, player1Card); OnTurnFinish?.Invoke(this, new FinishEventArgs("Player 2")); } else { // Both cards have the same value, so they'll go to war. War(new List <Card> { player1Card }, new List <Card> { player2Card }); } if (TurnCount >= _maxTurnCount) { OnGameFinish?.Invoke(this, new FinishEventArgs("Tie")); } if (_player1.CardsLeft <= 0) { OnGameFinish?.Invoke(this, new FinishEventArgs("Player 2")); } if (_player2.CardsLeft <= 0) { OnGameFinish?.Invoke(this, new FinishEventArgs("Player 1")); } }
public void EndTurn() { OnTurnEnd?.Invoke(this, new TurnEventArgs(turnNumber, currentPlayer)); MoveToNextPlayer(currentPlayer); if (playerQueue.Count == 0) { turnNumber++; playerQueue.Enqueue(1); playerQueue.Enqueue(2); } OnTurnStart?.Invoke(this, new TurnEventArgs(turnNumber, currentPlayer)); }
private void SetNextUnit() { BattleUnit unit = GetNextUnit(); unit.OnUnitStartTurn(); ReduceUnitTimes(unit.time); movementLimitObj.enabled = unit.isPlayerUnit; movementLimitObj.transform.position = unit.transform.position - (unit.sprite.transform.localPosition / 2); //Offset by half the sprite's local position so visually //the sprite will hit the edge of the circle limit OnTurnStart?.Invoke(); activeUnit = unit; }
/// <summary> /// Proceeds to the next thing in the turn order if /// there is one. /// </summary> private void Next() { turnEndRequested = false; turnEndInProgress = true; // Notify that the current actor's turn is ending if (turnOrder.Current != null) { turnOrder.Current.OnTurnEnd(); OnTurnEnd?.Invoke(turnOrder.Current); } // If the round hasn't started notify that a new one // is starting if (!roundStarted) { RoundCount++; OnRoundStart?.Invoke(); roundStarted = true; } // Go to next thing in the turn order bool anyMore = turnOrder.MoveNext(); // If there's nothing left in the order then the round has ended if (!anyMore) { roundStarted = false; turnOrder.Reset(); OnRoundEnd?.Invoke(); } // Otherwise, let the new thing know its turn is // starting else { // Notify the turn based thing FIRST - then other listeners. turnOrder.Current.OnTurnStart(); OnTurnStart?.Invoke(turnOrder.Current); } turnEndInProgress = false; if (turnEndRequested) { Next(); } }
private void StartTurn() { Team team = TurnCounter % 2 == 1 ? Team.Player: Team.Enemy; Debug.Log("Team " + team + " Turn " + TurnCounter / 2); if (TurnCounter == 1) { selectedPiece = null; Debug.Log("TEst"); OnTurnStart += ExecuteAI; } OnTurnStart?.Invoke(this, new TurnEventArgs { Team = team }); }
public void NextTurn() { InitState = InitializationState.Updating; _turnCounter++; foreach (Vector3Int pos in TilesDataManager.Instance.GetTilemapBounds().allPositionsWithin) { if (TilesDataManager.Instance.HasTile(pos)) { BaseTileData tile = TilesDataManager.Instance.GetTileDataAtPos(pos); tile.OnTurnStarts(); } } OnTurnStart?.Invoke(); PredictNextTurn(); InitState = InitializationState.Ready; }
void OnSocketMessage(object sender, MessageEventArgs e) { var parser = new MessageParser(e.Data); var message = parser.GetObject(); // All events are fired from the main thread Dispatcher.Enqueue(() => { OnGetMessage.TryInvoke(message); switch (parser.Path.ToLower()) { case "turn.start": OnTurnStart.TryInvoke(message as TurnStartMessage); break; case "turn.end": m_Socket.Send(BingUtils.TurnEndAcknowledgement()); m_Buffer = new byte[0]; OnTurnEnd.TryInvoke(message as TurnEndMessage); Status = BingStatus.Disconnecting; m_Socket.CloseAsync(() => { Connect(); }); break; case "speech.enddetected": OnSpeechEndDetected.TryInvoke(message as SpeechEndDetectedMessage); break; case "speech.phrase": OnSpeechPhrase.TryInvoke(message as SpeechPhraseMessage); break; case "speech.hypothesis": OnSpeechHypothesis.TryInvoke(message as SpeechHypothesisMessage); break; case "speech.startdetected": OnSpeechStartDetected.TryInvoke(message as SpeechStartDetectedMessage); break; case "speech.fragment": OnSpeechFragment.TryInvoke(message as SpeechFragmentMessage); break; } }); }
public void Init(List <Player> players) { playerQueue = new Queue <Player>(players); currentPlayer = playerQueue.Dequeue(); OnTurnStart?.Invoke(this, new TurnEventArgs(turnNumber, currentPlayer)); }
private void StartTurn() { _heroesToSimulateActionsCounter = _heroesControllers.Count; OnTurnStart?.Invoke(); }
/// <summary> /// Notifies this player that their turn has started. /// </summary> public void TurnStart() { IsCurrentActor = true; Debug.Log($"It's {Name}'s turn!"); OnTurnStart?.Invoke(this); }
private void HandleOnTurnStart(Player player) { OnTurnStart?.Invoke(player); }
public void ExecuteTurn() { if (currentState == State.END) { return; } // Don't do anything if battle is over if (currentState == State.START) { //Add effects of all Pokemon Abilities in battle foreach (Team team in Teams) { foreach (Slot slot in team) { RegisterEffect(slot.Pokemon.Ability.newEffect(this, slot.Pokemon)); } } OnBattleStart?.Invoke(this, BattleArgs); currentState = State.IN_PROGRESS; } OnTurnStart?.Invoke(this, BattleArgs); /* First we enqueue BattleActionRequests for all battle slots that are still in play. The * purpose of this is to allow move effects to trigger based on the enqueue'ing of the * BattleActionRequests. This allows effects from moves like Taunt modify which battlers * we make BattleActionRequests for. */ foreach (Team team in Teams) { foreach (Slot slot in team) { if (slot.IsInPlay) { MessageQueue.Enqueue(new Request(slot)); } } } actionRequests.Clear(); Flush(); RequestInputEventArgs requestInputEventArgs = new RequestInputEventArgs(this, actionRequests); OnRequestInput?.Invoke(this, requestInputEventArgs); List <IAction> actions = new List <IAction>(InputProvider.ProvideActions(this, actionRequests)); InputReceivedEventArgs inputReceivedEventArgs = new InputReceivedEventArgs(this, actionRequests, actions); OnInputReceived?.Invoke(this, inputReceivedEventArgs); actions.Sort(ActionComparer); foreach (IAction action in actions) { MessageQueue.Enqueue(action); } while (true) { Flush(); List <Request> requests = new List <Request>(); foreach (Team team in Teams) { foreach (Slot slot in team) { if (slot.Pokemon.HasFainted() && !slot.Participant.HasLost()) { requests.Add(new Request(slot)); } } } if (requests.Count == 0) { break; } IList <SwapPokemon> swapPokemonActions = InputProvider.ProvideSwapPokemon(this, requests); foreach (SwapPokemon swapPokemonAction in swapPokemonActions) { MessageQueue.Enqueue(swapPokemonAction); } } CurrentWeather.DecrementTurnCounter(); if (CurrentWeather.IsComplete) { WeatherCompletedEventArgs weatherCompletedEventArgs = new WeatherCompletedEventArgs(this, CurrentWeather); OnWeatherCompleted?.Invoke(this, weatherCompletedEventArgs); MessageQueue.AddFirst(new WeatherChange(SurroundingWeather, -1)); Broadcast(); } OnTurnEnd?.Invoke(this, BattleArgs); /* * Why is this loop run after OnTurnEnd is called? * We need to be able to process events that occur just before the end of the turn. */ while (true) { Flush(); List <Request> requests = new List <Request>(); foreach (Team team in Teams) { foreach (Slot slot in team) { if (slot.Pokemon.HasFainted() && !slot.Participant.HasLost()) { requests.Add(new Request(slot)); } } } if (requests.Count == 0) { break; } IList <SwapPokemon> swapPokemonActions = InputProvider.ProvideSwapPokemon(this, requests); foreach (SwapPokemon swapPokemonAction in swapPokemonActions) { MessageQueue.Enqueue(swapPokemonAction); } } if (this.IsComplete()) { BattleEndEventArgs battleEndEventArgs = new BattleEndEventArgs(this, this.Winner()); OnBattleEnd?.Invoke(this, battleEndEventArgs); currentState = State.END; } TurnCounter += 1; }
public void TurnStart() { SortUnits(); OnTurnStart?.Invoke(); }
private void StartTurnForPlayer(ChessPlayer player) { NextTurnPlayer = player; OnTurnStart?.Invoke(this, new OnTurnStartEventArgs(NextTurnPlayer)); }
public void TurnStart() { OnTurnStart?.Invoke(this, EventArgs.Empty); }