示例#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
 protected void computeRectangle() {
   Vector3d p1 = new Vector3d((Vector3d) get(0));
   Vector3d p2 = new Vector3d((Vector3d) get(1));
   removeAllElements();
   super.add(new Vector3d(p1.x, p1.y, 0));
   super.add(new Vector3d(p1.x, p2.y, 0));
   super.add(new Vector3d(p2.x, p2.y, 0));
   super.add(new Vector3d(p2.x, p1.y, 0));
   super.add(new Vector3d(p1.x, p1.y, 0));
 }
示例#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
 protected void computeCircle() {
   Vector3d center = new Vector3d((Vector3d) get(0));
   Vector3d p2 = new Vector3d((Vector3d) get(1));
   p2.sub(center);
   double radius = p2.length();
   removeAllElements();
   double angle = 0;
   double incAngle = 2 * Math.PI / sides;
   for (int i = 0; i < sides; i++) {
     super.add(
         new Vector3d(
             center.x + radius * Math.cos(angle), center.y + radius * Math.sin(angle), 0));
     angle += incAngle;
   }
   super.add(new Vector3d(center.x + radius, center.y, 0));
 }
示例#5
0
/**
 * Find a single-player spawnpoint. Kind of simplistic.
 * @return q2jgame.GameEntity, null if nothing available.
 */
public static GenericSpawnpoint getSpawnpointSingle() 
	{
	String target = BaseQ2.getSpawnpoint();

	if (target == null)
		{
		// look for an info_player_start spawnpoint that's not a target
		Vector list = Game.getLevelRegistryList(q2java.baseq2.spawn.info_player_start.REGISTRY_KEY);
		Enumeration enum = list.elements();
		while (enum.hasMoreElements())
			{
			GenericSpawnpoint sp = (GenericSpawnpoint) enum.nextElement();		
			if (sp.getTargetGroup() == null)
				return sp;
			}
			
		// all info_player_starts are targets, so settle for the first one (if available)
		if (list.size() > 0)
			return (GenericSpawnpoint) list.elementAt(0);					
		}
	else
示例#6
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);
	}
示例#7
0
文件: Team.java 项目: barryp/q2java
	public CTFPlayer[] getPlayers()
	{
		CTFPlayer[] players = new CTFPlayer[ fPlayers.size() ];
		fPlayers.copyInto( players );
		return players;
	}
示例#8
0
文件: Team.java 项目: barryp/q2java
	public int getNumPlayers()
	{
		return fPlayers.size();
	}
示例#9
0
/**
 * Select a random spawnpoint, but exclude the two points closest
 * to other players.
 * @return q2jgame.GameEntity
 */
public static GenericSpawnpoint getSpawnpointRandom() 
	{
	GenericSpawnpoint spawnPoint = null;
	GenericSpawnpoint spot1 = null;
	GenericSpawnpoint spot2 = null;
	float range1 = Float.MAX_VALUE;
	float range2 = Float.MAX_VALUE;
	int count = 0;
	
	// find the two deathmatch spawnpoints that are closest to any players
	Vector list = Game.getLevelRegistryList(q2java.baseq2.spawn.info_player_deathmatch.REGISTRY_KEY);

	// if no deathmatch spawnpoint, try single-player ones
	if (list.size() < 1)
		list = Game.getLevelRegistryList(q2java.baseq2.spawn.info_player_start.REGISTRY_KEY);
		
	Enumeration enum = list.elements();
	while (enum.hasMoreElements())
		{
		count++;
		spawnPoint = (GenericSpawnpoint) enum.nextElement();
		float range = MiscUtil.nearestPlayerDistance(spawnPoint);

		if (range < range1)
			{
			range1 = range;
			spot1 = spawnPoint;
			}		
		else
			{
			if (range < range2)
				{
				range2 = range;
				spot2 = spawnPoint;
				}
			}			
			
		}

	if (count == 0)
		return null;
		
	if (count <= 2)
		spot1 = spot2 = null;
	else
		count -= 2;			

	int selection = (GameUtil.randomInt() & 0x0fff) % count;
	spawnPoint = null;

	enum = list.elements();
	while (enum.hasMoreElements())
		{
		spawnPoint = (GenericSpawnpoint) enum.nextElement();
		
		// skip the undesirable spots
		if ((spawnPoint == spot1) || (spawnPoint == spot2))
			continue;
			
		if ((selection--) == 0)					
			break;
		}

	return spawnPoint;
	}
示例#10
0
  public boolean isCellWithinRegion(Point3f point, Cell cell, boolean completelyInside) {
    logger.logComment("Checking point: " + point + " in: " + toString());

    float minXLoc, minYLoc, minZLoc;
    float maxXLoc, maxYLoc, maxZLoc;

    Segment firstSeg = cell.getFirstSomaSegment();

    if (completelyInside) logger.logComment("Cell needs to be completely inside");
    else
      logger.logComment(
          "Only cell centre (" + firstSeg.getStartPointPosition() + ") needs to be inside");

    int factor = 0;
    if (completelyInside) factor = 1;

    minXLoc = parameterList[0].value + factor * firstSeg.getSection().getStartRadius();
    minYLoc = parameterList[1].value + factor * firstSeg.getSection().getStartRadius();
    minZLoc = parameterList[2].value + factor * firstSeg.getSection().getStartRadius();
    maxXLoc =
        parameterList[0].value
            + parameterList[3].value
            - factor * firstSeg.getSection().getStartRadius();
    maxYLoc =
        parameterList[1].value
            + parameterList[4].value
            - factor * firstSeg.getSection().getStartRadius();
    maxZLoc =
        parameterList[2].value
            + parameterList[5].value
            - factor * firstSeg.getSection().getStartRadius();

    Point3f actualStartOfSoma =
        new Point3f(
            point.x + firstSeg.getSection().getStartPointPositionX(),
            point.y + firstSeg.getSection().getStartPointPositionY(),
            point.z + firstSeg.getSection().getStartPointPositionZ());

    logger.logComment(
        "actualStartOfSoma: "
            + actualStartOfSoma
            + ", radius: "
            + firstSeg.getSection().getStartRadius());

    if (actualStartOfSoma.x < minXLoc
        || actualStartOfSoma.x > maxXLoc
        || actualStartOfSoma.y < minYLoc
        || actualStartOfSoma.y > maxYLoc
        || actualStartOfSoma.z < minZLoc
        || actualStartOfSoma.z > maxZLoc) return false;

    if (completelyInside) {
      Vector somaSegments = cell.getOnlySomaSegments();

      for (int i = 0; i < somaSegments.size(); i++) {
        Segment nextSeg = (Segment) somaSegments.elementAt(i);

        Point3f actualEndPoint =
            new Point3f(
                point.x + nextSeg.getEndPointPositionX(),
                point.y + nextSeg.getEndPointPositionY(),
                point.z + nextSeg.getEndPointPositionZ());

        logger.logComment("actualEndPoint: " + actualEndPoint + ", radius: " + nextSeg.getRadius());

        if (actualEndPoint.x < parameterList[0].value + nextSeg.getRadius()
            || actualEndPoint.x
                > parameterList[0].value + parameterList[3].value - nextSeg.getRadius()
            || actualEndPoint.y < parameterList[1].value + nextSeg.getRadius()
            || actualEndPoint.y
                > parameterList[1].value + parameterList[4].value - nextSeg.getRadius()
            || actualEndPoint.z < parameterList[2].value + nextSeg.getRadius()
            || actualEndPoint.z
                > parameterList[2].value + parameterList[5].value - nextSeg.getRadius())
          return false;
      }
    }
    return true;
  }
示例#11
0
  private void createSections() {
    float axonRadius = .5f;

    Point3f posnEndPoint = new Point3f(0, -15, 0);

    Segment rootAxon =
        addAxonalSegment(axonRadius, "root", posnEndPoint, somaSection, 1, "axonRootSec");

    Vector<Segment> layer = new Vector<Segment>();

    layer.add(addRelativeAxon(rootAxon, new Point3f(-30, -20, -30), axonRadius));
    layer.add(addRelativeAxon(rootAxon, new Point3f(-30, -20, 30), axonRadius));
    layer.add(addRelativeAxon(rootAxon, new Point3f(30, -20, 30), axonRadius));
    layer.add(addRelativeAxon(rootAxon, new Point3f(30, -20, -30), axonRadius));

    for (int i = 0; i < layer.size(); i++) {
      Segment axon = (Segment) layer.elementAt(i);
      Segment a1 = addRelativeAxon(axon, new Point3f(-6, -4, -6), axonRadius);
      Segment a2 = addRelativeAxon(axon, new Point3f(6, -4, -6), axonRadius);
      Segment a3 = addRelativeAxon(axon, new Point3f(-6, -4, 6), axonRadius);
      Segment a4 = addRelativeAxon(axon, new Point3f(6, -4, 6), axonRadius);

      a1.getSection().addToGroup(axonSynGroup);
      a2.getSection().addToGroup(axonSynGroup);
      a3.getSection().addToGroup(axonSynGroup);
      a4.getSection().addToGroup(axonSynGroup);
    }

    float dendriteDiam = 2;

    int numDendrites = 6;

    for (int i = 0; i < numDendrites; i++) {
      double theta = ((2 * Math.PI) / numDendrites) * i;

      float xFact = (float) Math.sin(theta);
      float zFact = (float) Math.cos(theta);

      posnEndPoint = new Point3f(60 * xFact, 60, 60 * zFact);
      Segment radialDend =
          addDendriticSegment(
              dendriteDiam,
              "radialDend_" + i,
              posnEndPoint,
              somaSection,
              0,
              "radialDend_" + i + "_Sec",
              false);

      Point3f posnNew = new Point3f(30 * xFact, 40, 30 * zFact);
      Segment radialDend2 = addRelativeDendrite(radialDend, posnNew);
      radialDend2.getSection().addToGroup(dendSynGroup);
      Point3f posnNew2 = new Point3f(0, 30, 0);
      Segment radialDend3 = addRelativeDendrite(radialDend2, posnNew2);

      radialDend3.getSection().addToGroup(dendSynGroup);

      Point3f posnNew3 = new Point3f(-10 * xFact, 30, -10 * zFact);
      Segment radialDend4 = addRelativeDendrite(radialDend, posnNew3);

      radialDend4.getSection().addToGroup(dendSynGroup);
      Point3f posnNew4 = new Point3f(0, 25, 0);
      Segment radialDend5 = addRelativeDendrite(radialDend4, posnNew4);

      radialDend5.getSection().addToGroup(dendSynGroup);
    }
  }