Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
TowerDefense/src/TowerTypes.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
48 lines (38 sloc)
1.07 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.image.BufferedImage; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.imageio.ImageIO; | |
public enum TowerTypes { | |
//NAME (Cost to buy, Cost to sell, "sprite dir") | |
NEXUS (1, 1, "Nexus Tower.png"), | |
BASIC (50, 25, "Basic Tower.png"), | |
AOE (100, 50, "AOE Tower.png"); | |
private int _buycost, _sellcost; | |
private BufferedImage sprite; | |
private static final String SPRITE_FILE_DIR = "src/resources/images/"; | |
TowerTypes(int buycost, int sellcost, String spriteFileName) { | |
this._buycost = buycost; | |
this._sellcost = sellcost; | |
try { | |
this.sprite = ImageIO.read(new File(SPRITE_FILE_DIR.concat(spriteFileName))); | |
} catch (IOException ex) { | |
System.out.println("image not found"); | |
} | |
} | |
public int getBuycost() { | |
return _buycost; | |
} | |
public int getSellcost() { | |
return _sellcost; | |
} | |
public String getName() { | |
return this.toString(); | |
} | |
public TowerTypes getTowerType(){ | |
return this; | |
} | |
public BufferedImage getSprite() | |
{ | |
return sprite; | |
} | |
} |