Coverage Summary for Class: PowerupScreen (com.mygdx.game.UI)
| Class | Method, % | Line, % |
|---|---|---|
| PowerupScreen | 0% (0/6) | 0% (0/67) |
| PowerupScreen$1 | 0% (0/2) | 0% (0/5) |
| PowerupScreen$2 | 0% (0/2) | 0% (0/5) |
| PowerupScreen$3 | 0% (0/2) | 0% (0/5) |
| PowerupScreen$4 | 0% (0/2) | 0% (0/5) |
| PowerupScreen$5 | 0% (0/2) | 0% (0/5) |
| PowerupScreen$6 | 0% (0/2) | 0% (0/2) |
| Total | 0% (0/18) | 0% (0/94) |
1 package com.mygdx.game.UI; 2 3 import com.badlogic.gdx.Gdx; 4 import com.badlogic.gdx.Input; 5 import com.badlogic.gdx.scenes.scene2d.Actor; 6 import com.badlogic.gdx.scenes.scene2d.ui.Image; 7 import com.badlogic.gdx.scenes.scene2d.ui.Label; 8 import com.badlogic.gdx.scenes.scene2d.ui.Table; 9 import com.badlogic.gdx.scenes.scene2d.ui.TextButton; 10 import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; 11 import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; 12 import com.mygdx.game.Components.Pirate; 13 import com.mygdx.game.Managers.ResourceManager; 14 import com.mygdx.game.PirateGame; 15 16 import static com.mygdx.utils.Constants.VIEWPORT_HEIGHT; 17 18 /**NEW 19 * Contains widgets defining the shop screen. 20 */ 21 public class PowerupScreen extends Page { 22 public static boolean isImortal; 23 public static boolean isIncreasedDamage; 24 public static boolean isMultiDamage; 25 public static boolean isUnlimitedAmmo; 26 public static boolean isFreezeEnemy; 27 28 29 public PowerupScreen(PirateGame parent) { 30 super(parent); 31 } 32 33 /** 34 * Called every frame calls all other functions that need to be called every frame by rasing events and update methods 35 * 36 * @param delta delta time 37 */ 38 @Override 39 public void render(float delta) { 40 // show game screen if ESC key is pressed 41 if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) { 42 parent.setScreen(parent.shop); 43 } 44 super.render(delta); 45 } 46 47 /** 48 * Create menu widgets such as start button, labels, etc. 49 */ 50 @Override 51 protected void CreateActors() { 52 Table t = new Table(); 53 t.setFillParent(true); 54 55 float space = VIEWPORT_HEIGHT* 0.05f; // gap between rows in table 56 57 t.setBackground(new TextureRegionDrawable(ResourceManager.getTexture("shopBG.jpg"))); 58 Label l = new Label("Shop", parent.skin); 59 l.setFontScale(2); 60 t.add(l).top().spaceBottom(space * 0.5f); 61 62 t.row(); 63 t.add(new Label("Temporary Immortality", parent.skin)).spaceBottom(10); 64 t.row(); 65 TextButton buyPowerup1 = new TextButton("Buy Powerup", parent.skin); 66 buyPowerup1.addListener(new ChangeListener() { 67 @Override 68 public void changed(ChangeEvent event, Actor actor) { 69 if(Pirate.plunder >= 20 && isImortal == false){ 70 isImortal = true; 71 Pirate.plunder -= 20; 72 parent.setScreen(parent.game); 73 } 74 } 75 }); 76 t.add(buyPowerup1).top().size(100, 25).spaceBottom(10); 77 t.row(); 78 t.add(new Image(parent.skin, "coin")).top().left(); 79 t.add(new Label("20", parent.skin)).right().spaceBottom(space); 80 81 82 t.row(); 83 t.add(new Label("Bigger Damage", parent.skin)).spaceBottom(10); 84 t.row(); 85 TextButton buyPowerup2 = new TextButton("Buy Powerup", parent.skin); 86 buyPowerup2.addListener(new ChangeListener() { 87 @Override 88 public void changed(ChangeEvent event, Actor actor) { 89 if(Pirate.plunder >= 10 && isIncreasedDamage == false){ 90 isIncreasedDamage = true; 91 Pirate.plunder -= 10; 92 parent.setScreen(parent.game); 93 } 94 } 95 }); 96 t.add(buyPowerup2).size(100, 25).top().spaceBottom(10); 97 t.row(); 98 t.add(new Image(parent.skin, "coin")).top().left(); 99 t.add(new Label("10", parent.skin)).right().spaceBottom(space); 100 101 102 t.row(); 103 t.add(new Label("Shoot All 8 Directions", parent.skin)).spaceBottom(10); 104 t.row(); 105 TextButton buyPowerup3 = new TextButton("Buy Powerup", parent.skin); 106 buyPowerup3.addListener(new ChangeListener() { 107 @Override 108 public void changed(ChangeEvent event, Actor actor) { 109 if(Pirate.plunder >= 20 && isMultiDamage == false){ 110 isMultiDamage = true; 111 Pirate.plunder -= 20; 112 parent.setScreen(parent.game); 113 } 114 } 115 }); 116 t.add(buyPowerup3).size(100, 25).top().spaceBottom(10); 117 t.row(); 118 t.add(new Image(parent.skin, "coin")).top().left().spaceBottom(space); 119 t.add(new Label("20", parent.skin)).right().spaceBottom(space); 120 121 122 t.row(); 123 t.add(new Label("Unlimited Ammo", parent.skin)).spaceBottom(10); 124 t.row(); 125 TextButton buyPowerup4 = new TextButton("Buy Powerup", parent.skin); 126 buyPowerup4.addListener(new ChangeListener() { 127 @Override 128 public void changed(ChangeEvent event, Actor actor) { 129 if(Pirate.plunder >= 30 && isUnlimitedAmmo == false){ 130 isUnlimitedAmmo = true; 131 Pirate.plunder -= 30; 132 parent.setScreen(parent.game); 133 } 134 } 135 }); 136 t.add(buyPowerup4).size(100, 25).top().spaceBottom(10); 137 t.row(); 138 t.add(new Image(parent.skin, "coin")).top().left().spaceBottom(space); 139 t.add(new Label("30", parent.skin)).right().spaceBottom(space); 140 141 142 t.row(); 143 t.add(new Label("Freeze Enemies", parent.skin)).spaceBottom(10); 144 t.row(); 145 TextButton buyPowerup5 = new TextButton("Buy Powerup", parent.skin); 146 buyPowerup5.addListener(new ChangeListener() { 147 @Override 148 public void changed(ChangeEvent event, Actor actor) { 149 if(Pirate.plunder >= 10 && isFreezeEnemy == false){ 150 isFreezeEnemy = true; 151 Pirate.plunder -= 10; 152 parent.setScreen(parent.game); 153 } 154 } 155 }); 156 t.add(buyPowerup5).size(100, 25).top().spaceBottom(10); 157 t.row(); 158 t.add(new Image(parent.skin, "coin")).top().left().spaceBottom(space); 159 t.add(new Label("10", parent.skin)).right().spaceBottom(space); 160 161 t.row(); 162 TextButton back = new TextButton("Return", parent.skin); 163 back.addListener(new ChangeListener() { 164 @Override 165 public void changed(ChangeEvent event, Actor actor) { 166 parent.setScreen(parent.shop); 167 } 168 }); 169 t.add(back).top().size(100, 25).spaceBottom(space); 170 171 t.top(); 172 173 actors.add(t); 174 175 176 } 177 178 @Override 179 public void show() { 180 super.show(); 181 } 182 183 @Override 184 public void hide() { 185 super.hide(); 186 } 187 188 /** 189 * Used to resize the background texture to the correct size to fill the window 190 * @param width new dim x width of the screen 191 * @param height new dom y height of the screen 192 */ 193 @Override 194 public void resize(int width, int height) { 195 super.resize(width, height); 196 Table t = (Table) actors.get(0); 197 t.setBackground(new TextureRegionDrawable(ResourceManager.getTexture("shopBG.jpg"))); // prevent the bg being stretched 198 } 199 }