Skip to content

Creating Trees

Bui1211 edited this page Aug 27, 2017 · 12 revisions

New tree types are created by extending the AbstractTree class.

Tree Events

Normal Events for the tree occur when the tree is not being constructed (e.g. shooting) Construction Events occur when the tree is being constructed (e.g. construction animation) All events are TimeEvent

Tree Designs

As the player you will be able to create many different types of trees. These trees can range between your basic tree, resource gathering trees and other damage trees. You can find detailed sections on the various types of trees and styles by following the links below:

Extending AbstractTree

The method getAllUpgradeStats() must be implemented to return a list of all the upgrades. The list represents:

List Index Value
0 The tree when initially constructed, with no upgrades
1 The first upgrade level
... ...

It is recommended you have this list stored in a static variable if it is the same for all trees of your type

Creating UpgrateStats

The constructor for UpgradeStats Requires: Health, Shooting Speed, Shooting Range, Normal Events, Construction Events, Texture

The Normal and Construction event lists can be modified after the object is created via getNormalEventsReference() and getConstructionEventsReference()

UpgradeStats Constructor:

Parameter Type Description
hp int maximum health
speed int the action speed (shooting, etc.)
range int the range for shooting
constructionTime int the time it takes for the tree to grow
resourceCost int the resource cost, in seeds, of the tree
normalEvents List a list of [[TimeEvents
constructionEvents List a list of [[TimeEvents
texture String the texture for the tree

Example:

For this example, information is stored for the tower upgrades. Results are returned, timer events begin and the stats are then updated for the trees.

public class ExampleTree extends AbstractTree implements Tickable {
	/**
	 * Static field to store information about upgrades
	 */
	public static final List<UpgradeStats> STATS = initStats();

	/**
	 * Default constructor for serialization
	 */
	public ExampleTree() {
	}


	/**
	 * Base Constructor
	 */
	public ExampleTree(float posX, float posY, float posZ, String texture, float maxHealth) {
		super(posX, posY, posZ, 1f, 1f, 1f, texture, maxHealth);
	}

	/**
	 * Returns the list of upgrades for the tree
	 */
	@Override
	public List<UpgradeStats> getAllUpgradeStats() {
		return STATS;
	}
	
	/**
	 * Static method to create the list of upgrades
	 */
	private static List<UpgradeStats> initStats() {
		List<UpgradeStats> result = new LinkedList<>();
		List<TimeEvent<AbstractTree>> normalEvents = new LinkedList<>();
		List<TimeEvent<AbstractTree>> constructionEvents = new LinkedList<>();
		
		/* UpgradeStats(Health, Shooting Time, Shooting Range, Construction/Upgrade Time, events, events, texture) */
		result.add(new UpgradeStats(10, 1000, 8f, 5000, normalEvents, constructionEvents, "real_tree"));
		result.add(new UpgradeStats(20, 600, 8f, 2000, normalEvents, constructionEvents, "real_tree"));
		result.add(new UpgradeStats(30, 100, 8f, 2000, normalEvents, constructionEvents, "real_tree"));
		
		for (UpgradeStats upgradeStats : result) {
			upgradeStats.getNormalEventsReference().add(new TreeProjectileShootEvent(upgradeStats.getSpeed()));
		}
		
		return result;
	}
}

Gameplay

Design

Asset Creation

User Testing

Code Guidelines


http://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gif

Clone this wiki locally