示例#1
0
文件: Team.java 项目: barryp/q2java
	public void addPlayer( Player p )
	{
		if (fPlayers.contains(p))
			return; // already joined this team
			
		fPlayers.addElement( p );

		// make sure we find out if the team member disconnects
		p.addPlayerStateListener(this);

		// act as a damage filter for this member
		p.addDamageListener(this);

		// assign new skin
		assignSkinTo( p );
		Object[] args = {p.getName(), fTeamIndex};
		Game.localecast("q2java.ctf.CTFMessages", "join_team", args, Engine.PRINT_HIGH);	
		
		//update players stats that he joined this team (the yellow line around team-icon)
		int index1 = ( this == Team.TEAM1 ? STAT_CTF_JOINED_TEAM1_PIC : STAT_CTF_JOINED_TEAM2_PIC );
		int index2 = ( this == Team.TEAM1 ? STAT_CTF_JOINED_TEAM2_PIC : STAT_CTF_JOINED_TEAM1_PIC );
		int picnum = Engine.getImageIndex("i_ctfj");
		p.fEntity.setPlayerStat( index1, (short)picnum );
		p.fEntity.setPlayerStat( index2, (short)0      );
	}
示例#2
0
  public static final void fireEvent(GenericEvent e, Method m, Vector listeners)
      throws PropertyVetoException {
    Object[] snapshot = null;

    synchronized (listeners) {
      snapshot = new Object[listeners.size()];
      listeners.copyInto(snapshot);
    }

    // leighd 04/14/99 - modified for event debugging
    if (gDebugEvents) Engine.debugLog("Event : " + e.toString());

    Object params[] = new Object[] {e};

    for (int i = 0; i < snapshot.length; i++) {
      if ((e instanceof Consumable) && ((Consumable) e).isConsumed()) {
        // leighd 04/14/99
        // note that we don't catch the consumption of the
        // event until we've passed through the loop again,
        // so we reference i-1
        if (gDebugEvents) Engine.debugLog("Consumed By : " + snapshot[i - 1]);
        return;
      }
      try {
        m.invoke(snapshot[i], params);
      } catch (IllegalAccessException iae) {
        iae.printStackTrace();
      } catch (InvocationTargetException ite) {
        Throwable t = ite.getTargetException();
        if (t instanceof PropertyVetoException) throw ((PropertyVetoException) t);
        else t.printStackTrace();
      }
    }
  }
示例#3
0
文件: Team.java 项目: barryp/q2java
	public boolean removePlayer( Player p )
	{
		if (!fPlayers.contains(p))
			return false;
			
		//update players stats that he leaved this team (the yellow line around team-icon)
		p.fEntity.setPlayerStat( STAT_CTF_JOINED_TEAM1_PIC, (short)0 );
		p.fEntity.setPlayerStat( STAT_CTF_JOINED_TEAM2_PIC, (short)0 );
		
		p.removePlayerStateListener(this);
		p.removeDamageListener(this);
		return fPlayers.removeElement( p );
	}
示例#4
0
文件: Team.java 项目: barryp/q2java
	/**
	 * Check if a player belongs to this team.
	 * @return boolean
	 * @param p The player we're checking on.
	 */
	public boolean isTeamMember(Object obj) 
	{
		return fPlayers.contains(obj);
	}
示例#5
0
文件: Team.java 项目: barryp/q2java
	public CTFPlayer[] getPlayers()
	{
		CTFPlayer[] players = new CTFPlayer[ fPlayers.size() ];
		fPlayers.copyInto( players );
		return players;
	}
示例#6
0
文件: Team.java 项目: barryp/q2java
	public int getNumPlayers()
	{
		return fPlayers.size();
	}