Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.tf2.building;
- import net.tf2.classes.*;
- import net.tf2.misc.Misc;
- import net.tf2.team.TeamList;
- import net.tf2.weapons.WeaponBase;
- public class BuildingBase {
- private String name;
- private int maxHealth;
- private int health;
- private int cost;
- private int level;
- private Engineer owner;
- private boolean alive = false;
- private TeamList team;
- private int xPos, yPos, zPos;
- private int rotateX, rotateY;
- boolean exists;
- public BuildingBase(String name, int maxHealth, int cost, Engineer owner, int xPos, int yPos, int zPos, int rotateX, int rotateY, boolean exists)
- {
- if(exists == false)
- {
- this.name = name;
- this.maxHealth = maxHealth;
- health = maxHealth;
- this.cost = cost;
- level = 1;
- alive = true;
- team = owner.getTeam();
- this.owner = owner;
- this.xPos = xPos;
- this.yPos = yPos;
- this.zPos = zPos;
- this.rotateX = rotateX;
- this.rotateY = rotateY;
- this.exists = exists;
- Misc.print(owner.getUserName() + " created a " + name);
- }
- else
- {
- Misc.print("You already have a " + name);
- }
- }
- public void upgrade(Engineer upgrader)
- {
- if(exists == true)
- {
- if(upgrader.getTeam().equals(team))
- {
- if(level < 3)
- {
- if(upgrader.getMetal() >= 50)
- {
- upgrader.setMetal(upgrader.getMetal() - 50);
- level++;
- maxHealth += 80;
- health = maxHealth;
- Misc.print(upgrader.getUserName() + " upgraded " + owner.getUserName() + "'s " + name + " to level " + level);
- }
- else
- {
- Misc.print("You do not have enough metal to upgrade the building");
- }
- }
- else
- {
- Misc.print("This " + name + " is already level 3");
- }
- }
- else
- {
- Misc.print("You can't upgrade an enemys building");
- }
- }
- else
- {
- Misc.print("You can't repair a non existent building");
- }
- }
- public void damage(WeaponBase weapon)
- {
- if(exists == true)
- {
- if(!weapon.getOwner().getTeam().equals(team))
- {
- health -= weapon.getDamage();
- Misc.print(weapon.getOwner().getUserName() + " attacked " + owner.getUserName() + "'s " + name + " with a " + weapon.getName() + " for " + weapon.getDamage() + " health");
- System.out.println(owner.getUserName() + "'s " + name + "'s health is now " + health);
- if(health <= 0)
- {
- die(weapon);
- }
- }
- else
- {
- Misc.print("You can't attack team buildings");
- }
- }
- else
- {
- Misc.print("You can't attack non existent buildings");
- }
- }
- public void die(WeaponBase weapon)
- {
- if(exists == true)
- {
- if (!team.equals(weapon.getOwner().getTeam()))
- {
- if (health <= 0)
- {
- exists = false;
- Misc.print(weapon.getOwner().getUserName() + " destroyed " + owner.getUserName() + "'s " + name + " with a " + weapon.getName());
- }
- }
- else
- {
- Misc.print("You can't destroy team mates buildings");
- }
- }
- else
- {
- Misc.print("You can't kill non existent buildings");
- }
- }
- public int getMaxHealth() {
- return maxHealth;
- }
- public void setMaxHealth(int maxHealth) {
- this.maxHealth = maxHealth;
- }
- public int getRotateX() {
- return rotateX;
- }
- public void setRotateX(int rotateX) {
- this.rotateX = rotateX;
- }
- public int getRotateY() {
- return rotateY;
- }
- public void setRotateY(int rotateY) {
- this.rotateY = rotateY;
- }
- public int getxPos() {
- return xPos;
- }
- public void setxPos(int xPos) {
- this.xPos = xPos;
- }
- public int getyPos() {
- return yPos;
- }
- public void setyPos(int yPos) {
- this.yPos = yPos;
- }
- public int getzPos() {
- return zPos;
- }
- public void setzPos(int zPos) {
- this.zPos = zPos;
- }
- public boolean isAlive() {
- return alive;
- }
- public void setAlive(boolean alive) {
- this.alive = alive;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getHealth() {
- return health;
- }
- public void setHealth(int health) {
- this.health = health;
- }
- public int getCost() {
- return cost;
- }
- public void setCost(int cost) {
- this.cost = cost;
- }
- public int getLevel() {
- return level;
- }
- public void setLevel(int level) {
- this.level = level;
- }
- public TeamList getTeam() {
- return team;
- }
- public void setTeam(TeamList team) {
- this.team = team;
- }
- public Engineer getOwner() {
- return owner;
- }
- public void setOwner(Engineer owner) {
- this.owner = owner;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement