Пример #1
0
        public object lockObject; //for thread synchronisation

        /// <summary>
        /// Start a battle between two trainers
        /// </summary>
        /// <param name="player">the player (or npc I guess)</param>
        /// <param name="opponent">the opponent</param>
        public PokeBattle(Trainer player, Trainer opponent)
        {
            position    = new BattlePosition[2];
            position[0] = new BattlePosition(0, player, this);
            position[1] = new BattlePosition(1, opponent, this);

            lockObject            = new object();
            waitingForPlayerInput = false;

            //send out first pokemon in party
            for (int i = 0; i < 6; i++)
            {
                if (player.currentPokemon[i] != null)
                {
                    if (player.currentPokemon[i].currentHP > 0)
                    {
                        Positions[0].SwitchPokemon(new BattlePokemon(player.currentPokemon[i]));
                        break;
                    }
                }
            }
            for (int i = 0; i < 6; i++)
            {
                if (player.currentPokemon[i] != null)
                {
                    if (player.currentPokemon[i].currentHP > 0)
                    {
                        Positions[1].SwitchPokemon(new BattlePokemon(opponent.currentPokemon[i]));
                        break;
                    }
                }
            }
            BattleStack.initializeStacks(this);
        }
Пример #2
0
        /// <summary>
        /// Start a battle between two trainers
        /// </summary>
        /// <param name="player">the player (or npc I guess)</param>
        /// <param name="opponent">the opponent</param>
        /// <param name="numberOfPositions">number of places on the field (two is the normal)</param>
        public PokeBattle(Trainer player, Trainer opponent, int numberOfPositions)
        {
            lockObject            = new object();
            waitingForPlayerInput = false;

            //throw an error if given an odd number
            if ((numberOfPositions % 2) != 0)
            {
                throw(new ArgumentException("Number of Positions must be even!"));
            }

            position = new BattlePosition[numberOfPositions];

            //set the first half to the player
            for (int i = 0; i < (numberOfPositions / 2); i++)
            {
                position[i] = new BattlePosition(i, player, this);
            }
            //second half to the opponent
            for (int i = (numberOfPositions / 2); i < numberOfPositions; i++)
            {
                position[i] = new BattlePosition(i, opponent, this);
            }
            BattleStack.initializeStacks(this);
            //speedOrder = GetSpeedOrder();
        }
Пример #3
0
        private void useMove(BattlePosition position)
        {
            //show dialog message
            PokeEngineScriptHelper.ShowMessage(position.pokemon.pokemon.Nickname + " uses " + position.choice.move.bMove.name);
            //use the move
            Lua lua = new Lua();

            //put in the persistant variables
            TFSH.ScriptVariables.PutVariables(lua);
            lua["user"]   = position.pokemon;
            lua["move"]   = position.choice.move;
            lua["effect"] = position.choice.move.bMove.effectScript;
            lua["target"] = position.choice.target.pokemon;
            LuaRegistrationHelper.TaggedStaticMethods(lua, typeof(TFSH.PokeEngineScriptHelper));
            lua.DoString(position.choice.move.bMove.moveScript);
            //store any changes to the persistant variables
            TFSH.ScriptVariables.TakeVariables(lua);
        }