/
Sniper.java
91 lines (83 loc) · 2.4 KB
/
Sniper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Sniper
*
* @author James Ly, Jesmin Hondell, Daniel Chung
* @version Beta 2.1
*/
public class Sniper extends RangedInfantry
{
//CONSTANTS
public static final int FOOD_COST = 80, WOOD_COST = 80, GOLD_COST = 80, SPAWN_TIME = 80;
private static final GreenfootImage FRONT = new GreenfootImage("SniperFront.png");
private static final GreenfootImage RIGHT = new GreenfootImage("SniperRight.png");
private static final GreenfootImage LEFT = new GreenfootImage("SniperLeft.png");
private static final GreenfootImage BACK = new GreenfootImage("SniperBack.png");
/**
* Constructor for Sniper, sets its cell and map
*
* @param cell The Cell that the unit will spawn in
* @param map The Map that this will be put into
*/
public Sniper(Player owner, Cell cell, Map map) {
super(owner, cell, map);
//Description
unit = "Sniper";
//Combat Statistics
speed = 4;
range = 8;
attackSpeed = 2;
health = 200.00;
currentHealth = health;
attack = 25.0;
//Resistance multipliers
meleeArmour = 0.3;
rangedArmour = 0.3;
siegeArmour = 0.0;
//Attack multipliers
meleeInfantry = 2.0;
rangedInfantry = 2.0;
meleeCavalry = 1.0;
rangedCavalry = 1.0;
siege = 1.5;
building = 3.0;
}
/**
* Setss Sniper's image
*/
public void act() {
setImage("sniper.png");
}
/**
* Returns the image when object is facing left
*
* @return The image when object is facing left
*/
public GreenfootImage getLeftImage() {
return LEFT;
}
/**
* Returns the image when object is facing right
*
* @return The image when object is facing right
*/
public GreenfootImage getRightImage() {
return RIGHT;
}
/**
* Returns the image when object is facing the front
*
* @return The image when object is facing the front
*/
public GreenfootImage getFrontImage() {
return FRONT;
}
/**
* Returns the image when object is facing back (away)
*
* @return The image when object is facing back (away)
*/
public GreenfootImage getBackImage() {
return BACK;
}
}