Thread: group teleporting?

Results 1 to 2 of 2
  1. #1 group teleporting? 
    Donator
    xSelseor's Avatar
    Join Date
    Mar 2009
    Age
    28
    Posts
    456
    Thanks given
    33
    Thanks received
    4
    Rep Power
    28
    I am making barbarian assult, and i need to know something. After the queen is dead, how do you make it teleport a group instead of just one person?

    This is 317 not 508.
    Reply With Quote  
     

  2. #2  
    Registered Member
    PSNB's Avatar
    Join Date
    Aug 2009
    Posts
    885
    Thanks given
    8
    Thanks received
    103
    Rep Power
    590
    Personally, I would create a new class that will act as a group of players. This will allow you to control the entire group rather than each Player individually. This is a quick example of what I mean.

    Code:
    import java.util.ArrayList;
    
    public class AssaultTeam {
    	
    	/**
    	 * Contains the Players that are on the team. (Limited to four)
    	 */
    	private ArrayList<Player> members = new ArrayList<Player>();
    	
    	/**
    	 * Adds a Member to the team.
    	 * @param p The member to add to the team.
    	 */
    	public void addMember(Player p) {
    		
    		//The team is full, so don't add.
    		if(members.size() >= 4)
    			return;
    		
    		//Add the Player to the team.
    		members.add(p);
    	}
    	
    	/**
    	 * removes a Member from the team.
    	 * @param p The member to remove from the team.
    	 */
    	public void removeMember(Player p) {
    		
    		//Player is not on the team, so don't remove.
    		if(!members.contains(p))
    			return;
    		
    		//Remove the player.
    		members.remove(p);
    	}
    	
    	/**
    	 * Launches the team into the game.
    	 */
    	public void launchTeam() {
    		
    		//Loops through the players and prepares them for the game to start.
    		for(Player p : members) {
    			/*
    			 * All code for launching the team should go here. For example
    			 * p.teleportToX = 3333;
    			 * p.teleportToY = 3333;
    			 * p.replenishHealth();
    			 * p.replenishPrayer();
    			 */
    		}
    	}
    }
    When starting a game, you could do something like this.

    Code:
    public static void newGame(Player[] members) {
    		AssaultTeam team = new AssaultTeam();
    		team.addMember(members[0]);
    		team.addMember(members[1]);
    		team.addMember(members[2]);
    		team.addMember(members[3]);
    		team.launch();
    	}
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •