-
Notifications
You must be signed in to change notification settings - Fork 0
/
HasShotState.java
33 lines (30 loc) · 894 Bytes
/
HasShotState.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
import greenfoot.*;
/**
* Write a description of class HasShots here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class HasShotState implements ShaktimaanState
{
Shaktimaan heroObj;
World world;
SimpleTimer shotTimer;
public HasShotState(Shaktimaan heroObj,SimpleTimer shotTimer)
{
this.heroObj = heroObj;
this.shotTimer = shotTimer;
}
public void attackEnemy(){
// disparoSound.setVolume(80);
// disparoSound.play();
World world = heroObj.getWorld();
world.addObject(new ShotPlayer(), heroObj.getX()+heroObj.getImage().getWidth()/2, heroObj.getY());
int shot = heroObj.getNumShots()-1;
heroObj.setNumShots(shot);
if(heroObj.getNumShots() == 0){
heroObj.setCurrState(heroObj.getOutOfShotState());
}
shotTimer.mark();
}
}