AICommand * SkipTurnStrategy::CreateCommand() const { CommandList * commands = new CommandList(); commands->Add(new SelectWeaponCommand(Weapon::WEAPON_SKIP_TURN)); commands->Add(new StartShootingCommand()); commands->Add(new StopShootingCommand()); return commands; }
AICommand * LoadAndFireStrategy::CreateCommand() const { CommandList * commands = CreateSelectCommandList(shooter, weapon, direction, angle, timeout); commands->Add(new StartShootingCommand()); commands->Add(new WaitForStrengthCommand(strength)); commands->Add(new StopShootingCommand()); commands->Add(new DoNothingForeverCommand()); return commands; }
AICommand * ShootWithGunStrategy::CreateCommand() const { CommandList * commands = CreateSelectCommandList(shooter, weapon, direction, angle); for (int i = 0; i < bullets; i++) { if (i != 0) commands->Add(new DoNothingCommand(1000)); commands->Add(new StartShootingCommand()); commands->Add(new StopShootingCommand()); } commands->Add(new DoNothingCommand(WATCH_MISSILE_TIME_IN_MS)); return commands; }
static CommandList * CreateSelectCommandList(const Character & character, Weapon::Weapon_type weapon, LRDirection direction, float angle, int timeout = -1) { CommandList * commands = new CommandList(); commands->Add(new SelectCharacterCommand(&character)); commands->Add(new DoNothingCommand(1000)); commands->Add(new SelectWeaponCommand(weapon)); commands->Add(new DoNothingCommand(100)); if (timeout > 0) { commands->Add(new SetTimeoutCommand(timeout)); } commands->Add(new DoNothingCommand(100)); commands->Add(new SetDirectionCommand(direction)); commands->Add(new SetWeaponAngleCommand(angle)); commands->Add(new DoNothingCommand(200)); return commands; }