private void StartEntityTurn(TurnEntities entity) { ActiveTurnEntity = entity; OnTurnEnd?.Invoke(ActiveTurnEntity); RefTurnEntity.Value = entity; EntityCollection[entity].StartTurn(this); }
public void ChangeLocationForward(EventInfo eventInfo) { CameraAngleChangeInfo floatChangeInfo = (CameraAngleChangeInfo)eventInfo; int newIndex = 0; int previousIndex = CurrentIndex; if (CurrentIndex + floatChangeInfo.increments <= 3) { newIndex = CurrentIndex + floatChangeInfo.increments; } else { newIndex = (CurrentIndex + floatChangeInfo.increments) % 4; // % operaattori tarkoitaa jakojäännöstä. Korjaa pari väärän sijainnin antamis bugia. turnEndFlag = true; } setCurrentLocation(newIndex); OnLocationChange?.Invoke(); if (hasTurnCompleted()) { OnTurnEnd?.Invoke(); turnEndFlag = false; } }
public void FindMatches() { for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { GameObject select = candyPos[i, j]; if (select != null) { if (i > 0 && i < width - 1) { GameObject left = candyPos[i - 1, j]; GameObject right = candyPos[i + 1, j]; if (left != null && right != null) { if (left.name == select.name && right.name == select.name) { select.GetComponent <Candy>().isMatched = true; left.GetComponent <Candy>().isMatched = true; right.GetComponent <Candy>().isMatched = true; } } } if (j > 0 && j < height - 1) { GameObject down = candyPos[i, j - 1]; GameObject up = candyPos[i, j + 1]; if (down != null && up != null) { if (down.name == select.name && up.name == down.name) { select.GetComponent <Candy>().isMatched = true; up.GetComponent <Candy>().isMatched = true; down.GetComponent <Candy>().isMatched = true; } } } } } } if (IsMatchedOnBoard()) { AddToMatchedList(); } else { if (streakValue == 0) { return; } OnTurnEnd?.Invoke(this, EventArgs.Empty); streakValue = 0; ClearDict(); } }
public void EndTurn() { OnTurnEnd?.Invoke(this, new TurnEventArgs(turnNumber, currentPlayer)); MoveToNextPlayer(); m_TurnNumber++; OnTurnStart?.Invoke(this, new TurnEventArgs(turnNumber, currentPlayer)); }
public void EndTurn() { OnTurnEnd?.Invoke(); HandleTurnEnd(); ResetTurnBar(); BattleManager.Instance.EndTurn(); }
private void EndTurn() { Team team = TurnCounter % 2 == 1 ? Team.Player : Team.Enemy; Debug.Log("Ending Turn"); TurnCounter += 1; OnTurnEnd?.Invoke(this, new TurnEventArgs { Team = team }); }
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)); }
/// <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(); } }
public void TurnEnd() { OnTurnEnd?.Invoke(); if (IsBattleEnd()) { return; } if (IsPhaseEnd()) { UnitsList.ForEach(x => x.IsEnded = false); } TurnStart(); }
/// <summary> /// A callback to progress the current state of the game. /// </summary> /// <param name="baseObject"></param> private void OnProgressTurnButtonLeftClicked(BaseObject baseObject) { // Change the state of the turn and call any appropriate functions switch (TurnState) { // We are currently in the placing cards state case TurnState.kPlaceCards: { // Change to the battle state TurnState = TurnState.kBattle; OnBattleStateStarted?.Invoke(); break; } // We are currently in the battle state case TurnState.kBattle: { // Change to the place cards state and change the turns TurnState = TurnState.kPlaceCards; OnTurnEnd?.Invoke(); NewPlayerTurn(); OnCardPlacementStateStarted?.Invoke(); break; } default: { Debug.Fail(""); break; } } }
private void EndTurn() { OnTurnEnd?.Invoke(); }
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 TurnEnd() { OnTurnEnd?.Invoke(this, EventArgs.Empty); }
private IEnumerator FallingDown() { findMatchesStarted = true; // Debug.Log("@@@ Next Move search matches @@@"); THIS.thrivingBlockDestroyed = false; combo = 0; AI.THIS.allowShowTip = false; var it = field.GetItems(); for (var i = 0; i < it.Count; i++) { var item = it[i]; if (item != null) { item.anim.StopPlayback(); } } destLoopIterations = 0; while (true) { destLoopIterations++; checkMatchesAgain = false; var destroyItemsListed = field.GetItems().Where(i => i.destroyNext).ToList(); if (destroyItemsListed.Count > 0) { yield return(new WaitWhileDestroyPipeline(destroyItemsListed, new Delays())); } yield return(new WaitWhileDestroying()); yield return(new WaitWhile(() => StopFall)); yield return(new WaitWhileFall()); yield return(new WaitWhileCollect()); // yield return new WaitWhileFallSide(); var combineCount = CombineManager.GetCombines(field); if ((combineCount.Count <= 0 || !combineCount.SelectMany(i => i.items).Any()) && !field.DestroyingItemsExist() && !field.GetEmptySquares().Any() && !checkMatchesAgain) { break; } if (destLoopIterations > 10) { foreach (var combine in combineCount) { if (combine.items.Any()) { combine.items.NextRandom().NextType = combine.nextType; } } combineCount.SelectMany(i => i.items).ToList().ForEach(i => i.destroyNext = true); } } if (combo > 2 && gameStatus == GameState.Playing) { gratzWords[Random.Range(0, gratzWords.Length)].SetActive(true); combo = 0; OnCombo?.Invoke(); } //CheckItemsPositions(); DragBlocked = false; findMatchesStarted = false; checkMatchesAgain = false; if (gameStatus == GameState.Playing) { StartCoroutine(AI.THIS.CheckPossibleCombines()); } // Debug.Log("<-next turn->"); if (gameStatus == GameState.Playing && !FindObjectsOfType <AnimateItems>().Any()) { OnTurnEnd?.Invoke(); THIS.CheckWinLose(); } }
public void fireTurnEndEvent() { Utilities.instance.Debug("Turn ended."); OnTurnEnd?.Invoke(); }
/// <summary> /// Ends the player's turn. /// </summary> public virtual void EndTurn() { _hasHadTurn = true; OnTurnEnd?.Invoke(this, new EventArgs()); }
private void HandleOnTurnEnd(Player player) { OnTurnEnd?.Invoke(player); }
/// <summary> /// Notifies this player that their turn has ended. /// </summary> public void TurnEnd() { IsCurrentActor = false; OnTurnEnd?.Invoke(this); }