Astraeus Player's Guide

My First Team

SETTING UP YOUR PACKAGE

Renaming Package and Files

PLAYER CLASS

The Constructor


The constructor is called before the game begins. 


public MyTeamPlayer(int team, Game g) 

{

super(team, g);

// Your team name and image.   The image should be in a 4:3 ratio.

setName("MyTeam");

setTeamImage("src/teams/student/myTeam/myTeam.png");


  // You can set your team colors here as RGB values.  

setColorPrimary(150, 150, 150);

setColorSecondary(255, 255, 255);

setColorAccent(255, 255, 255);

}

Strategy Method


This method is called every frame.  It is used to help set your team's strategy and build order.  


There are many ways to decide which units to build.  The example team simply tries to keep units at a certain ratio to each other.  You may also consider...


pulic void strategy()

{

  // In this example our player is ONLY setting a build order
  // However, you may want to determine when to attack or defend here too!


  // Checks what percentage of the fleet are each type
  // This approach scales by unit cost, not absolute numbers.


if(getFleetValuePercentage(Worker.class) < .5f)

{

    buildUnit(new Worker(this));

}

else

{

    buildUnit(new Fighter(this));

}

}

When you run the program, you'll see Fleet values at the bottom. 

Resources are listed twice 

Draw Method


This method is called every frame when it is enabled.  It can be toggled in:

public void draw(Graphics g)

{

  // You can use ANY drawing method you would like in here

  // This is very useful for showing what your units are trying to do

}

UNIT SUPERCLASS

Action Method


This method is called every frame.  During a unit's action, it can:

public void action()

{

    // If you want all your units to perform a default action, add code here
    // Reminder: It won't work unless subclasses call super.action() !

}


Draw Method


This method is called every frame when it is enabled.  It can be toggled in:

public void draw(Graphics g)

{

  // You can use ANY drawing method you would like in here

  // This is very useful for displaying data and decisions

}


An Example Method: Skirmish


This is just an example method, it isn't something that is a core part of Astraeus.  This teaches all of our unit types to move and attack.    


public void skirmish(Weapon w)

{

   // Find the nearest enemy and store it in a local variable

   Unit enemy = getNearestEnemy();

   // If the enemy actually exists.... (stops us from crashing if we win)

   if(enemy != null)

   {
      // Use the selected weapon against the nearest enemy

       w.use(enemy);


      // if I am far away from the enemy, approach it...

      if(getDistance(enemy) > getMaxRange())

      {
        moveTo(enemy)

      }

      // Otherwise run away!

      else

      {
        turnTo(enemy);
        turnAround();

        move();

      }

   }


}

BASIC FIGHTER

Design


public void design()

{

       // This unit costs 6 credits

          // Medium Frame (2) Weapons (2) + Upgrades (2)

  // For more information, see the units page. 


setFrame(Frame.MEDIUM);

setStyle(Style.DAGGER);

addWeapon(new MachineGun(this));

addWeapon(new SmallLaser(this));

addUpgrade(new Plating(this));

addUpgrade(new Shield(this));

}

Action()


The action method is called every frame and determines what the ship does.  In this case it calls the Skirmish() method from the superclass.


public void action() 

{

    // This overrides the basic unit action method. 
        // Call super.action() too if you want to do your general action first.

        // Calls the skirmish method for each weapon.

skirmish(getWeaponOne());

skirmish(getWeaponTwo());

}

Making Additional Combat Units


This is going to be a lot of your work in the project.   Here are a few basic things you can explore:

Basic Worker

Improving Gatherering

Improving Mining


Try watching your worker.  If you look carefully, you'll notice that it isn't always mining!  It bobs in and out of range.  This results in some wasted time.  How can you modify the harvest method to be better?