Advertisement
Guest User

BuildingBase

a guest
Jul 15th, 2019
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.86 KB | None | 0 0
  1. package net.tf2.building;
  2.  
  3. import net.tf2.classes.*;
  4. import net.tf2.misc.Misc;
  5. import net.tf2.team.TeamList;
  6. import net.tf2.weapons.WeaponBase;
  7.  
  8. public class BuildingBase {
  9.  
  10.     private String name;
  11.    
  12.     private int maxHealth;
  13.     private int health;
  14.     private int cost;
  15.     private int level;
  16.    
  17.     private Engineer owner;
  18.    
  19.     private boolean alive = false;
  20.    
  21.     private TeamList team;
  22.    
  23.     private int xPos, yPos, zPos;
  24.    
  25.     private int rotateX, rotateY;
  26.    
  27.     boolean exists;
  28.  
  29.     public BuildingBase(String name, int maxHealth, int cost, Engineer owner, int xPos, int yPos, int zPos, int rotateX, int rotateY, boolean exists)
  30.     {
  31.         if(exists == false)
  32.         {
  33.             this.name = name;
  34.             this.maxHealth = maxHealth;
  35.             health = maxHealth;
  36.             this.cost = cost;
  37.             level = 1;
  38.             alive = true;
  39.             team = owner.getTeam();
  40.             this.owner = owner;
  41.             this.xPos = xPos;
  42.             this.yPos = yPos;
  43.             this.zPos = zPos;
  44.             this.rotateX = rotateX;
  45.             this.rotateY = rotateY;
  46.             this.exists = exists;
  47.  
  48.             Misc.print(owner.getUserName() + " created a " + name);
  49.         }
  50.         else
  51.         {
  52.             Misc.print("You already have a " + name);
  53.         }
  54.     }
  55.  
  56.     public void upgrade(Engineer upgrader)
  57.     {
  58.         if(exists == true)
  59.         {
  60.             if(upgrader.getTeam().equals(team))
  61.             {
  62.                 if(level < 3)
  63.                 {
  64.                     if(upgrader.getMetal() >= 50)
  65.                     {
  66.                         upgrader.setMetal(upgrader.getMetal() - 50);
  67.                         level++;
  68.                         maxHealth += 80;
  69.                         health = maxHealth;
  70.                         Misc.print(upgrader.getUserName() + " upgraded " + owner.getUserName() + "'s " + name + " to level " + level);
  71.                     }
  72.                     else
  73.                     {
  74.                         Misc.print("You do not have enough metal to upgrade the building");
  75.                     }
  76.                 }
  77.                 else
  78.                 {
  79.                     Misc.print("This " + name + " is already level 3");
  80.                 }
  81.             }
  82.             else
  83.             {
  84.                 Misc.print("You can't upgrade an enemys building");
  85.             }
  86.         }
  87.         else
  88.         {
  89.             Misc.print("You can't repair a non existent building");
  90.         }
  91.     }
  92.    
  93.     public void damage(WeaponBase weapon)
  94.     {
  95.         if(exists == true)
  96.         {
  97.             if(!weapon.getOwner().getTeam().equals(team))
  98.             {
  99.                 health -= weapon.getDamage();
  100.  
  101.                 Misc.print(weapon.getOwner().getUserName() + " attacked " + owner.getUserName() + "'s " + name + "  with a " + weapon.getName() + " for " + weapon.getDamage() + " health");
  102.  
  103.                 System.out.println(owner.getUserName() + "'s " + name + "'s health is now " + health);
  104.  
  105.                 if(health <= 0)
  106.                 {
  107.                     die(weapon);
  108.                 }
  109.  
  110.             }
  111.             else
  112.             {
  113.                 Misc.print("You can't attack team buildings");
  114.             }
  115.             }
  116.         else
  117.         {
  118.             Misc.print("You can't attack non existent buildings");
  119.         }
  120.     }
  121.    
  122.     public void die(WeaponBase weapon)
  123.     {
  124.         if(exists == true)
  125.         {
  126.             if (!team.equals(weapon.getOwner().getTeam()))
  127.             {
  128.                 if (health <= 0)
  129.                 {
  130.                     exists = false;
  131.                     Misc.print(weapon.getOwner().getUserName() + " destroyed " + owner.getUserName() + "'s " + name + " with a " + weapon.getName());
  132.                 }
  133.             }
  134.             else
  135.             {
  136.                 Misc.print("You can't destroy team mates buildings");
  137.             }
  138.         }
  139.         else
  140.         {
  141.             Misc.print("You can't kill non existent buildings");
  142.         }
  143.     }
  144.  
  145.     public int getMaxHealth() {
  146.         return maxHealth;
  147.     }
  148.  
  149.     public void setMaxHealth(int maxHealth) {
  150.         this.maxHealth = maxHealth;
  151.     }
  152.  
  153.     public int getRotateX() {
  154.         return rotateX;
  155.     }
  156.  
  157.     public void setRotateX(int rotateX) {
  158.         this.rotateX = rotateX;
  159.     }
  160.  
  161.     public int getRotateY() {
  162.         return rotateY;
  163.     }
  164.  
  165.     public void setRotateY(int rotateY) {
  166.         this.rotateY = rotateY;
  167.     }
  168.    
  169.     public int getxPos() {
  170.         return xPos;
  171.     }
  172.  
  173.     public void setxPos(int xPos) {
  174.         this.xPos = xPos;
  175.     }
  176.  
  177.     public int getyPos() {
  178.         return yPos;
  179.     }
  180.  
  181.     public void setyPos(int yPos) {
  182.         this.yPos = yPos;
  183.     }
  184.  
  185.     public int getzPos() {
  186.         return zPos;
  187.     }
  188.  
  189.     public void setzPos(int zPos) {
  190.         this.zPos = zPos;
  191.     }
  192.    
  193.     public boolean isAlive() {
  194.         return alive;
  195.     }
  196.  
  197.     public void setAlive(boolean alive) {
  198.         this.alive = alive;
  199.     }
  200.  
  201.     public String getName() {
  202.         return name;
  203.     }
  204.  
  205.     public void setName(String name) {
  206.         this.name = name;
  207.     }
  208.  
  209.     public int getHealth() {
  210.         return health;
  211.     }
  212.  
  213.     public void setHealth(int health) {
  214.         this.health = health;
  215.     }
  216.  
  217.     public int getCost() {
  218.         return cost;
  219.     }
  220.  
  221.     public void setCost(int cost) {
  222.         this.cost = cost;
  223.     }
  224.  
  225.     public int getLevel() {
  226.         return level;
  227.     }
  228.  
  229.     public void setLevel(int level) {
  230.         this.level = level;
  231.     }
  232.  
  233.     public TeamList getTeam() {
  234.         return team;
  235.     }
  236.  
  237.     public void setTeam(TeamList team) {
  238.         this.team = team;
  239.     }
  240.    
  241.     public Engineer getOwner() {
  242.         return owner;
  243.     }
  244.  
  245.     public void setOwner(Engineer owner) {
  246.         this.owner = owner;
  247.     }
  248.    
  249. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement