예제 #1
0
        public void Receive(SwapPokemon swapPokemonAction)
        {
            IPokemon swappedPokemon = swapPokemonAction.Slot.Pokemon;

            SwapPokemonEventArgs swapPokemonEventArgs = new SwapPokemonEventArgs(this, swapPokemonAction);

            OnSwapPokemon?.Invoke(this, swapPokemonEventArgs);

            // TODO

            PokemonSwappedEventArgs pokemonSwappedEventArgs = new PokemonSwappedEventArgs(this, swapPokemonAction, swappedPokemon);

            OnPokemonSwapped?.Invoke(this, pokemonSwappedEventArgs);
        }
예제 #2
0
        public void Swap(int slot1, int slot2)
        {
            if (slot1 < 0 || slot1 >= PokemonCount)
            {
                throw new Exception($"Invalid slot for first pokemon: {slot1}");
            }
            if (slot2 < 0 || slot2 >= PokemonCount)
            {
                throw new Exception($"Invalid slot for second pokemon: {slot2}");
            }

            if (slot1 == slot2)
            {
                throw new Exception($"You cannot swap pokemon in the same slot");
            }
            PokemonSwappedEventArgs args = new PokemonSwappedEventArgs(this, slot1, slot2);

            OnSwapPokemon?.Invoke(this, args);
            Unique.IPokemon tmp = pokemon[slot1];
            pokemon[slot1] = pokemon[slot2];
            pokemon[slot2] = tmp;
            OnPokemonSwapped?.Invoke(this, args);
        }