Advertisement
Guest User

Java

a guest
Sep 4th, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. package src;
  2.  
  3. public class MobBandit extends ObjectLiving{
  4.    
  5.         public String banditType;
  6.  
  7.     public MobBandit()
  8.     {
  9.         chooseType();
  10.         hp = 8;
  11.         strength = 2;
  12.         setSpeed(2, 3);
  13.         sprite = appendStringToType();
  14.         loot = appendToType();
  15.         goldDrop = 6;
  16.     }
  17.    
  18.     public void chooseType()
  19.     {
  20.         int random = (int) (Math.random() * 2);
  21.         if(random == 0)
  22.         {
  23.             banditType = "archer"; 
  24.         }
  25.         else if(random == 1)
  26.         {
  27.             banditType = "fighter";
  28.         }
  29.     }
  30.    
  31.     public String appendStringToType()
  32.     {
  33.         if(banditType == "archer")
  34.         {
  35.             return "/banditarcher.png";
  36.         }
  37.         else if(banditType == "fighter")
  38.         {
  39.             return "/bandit.png";
  40.         }
  41.         else return "/banit.png";
  42.     }
  43.    
  44.     public Item appendToType()
  45.     {
  46.         if(banditType == "archer")
  47.         {
  48.             return Item.bone;
  49.         }
  50.        
  51.         else if(banditType == "fighter")
  52.         {
  53.             return Item.swordSteel;
  54.         }
  55.        
  56.         else return null;
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement