-
Notifications
You must be signed in to change notification settings - Fork 4
Creating Trees
New tree types are created by extending the AbstractTree class.
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
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:
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
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 |
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;
}
}
- Home
- How To Play
- Keybindings
- Inventory and Resources
- Trees
- Portals and Worlds
- Projectiles
- Enemies
- Waves & Spawning
- Graphical assets progress overview
- Audio Files
- Design Templates
- Blender Intro
- Converting 3D models to Sprites
- Scripting in Blender
- Creating a Model in Sketchup
- Colouring and Animating in Blender
- Animation using Dope Sheet, Keyframes and Scale Transformation in Blender
- Template
- Testing
- Terrain
- Terrain Generation
- Resource Trees
- Main Menu, Chat, options
- Main Menu V2, Options V2, Sound
- Damage Trees
- Projectiles
- Enemy User Testing
- Tree planting, inventory GUI, resources, portals
- Caveman Character
- Debug Mode Menu
- Tree learning, Attack Trees, Main Menu Tutorial Resources Styling
- Revamped Resource Trees
- Squirrel User Testing
- Final evaluation
- Project Structure
- Git Workflow
- GUI
- Worlds
- Entity Directions
- Resources
- Inventory
- AbstractEntities
- BasicProperties
- MortalEntity
- ProgressBarEntity
- Multiplayer
- Trees
- TimeEvent
- Game Time
- Animations
- Enemies
- Waves
- Player
- Projectiles
- Effect
- Particles
- Path Manager
- Sounds
- Debug 'God' Mode
- 2D Collision
- Box3D {depreciated}
- Render3D
- Cheat Codes