Skip to content

Commit

Permalink
Balance Changes
Browse files Browse the repository at this point in the history
SHOWCASE BUILD
  • Loading branch information
bornskilled200 committed Feb 14, 2014
1 parent f4ef9c0 commit 5cef50c
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 64 deletions.
16 changes: 5 additions & 11 deletions src/zombiecraft/human/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,32 @@
/**
* Created by David Park on 1/7/14.
*/
public class Base extends MainBuilding
{
public class Base extends MainBuilding {
public static final String NAME = "Base";
private List<UnitData> allUnits;


public Base()
{
public Base() {
super(NAME, 22);
setHealth(250);

allUnits = new ArrayList<UnitData>();
allUnits.add(new Human());
allUnits.add(new Scout());
allUnits.add(new Mercenary());
}

@Override
public GenericMovableUnit createUnit(UnitData unitData)
{
public GenericMovableUnit createUnit(UnitData unitData) {
return null; //To change body of implemented methods use File | Settings | File Templates.
}

@Override
public List<UnitData> buildableUnits()
{
public List<UnitData> buildableUnits() {
return allUnits;
}

@Override
public int getVisionRadius()
{
public int getVisionRadius() {
return 128; //To change body of implemented methods use File | Settings | File Templates.
}
}
4 changes: 2 additions & 2 deletions src/zombiecraft/human/Human.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public class Human extends SawtoothUnitData

public Human()
{
super(50, NAME, DESCRIPTION, 32, 200, 80, 20, 70);
super(50, NAME, DESCRIPTION, 20, 200, 80, 20, 70);
}

@Override
public int getHurtRadius()
{
return 48; //To change body of implemented methods use File | Settings | File Templates.
return 36; //To change body of implemented methods use File | Settings | File Templates.
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/zombiecraft/human/Scout.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Scout extends UnitData

public Scout()
{
super(25, NAME, "Straight path unit that brings back other units.", false, 32, 20);
super(25, NAME, "Straight path unit that brings back other units.", false, 20, 20);
}

@Override
Expand Down
76 changes: 33 additions & 43 deletions src/zombiecraft/player/ComputerPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@
/**
* Created by David Park on 1/7/14.
*/
public class ComputerPlayer extends Player
{
public class ComputerPlayer extends Player {
Queue<GenericMovableUnit> rememberedUnits;
float degreeOfFreedom = 360;
float currentDirection;

public ComputerPlayer(Race race)
{
public ComputerPlayer(Race race) {
super(race);
switch (race)
{
switch (race) {
case ZOMBIE:
break;
default:
Expand All @@ -35,25 +32,20 @@ public ComputerPlayer(Race race)
rememberedUnits = new ArrayDeque<GenericMovableUnit>();
}

public void poll(GameModel gameModel, ViewModel viewModel)
{
public void poll(GameModel gameModel, ViewModel viewModel) {
if (race != Race.ZOMBIE)
return;
boolean targetFound = false;
List<Unit> units = gameModel.getUnits();
for (Unit unit : units)
{
if (unit instanceof GenericMovableUnit && gameModel.getPlayerMap().get(unit) == this)
{
for (Unit unit : units) {
if (unit instanceof GenericMovableUnit && gameModel.getPlayerMap().get(unit) == this) {
GenericMovableUnit genericMovableUnit = (GenericMovableUnit) unit;
for (Unit other : units)
{
for (Unit other : units) {
if (unit == other || gameModel.getPlayerMap().get(unit) == gameModel.getPlayerMap().get(other))
continue;
int i = genericMovableUnit.getUnitData()
.doDamage(gameModel.getCurrentUpdate(), genericMovableUnit, other);
if (i > 0)
{
.doDamage(gameModel.getCurrentUpdate(), genericMovableUnit, other);
if (i > 0) {
if (rememberedUnits.contains(genericMovableUnit))
degreeOfFreedom *= .90;
else
Expand All @@ -69,44 +61,42 @@ public void poll(GameModel gameModel, ViewModel viewModel)


MainBuilding mainBuilding = gameModel.getMainBuildingMap().get(this);

if (getProductionDelay() <= 0)
{
for (Unit unit : units) {
if (gameModel.getPlayerMap().get(unit) != this) {
if (UnitData.isVisible(mainBuilding, unit)) {
float angle =
(float) Math.atan2(unit.getY() - mainBuilding.getY(), unit.getX() - mainBuilding.getX()) *
MathUtils.radiansToDegrees;
if (angle < 0)
angle += 360;
for (Unit unit1 : units) {
if (gameModel.getPlayerMap().get(unit1) == this && unit1 instanceof GenericMovableUnit) {
GenericMovableUnit genericMovableUnit = (GenericMovableUnit) unit1;
genericMovableUnit.setDirection(angle);
}
}
setProductionDelay(200);
setProductionDelayLength(200);
break;
}
}
}


if (getProductionDelay() <= 0) {
UnitData unitData = mainBuilding.buildableUnits().get(0);
setProductionDelayLength(unitData.getProductionDelay());
setProductionDelay(unitData.getProductionDelay());

GenericMovableUnit genericMovableUnit = new GenericMovableUnit(unitData);
genericMovableUnit.setDirection((float) (currentDirection + (degreeOfFreedom * Math.random())) % 360);
System.out.println(currentDirection + " + " + degreeOfFreedom);
genericMovableUnit.setPosition(mainBuilding.getX(), mainBuilding.getY());
rememberedUnits.offer(genericMovableUnit);
if (rememberedUnits.size() > 6)
rememberedUnits.poll();
gameModel.addUnit(this, genericMovableUnit);
}

for (Unit unit : units)
{
if (gameModel.getPlayerMap().get(unit) != this)
{
if (UnitData.isVisible(mainBuilding, unit))
{
for (Unit unit1 : units)
{
if (gameModel.getPlayerMap().get(unit1) == this && unit1 instanceof GenericMovableUnit && UnitData.isVisible(mainBuilding,unit1)==false)
{
GenericMovableUnit genericMovableUnit = (GenericMovableUnit) unit1;
float angle =
(float) Math.atan2(unit.getY() - unit1.getY(), unit.getX() - unit1.getX()) *
MathUtils.radiansToDegrees;
if (angle < 0)
angle += 360;
genericMovableUnit.setDirection(angle);
}
}
break;
}
}
}
}
}
30 changes: 26 additions & 4 deletions src/zombiecraft/player/HumanPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.badlogic.gdx.Input;
import com.badlogic.gdx.math.MathUtils;
import zombiecraft.*;
import zombiecraft.human.Scout;
import zombiecraft.unit.GenericMovableUnit;
import zombiecraft.unit.MainBuilding;

Expand All @@ -17,12 +18,18 @@
public class HumanPlayer extends Player {


private boolean abilityUsed;
private UnitData unitData;

public HumanPlayer(Race race) {
super(race);
unitData = new Scout();
}


public void poll(GameModel gameModel, ViewModel viewModel) {
if (getProductionDelay() <= 0)
abilityUsed = false;
if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) {
gameModel.getMainBuildingMap().get(this).setHealth(0);
return;
Expand Down Expand Up @@ -60,10 +67,11 @@ public void poll(GameModel gameModel, ViewModel viewModel) {
}


if (race == Race.ZOMBIE) {
if (Gdx.input.isKeyPressed(Input.Keys.Q) && getProductionDelay() <= 0) {
setProductionDelay(300);
setProductionDelayLength(300);
if (Gdx.input.isKeyPressed(Input.Keys.Q) && abilityUsed == false) {
if (race == Race.ZOMBIE) {
setProductionDelay(getProductionDelay() + 200);
setProductionDelayLength(getProductionDelayLength() + 200);
abilityUsed = true;
List<Unit> units = gameModel.getUnits();
viewModel.setUnprojectPosition(Gdx.input.getX(), Gdx.input.getY());
float x = mainBuilding.getX() + 32;
Expand All @@ -79,6 +87,20 @@ public void poll(GameModel gameModel, ViewModel viewModel) {
genericMovableUnit.setDirection(angle);
}
}
} else if (race == Race.HUMAN) {
viewModel.setUnprojectPosition(Gdx.input.getX(), Gdx.input.getY());
GenericMovableUnit genericMovableUnit = new GenericMovableUnit(unitData);
abilityUsed = true;
float x = mainBuilding.getX() + 32;
float y = mainBuilding.getY() + 32;
float angle = (float) Math.atan2(viewModel.getUnprojectY() - y, viewModel.getUnprojectX() - x) * MathUtils.radiansToDegrees;
if (angle < 0)
angle += 360;
genericMovableUnit.setDirection(angle);
genericMovableUnit.setPosition(x - 32, y - 32);
setProductionDelay(getProductionDelay() + 20);
setProductionDelayLength(getProductionDelayLength() + 20);
gameModel.addUnit(this, genericMovableUnit);
}
}
}
Expand Down
20 changes: 18 additions & 2 deletions src/zombiecraft/screen/GameMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
Expand Down Expand Up @@ -39,9 +40,10 @@ public class GameMap implements Screen, GameModel, ViewModel
public final Vector3 vector;
private final SpriteBatch spriteBatch;
private final BitmapFont bitmapFont;
private final boolean debug;
private boolean debug;
private final int width;
private final float height;
private final InputAdapter inputAdapter;
public float accumulator;
FPSLogger fpsLogger = new FPSLogger();
private OrthographicCamera camera;
Expand Down Expand Up @@ -95,6 +97,19 @@ public GameMap(ZombieCraft zombieCraft, List<Player> players, boolean randomPlac
textures.put("Crasher", new Texture(Gdx.files.internal("assets/zombie/hulk.png")));
Gdx.gl.glClearColor(1, 1, 1, 0);
vector = new Vector3();
inputAdapter = new InputAdapter() {
@Override
public boolean keyTyped(char character) {
switch (character) {
case ' ':
GameMap.this.debug = !GameMap.this.debug;
break;
default:
return false;
}
return true;
}
};
}

@Override
Expand Down Expand Up @@ -327,12 +342,13 @@ public void show()

System.out.println(maxSize);
texture = new Texture(2048, 2048, Pixmap.Format.RGBA8888);
Gdx.input.setInputProcessor(inputAdapter);
}

@Override
public void hide()
{

Gdx.input.setInputProcessor(null);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/zombiecraft/zombie/Zombie.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Zombie extends UnitData

public Zombie()
{
super(75, NAME, "The remains of a deceased living being made autonomous", false, 20, 25);
super(75, NAME, "The remains of a deceased living being made autonomous", false, 20, 20);
}

@Override
Expand Down

0 comments on commit 5cef50c

Please sign in to comment.