示例#1
0
  public void generateAi(List<AiGeneratorInterface.GenerateCommand> generationCommands) {

    squadCount = 0;

    for (AiGeneratorInterface.GenerateCommand command : generationCommands) {

      if (command instanceof DaemonRandomSpawn) {
        generateDaemonAi((DaemonRandomSpawn) command, squadCount);
        squadCount++;
        continue;
      }

      if (command instanceof SoloGenerateCommand) {
        generateSoloAi((SoloGenerateCommand) command, squadCount);
        squadCount++;
        continue;
      }

      switch (command.getFaction()) {
        case WHITE_VISTA:
          generateTeam(
              Integer.toString(squadCount) + WHITE_VISTA,
              command.getTeamSize(),
              command.getAllowedItems(),
              command.getAllowedWeapons(),
              combatMembersManager.getCommander(WHITE_VISTA).getSpawnRoom());
          break;
        case BANDITS:
          generateTeam(
              Integer.toString(squadCount) + BANDITS,
              command.getTeamSize(),
              command.getAllowedItems(),
              command.getAllowedWeapons(),
              combatMembersManager.getCommander(BANDITS).getSpawnRoom());
          break;
        case PLAYER:
          generatePlayerTeam(command.getSquad(), levelManager.getCurrentLevel().getPlayerSpawn());
          break;
        case LONER:
          generateLoner(
              Integer.toString(squadCount) + LONER,
              command.getAllowedItems(),
              command.getAllowedWeapons(),
              levelManager.randomRoom());
          break;
      }
      squadCount++;
    }

    combatMembersManager.pickStartingAi();
    generateRosters();
    combatUiManager.getAllyRoster().generatePortraits();
    aiCrowd.shuffleAi();
  }
示例#2
0
  @Override
  public void setDead(Ai killer, boolean dead) {
    if (dead) {
      LevelBlock randomRoom;
      do {
        randomRoom = levelManager.randomRoom();
      } while (randomRoom == this.getLevelBlock());

      this.setLocation(levelManager.randomInPosition(randomRoom));
      this.setLevelBlock(randomRoom);
      this.setMoveLocationToSelf();
    }
  }
示例#3
0
  private void generateLoner(
      String team, List<String> allowedItems, List<String> allowedWeapons, LevelBlock room) {

    double[] randomLocation = levelManager.randomInPosition(room);

    AiImage aiImg =
        new AiImage(
            aiCrowd,
            combatMembersManager,
            combatUiManager,
            combatVisualManager,
            panningManager,
            0,
            0,
            mouseAbilityHandler,
            floatingIcons);
    ThinkingAi ai;

    DialoguePool dialoguePool = new DialoguePool(LONER, missionManager, cartographer, messageBox);

    ai =
        new LonerAi(
            panningManager,
            aiCrowd,
            combatVisualManager,
            turnProcess,
            floatingIcons,
            mouseAbilityHandler,
            combatMembersManager,
            randomName(),
            randomLocation[0],
            randomLocation[1],
            levelManager,
            combatInorganicManager,
            combatUiManager,
            lootbox,
            dialoguePool);
    ai.setBaseAggression(ThinkingAiEmotion.PASSIVE_RESPOND);
    ai.setImage(randomImage());
    ai.setTeam(team);

    applyLootList(allowedItems, allowedWeapons, ai);

    ai.assignAbilities();
    aiImg.setAi(ai);

    aiCrowd.addDisplayItem(aiImg);
    aiCrowd.addMouseActionItem(aiImg);

    aiCrowd.addActor(ai, new DirectorClassification(DirectorArchetype.UNDECIDED));
    aiCrowd.addMask(aiImg);

    combatMembersManager.addAi(ai);
  }
示例#4
0
  private void generateTeam(
      String team,
      int members,
      List<String> allowedItems,
      List<String> allowedWeapons,
      LevelBlock spawnRoom) {

    double[] randomLocation = levelManager.randomInPosition(spawnRoom);

    Pattern numberPattern = Pattern.compile("[0-9]+");
    Matcher numberMatcher;
    numberMatcher = numberPattern.matcher(team);
    numberMatcher.find();

    for (int i = 0; i < members; i++) {
      AiImage aiImg =
          new AiImage(
              aiCrowd,
              combatMembersManager,
              combatUiManager,
              combatVisualManager,
              panningManager,
              0,
              0,
              mouseAbilityHandler,
              floatingIcons);

      String faction = team.substring(numberMatcher.group().length());

      DialoguePool dialoguePool =
          new DialoguePool(faction, missionManager, cartographer, messageBox);

      ThinkingAi ai =
          new ThinkingAi(
              dialoguePool,
              panningManager,
              combatVisualManager,
              turnProcess,
              floatingIcons,
              mouseAbilityHandler,
              aiCrowd,
              combatMembersManager,
              randomName(),
              randomLocation[0],
              randomLocation[1],
              levelManager,
              combatInorganicManager,
              combatUiManager,
              lootbox);

      ai.setImage(randomImage());

      ai.setTeam(team);

      applyLootList(allowedItems, allowedWeapons, ai);

      switch (ai.getFaction()) {
        case BANDITS:
          ai.setBaseAggression(ThinkingAiEmotion.AGGRESSIVE_FIGHTER);
          ai.setImage("Bandit");
          break;
        case WHITE_VISTA:
          ai.setBaseAggression(ThinkingAiEmotion.PASSIVE_RESPOND);
          ai.setImage("Armour");
          break;
      }

      ai.assignAbilities();
      aiImg.setAi(ai);
      aiCrowd.addDisplayItem(aiImg);
      aiCrowd.addMouseActionItem(aiImg);

      aiCrowd.addActor(ai, new DirectorClassification(DirectorArchetype.UNDECIDED));
      aiCrowd.addMask(aiImg);

      randomLocation = levelManager.randomInPosition(spawnRoom);

      combatMembersManager.addAi(ai);
    }
  }
示例#5
0
  private void generatePlayerTeam(ArrayList<Squaddie> squad, LevelBlock levelBlock) {
    double[] randomLocation = levelManager.randomInPosition(levelBlock);

    for (int i = 0; i < squad.size(); i++) {

      Ai ai = null;
      AiImage aiImg = null;

      if (squad.get(i).isVehicle()) {
        aiImg =
            new VehicleImage(
                aiCrowd,
                combatMembersManager,
                combatUiManager,
                combatVisualManager,
                panningManager,
                100,
                100,
                mouseAbilityHandler,
                floatingIcons);

        switch (squad.get(i).getVehicleType()) {
          case MuleAi.MULE:
            ai =
                new MuleAi(
                    panningManager,
                    floatingIcons,
                    mouseAbilityHandler,
                    squad.get(i).getName(),
                    randomLocation[0],
                    randomLocation[1],
                    combatInorganicManager,
                    levelManager,
                    lootbox,
                    combatMembersManager,
                    combatUiManager,
                    combatVisualManager,
                    aiCrowd,
                    turnProcess);
            break;
        }

        ai.setImage(squad.get(i).getImage());
        ai.setTeam("1Player");
      } else {
        aiImg =
            new AiImage(
                aiCrowd,
                combatMembersManager,
                combatUiManager,
                combatVisualManager,
                panningManager,
                100,
                100,
                mouseAbilityHandler,
                floatingIcons);

        ai =
            new Ai(
                floatingIcons,
                mouseAbilityHandler,
                squad.get(i).getName(),
                randomLocation[0],
                randomLocation[1],
                combatInorganicManager,
                levelManager,
                lootbox,
                combatMembersManager,
                combatUiManager,
                combatVisualManager,
                aiCrowd,
                panningManager,
                turnProcess);
        ai.setImage(squad.get(i).getImage());
        ai.setTeam("1Player");
      }

      Iterator<String> skillIt = squad.get(i).getSkills();
      while (skillIt.hasNext()) {
        String next = skillIt.next();
        ai.setSkill(next, squad.get(i).getSkillLevel(next));
      }

      ai.setWeapon(Weapon.stringToWeapon(squad.get(i).getWeapon()));

      Iterator<String> itemIt = squad.get(i).getItems();

      while (itemIt.hasNext()) {
        ai.addItem(Item.stringToItem(itemIt.next()));
      }

      ai.assignAbilities();
      aiImg.setAi(ai);
      aiCrowd.addDisplayItem(aiImg);
      aiCrowd.addMouseActionItem(aiImg);

      aiCrowd.addActor(ai, new DirectorClassification(DirectorArchetype.PLAYER));
      aiCrowd.addMask(aiImg);

      randomLocation = levelManager.randomInPosition(levelBlock);

      combatMembersManager.addAi(ai);
    }
  }
示例#6
0
  private void generateDaemonAi(DaemonRandomSpawn command, int squadCount) {
    double[] location = levelManager.randomPosition();

    AiImage aiImg =
        new AiImage(
            aiCrowd,
            combatMembersManager,
            combatUiManager,
            combatVisualManager,
            panningManager,
            0,
            0,
            mouseAbilityHandler,
            floatingIcons);
    ThinkingAi ai = null;

    DialoguePool dialoguePool = new DialoguePool(DAEMON, missionManager, cartographer, messageBox);

    ai =
        new DaemonAi(
            panningManager,
            combatVisualManager,
            turnProcess,
            floatingIcons,
            mouseAbilityHandler,
            aiCrowd,
            combatMembersManager,
            randomDaemonName(),
            location[0],
            location[1],
            levelManager,
            combatInorganicManager,
            combatUiManager,
            lootbox,
            dialoguePool);
    ai.setBaseAggression(ThinkingAiEmotion.MINDLESS_TERROR);
    aiImg =
        new DaemonImage(
            aiCrowd,
            combatMembersManager,
            combatUiManager,
            combatVisualManager,
            panningManager,
            location[0],
            location[1],
            mouseAbilityHandler,
            floatingIcons);
    ai.setTeam(squadCount + DAEMON);

    ai.setWeapon(new DaemonWeapon());

    ai.assignAbilities();
    aiImg.setAi(ai);

    aiCrowd.addDisplayItem(aiImg);
    aiCrowd.addMouseActionItem(aiImg);

    aiCrowd.addActor(ai, new DirectorClassification(DirectorArchetype.UNDECIDED));
    aiCrowd.addMask(aiImg);

    combatMembersManager.addAi(ai);
  }
示例#7
0
  private void generateSoloAi(SoloGenerateCommand command, int team) {

    double[] location = null;

    if (command.x == null && !command.getFaction().equals(AiGenerator.LONER))
      location =
          levelManager.randomInPosition(
              combatMembersManager.getCommander(command.getFaction()).getSpawnRoom());
    else if (command.x == null && command.getFaction().equals(AiGenerator.LONER))
      location = levelManager.randomPosition();
    else location = new double[] {command.x, command.y};

    AiImage aiImg =
        new AiImage(
            aiCrowd,
            combatMembersManager,
            combatUiManager,
            combatVisualManager,
            panningManager,
            0,
            0,
            mouseAbilityHandler,
            floatingIcons);
    ThinkingAi ai = null;

    DialoguePool dialoguePool =
        new DialoguePool(command.getFaction(), missionManager, cartographer, messageBox);

    switch (command.getFaction()) {
      case AiGenerator.LONER:
        if (command.isDaemon()) {
          ai =
              new DaemonAi(
                  panningManager,
                  combatVisualManager,
                  turnProcess,
                  floatingIcons,
                  mouseAbilityHandler,
                  aiCrowd,
                  combatMembersManager,
                  command.getName(),
                  location[0],
                  location[1],
                  levelManager,
                  combatInorganicManager,
                  combatUiManager,
                  lootbox,
                  dialoguePool);
          ai.setBaseAggression(ThinkingAiEmotion.MINDLESS_TERROR);
          aiImg =
              new DaemonImage(
                  aiCrowd,
                  combatMembersManager,
                  combatUiManager,
                  combatVisualManager,
                  panningManager,
                  location[0],
                  location[1],
                  mouseAbilityHandler,
                  floatingIcons);
        } else {
          ai =
              new LonerAi(
                  panningManager,
                  aiCrowd,
                  combatVisualManager,
                  turnProcess,
                  floatingIcons,
                  mouseAbilityHandler,
                  combatMembersManager,
                  command.getName(),
                  location[0],
                  location[1],
                  levelManager,
                  combatInorganicManager,
                  combatUiManager,
                  lootbox,
                  dialoguePool);
          ai.setBaseAggression(ThinkingAiEmotion.PASSIVE_RESPOND);
          ai.setImage(randomImage());
        }
        ai.setTeam(team + LONER);
        break;
      case AiGenerator.WHITE_VISTA:
        ai =
            new ThinkingAi(
                dialoguePool,
                panningManager,
                combatVisualManager,
                turnProcess,
                floatingIcons,
                mouseAbilityHandler,
                aiCrowd,
                combatMembersManager,
                command.getName(),
                location[0],
                location[1],
                levelManager,
                combatInorganicManager,
                combatUiManager,
                lootbox);
        ai.setBaseAggression(ThinkingAiEmotion.PASSIVE_RESPOND);
        ai.setImage("Armour");
        ai.setTeam(team + WHITE_VISTA);
        break;
      case AiGenerator.BANDITS:
        ai =
            new ThinkingAi(
                dialoguePool,
                panningManager,
                combatVisualManager,
                turnProcess,
                floatingIcons,
                mouseAbilityHandler,
                aiCrowd,
                combatMembersManager,
                command.getName(),
                location[0],
                location[1],
                levelManager,
                combatInorganicManager,
                combatUiManager,
                lootbox);
        ai.setBaseAggression(ThinkingAiEmotion.AGGRESSIVE_FIGHTER);
        ai.setImage("Bandit");
        ai.setTeam(team + BANDITS);
        break;
    }

    if (command.isDaemon()) {
      ai.setWeapon(new DaemonWeapon());
    } else {
      ai.setWeapon(Weapon.stringToWeapon(command.getWeapon()));

      if (command.getItems() != null)
        for (int i = 0; i < command.getItems().length; i++) {
          ai.addItem(Item.stringToItem(command.getItems()[i]));
        }
    }

    ai.assignAbilities();
    aiImg.setAi(ai);

    aiCrowd.addDisplayItem(aiImg);
    aiCrowd.addMouseActionItem(aiImg);

    aiCrowd.addActor(ai, new DirectorClassification(command.directorClass));
    aiCrowd.addMask(aiImg);

    if (command.getAiNode() != null) {
      List<String> priority = new ArrayList<String>(1);
      priority.add(ai.getName());
      command.getAiNode().addPriorities(priority);
      ai.setAiNode(command.getAiNode());
    }

    combatMembersManager.addAi(ai);

    String[] alliances = command.getAlliances();
    if (alliances != null)
      for (int i = 0; i < alliances.length; i++) {
        ai.getCommander().addAlliance(alliances[i]);
      }
  }