Пример #1
0
  /** Initialize game. */
  public void init() {
    //		// Create characters
    //		Human h1 = new Human("Human 1", HP_HUMANS);
    //		Human h2 = new Human("Human 2", HP_HUMANS);
    //		Vampire v1 = new Vampire("Vampire 1", HP_VAMPIRES);
    //		Vampire v2 = new Vampire("Vampire 2", HP_VAMPIRES);
    //		Zombie z1 = new Zombie("Zombie 1", HP_ZOMBIES);
    //		MadZombie mz1 = new MadZombie("MadZombie 1", HP_ZOMBIES);
    // Add characters to the list
    characterList = new ArrayList<Character>();
    //		characterList.add(h1);
    //		characterList.add(h2);
    //		characterList.add(v1);
    //		characterList.add(v2);
    //		characterList.add(z1);
    //		characterList.add(mz1);
    /*humans = new ArrayList<Human>();
    zombies = new ArrayList<Zombie>();
    vampires = new ArrayList<Vampire>();
    madZombies = new ArrayList<MadZombie>();*/
    //	    humans.add(h1);
    //	    humans.add(h2);
    //	    vampires.add(v1);
    //	    vampires.add(v2);
    //	    zombies.add(z1);
    //	    madZombies.add(mz1);

    shotguns = new ArrayList<ShotGun>();
    nitrogens = new ArrayList<LiquidNitrogen>();
    stakes = new ArrayList<WoodenStake>();

    field = new Field(DEFAULT_DEPTH, DEFAULT_WIDTH);

    // Create a view of the state of each location in the field.
    view = new SimulatorView(DEFAULT_DEPTH, DEFAULT_WIDTH);
    view.setColor(Human.class, Color.orange);
    view.setColor(Zombie.class, Color.green);
    view.setColor(Vampire.class, Color.black);
    view.setColor(MadZombie.class, Color.red);
    view.setColor(BaseObject.class, Color.cyan);

    // Setup a valid starting point.
    reset();
  }
Пример #2
0
  /**
   * Create a simulation field with the given size.
   *
   * @param depth Depth of the field. Must be greater than zero.
   * @param width Width of the field. Must be greater than zero.
   */
  public Simulator(int depth, int width) {
    if (width <= 0 || depth <= 0) {
      System.out.println("The dimensions must be greater than zero.");
      System.out.println("Using default values.");
      depth = DEFAULT_DEPTH;
      width = DEFAULT_WIDTH;
    }

    rabbits = new ArrayList<Rabbit>();
    foxes = new ArrayList<Fox>();
    field = new Field(depth, width);

    // Create a view of the state of each location in the field.
    view = new SimulatorView(depth, width);
    view.setColor(Rabbit.class, Color.orange);
    view.setColor(Fox.class, Color.blue);

    // Setup a valid starting point.
    reset();
  }