Example #1
0
 public override void ProcessEnemyDeath()
 {
     if (_controlledEnemy.GetDead())
     {
         OnBattleEnd.Invoke();
     }
 }
Example #2
0
 public override void ProcessEnemyDeath()
 {
     ChendePosition();
     if (_countWolf == 0)
     {
         OnBattleEnd.Invoke();
     }
 }
Example #3
0
 public override void ProcessEnemyDeath()
 {
     if (_controlledEnemy.GetDead())
     {
         SoundManager.Instance.PlaySoundClip(DieSound, true);
         OnBattleEnd.Invoke();
     }
 }
Example #4
0
 // 战斗结束最后一帧
 void ProcessBattleEndFrame(string winner)
 {
     BattleEnd(winner);
     OnBattleEnd.SC(this, winner, inReplay);
 }
Example #5
0
        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;
        }
 protected override void Die()
 {
     OnBattleEnd.Invoke(true);
 }
Example #7
0
 public void EndBattle()
 {
     _batl = false;
     StartCoroutine(Sprint(4));
     OnBattleEnd.Invoke();
 }
Example #8
0
 protected override void Die()
 {
     OnBattleEnd.Invoke(false);
     Stats.OnCharacterDeath -= Die;
 }