Created
October 24, 2011 21:00
-
-
Save daltonks/1310281 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.dalton.mineconquer; | |
import java.util.ArrayList; | |
import java.util.List; | |
import org.bukkit.Location; | |
import org.bukkit.entity.Player; | |
public class CaptureHandler { | |
static List<CaptureSpot> captureSpots = new ArrayList<CaptureSpot>(); | |
public static void newCapturer(Player playa){ | |
Location location = playa.getLocation(); | |
int px = location.getBlockX(); | |
int pz = location.getBlockZ(); | |
String name = playa.getName(); | |
ChunkData playerChunk = new ChunkData(playa.getLocation().getBlock().getChunk()); | |
//get adjacent chunks and find the closest | |
double distance = 9001; | |
ChunkData closestChunk = null; | |
for(ChunkData enemyChunk : Util.getEnemyChunks(name)) | |
if(enemyChunk.isAdjacentTo(playerChunk)){ | |
double tempDistance = Util.getDistance(enemyChunk.X * 16 + 8, enemyChunk.Z * 16 + 8, px, pz); | |
if(tempDistance < distance){ | |
distance = tempDistance; | |
closestChunk = enemyChunk; | |
} | |
} | |
if(closestChunk == null) | |
return; | |
for(CaptureSpot spot : captureSpots){ | |
if(spot.chunk.equals(closestChunk)){ | |
spot.addAttacker(name); | |
return; | |
} | |
} | |
captureSpots.add(new CaptureSpot(name, closestChunk)); | |
//TODO broadcasting that their chunk is being taken over | |
} | |
public static void iterateSpots(){ | |
for(CaptureSpot cSection : captureSpots){ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment