本文整理汇总了C#中Player.getLocation方法的典型用法代码示例。如果您正苦于以下问题:C# Player.getLocation方法的具体用法?C# Player.getLocation怎么用?C# Player.getLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player.getLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fillingVial
// TODO make this use an AreaEvent so itll work from a distance.
/**
* Will fill vials in a continuous motion from a water source.
*/
public static bool fillingVial(Player p, Location loc)
{
if (!p.getInventory().hasItem(VIAL) || !p.getLocation().withinDistance(loc, 2))
{
return true;
}
if (p.getTemporaryAttribute("fillVialTimer") != null)
{
long lastFillTime = (int)p.getTemporaryAttribute("fillVialTimer");
if (Environment.TickCount - lastFillTime < 600)
{
return true;
}
}
p.setTemporaryAttribute("fillingVials", true);
p.setFaceLocation(loc);
Event fillVialEvent = new Event(500);
fillVialEvent.setAction(() =>
{
int amountFilled = 0;
string s = amountFilled == 1 ? "vial" : "vials";
if (p.getTemporaryAttribute("fillingVials") == null || !p.getLocation().withinDistance(loc, 2) || !p.getInventory().hasItem(229))
{
p.setLastAnimation(new Animation(65535));
if (amountFilled > 0)
{
p.getPackets().sendMessage("You fill up the " + s + " with water.");
}
fillVialEvent.stop();
return;
}
if (p.getInventory().replaceSingleItem(VIAL, VIAL_OF_WATER))
{
p.setLastAnimation(new Animation(832));
amountFilled++;
p.setTemporaryAttribute("fillVialTimer", Environment.TickCount);
}
else
{
if (amountFilled > 0)
{
p.setLastAnimation(new Animation(65535));
p.getPackets().sendMessage("You fill up the " + s + " with water.");
}
fillVialEvent.stop();
}
});
Server.registerEvent(fillVialEvent);
return true;
}
示例2: canMove
public static bool canMove(Player player)
{
HashSet<Node> allPossibleMoveLocations = new HashSet<Node>();
allPossibleMoveLocations = player.getLocation().getAllEdges();
allPossibleMoveLocations.ExceptWith (getAllOtherPlayerLocations (player));
bool playerBlocked = (allPossibleMoveLocations.Count == 0);
if(playerBlocked){
return false;
}
foreach (Node adjacentLocation in allPossibleMoveLocations) {
//create new HashSet that will hold the connection types... not sure if inside or outside loop.
HashSet<TransportType> connectionTypes = getPossibleConnectionTypes(player.getLocation(), adjacentLocation);
foreach(TransportType type in connectionTypes){
if(playerHasEnoughTickets(player, type)){
return true;
}
}
}
//player does not have enough tickets
return false;
}
示例3: attack
public void attack(Player target)
{
List<Location> locations = getAttackableLocations();
if (! locations.Contains(target.getLocation()))
{
Debug.Log("Can not attack player");
return;
}
target.takeDamage(getdamageBase());
Debug.Log("Target was reduced to " + target.getHealthPower() + " health");
}
示例4: doAgility
public static bool doAgility(Player p, int gameObject, int x, int y)
{
for (int i = 0; i < GNOME_COURSE.Length; i++) {
if (gameObject == (int)GNOME_COURSE[i][0]) {
GnomeCourse.doCourse(p, x, y, GNOME_COURSE[i]);
return true;
}
}
for (int i = 0; i < BARBARIAN_COURSE.Length; i++) {
if (gameObject == (int)BARBARIAN_COURSE[i][0]) {
BarbarianCourse.doCourse(p, x, y, BARBARIAN_COURSE[i]);
return true;
}
}
for (int i = 0; i < WILDERNESS_COURSE.Length; i++) {
if (gameObject == (int)WILDERNESS_COURSE[i][0]) {
WildernessCourse.doCourse(p, x, y, WILDERNESS_COURSE[i]);
return true;
}
}
for (int i = 0; i < APE_ATOLL_COURSE.Length; i++) {
if (gameObject == (int)APE_ATOLL_COURSE[i][0]) {
ApeAtollCourse.doCourse(p, x, y, APE_ATOLL_COURSE[i]);
return true;
}
}
for (int i = 0; i < AGILITY_ARENA_PILLARS.Length; i++) {
if (x == AGILITY_ARENA_PILLARS[i][1] && y == AGILITY_ARENA_PILLARS[i][2]) {
if (gameObject == AGILITY_ARENA_PILLARS[i][0]) {
AgilityArena.tagPillar(p, i);
return true;
}
}
}
if (Location.atAgilityArena(p.getLocation())) {
for (int i = 0; i < AGILITY_ARENA_OBJECTS.Length; i++) {
if (x == (int)AGILITY_ARENA_OBJECTS[i][1] && y == (int)AGILITY_ARENA_OBJECTS[i][2]) {
if (gameObject == (int)AGILITY_ARENA_OBJECTS[i][0]) {
Obstacles.doObstacle(p, i);
return true;
}
}
}
}
if (gameObject == 3205 && x == 2532 && y == 3545)
{
BarbarianCourse.useLadder(p);
return true;
}
return false;
}
示例5: calculateValue
/**
* Uses a breadth-first-search to calculate the distance between a given Detective and Mr X.
* Only considers the absolute distance between the Detective and Mr. X. Ticket amounts are
* not accounted for.
*/
public static int calculateValue(GamePosition game, Player player)
{
int mrXId = 0;
var nodes = new HashSet<Node>(game.Board.Values);
foreach(Node node in nodes){
node.Color = Color.white;
node.Value = Int32.MaxValue;
node.Parent = null;
}
player.getLocation().Color = Color.gray;
player.getLocation().Value = 0;
player.getLocation().Parent = null;
int MAX_NUMBER_OF_NODES = 200;
HeapPriorityQueue<Node> pq = new HeapPriorityQueue<Node>(MAX_NUMBER_OF_NODES);
Node playerLocation = player.getLocation();
pq.Enqueue(playerLocation, playerLocation.Value);
while(pq.First != null){
Node u = pq.Dequeue();
foreach(Node v in u.getAllEdges()){
if(v.Color == Color.white){
v.Color = Color.gray;
v.Value = u.Value + 1;
v.Parent = u;
if(v == game.Players[mrXId].getLocation()){
return v.Value;
}
pq.Enqueue(v, v.Value);
}
}
u.Color = Color.black;
}
throw new Exception ("calculate value error!!!!!!!");
//Not all code paths return a value, should the following line be here?
return MAX_NUMBER_OF_NODES;
}
示例6: canFish
public static bool canFish(Player p, Spot fishingSpot, Spot fishingSpot2, int index)
{
if (p == null || fishingSpot == null)
{
return false;
}
if (!p.getLocation().withinDistance(fishingSpot.getSpotLocation(), 2))
{
return false;
}
if (fishingSpot2 != null)
{
if (!fishingSpot.Equals(fishingSpot2))
{
return false;
}
}
if (p.getSkills().getGreaterLevel(Skills.SKILL.FISHING) < fishingSpot.getLevel()[index])
{
p.getPackets().sendMessage("You need a fishing level of " + fishingSpot.getLevel()[index] + " to fish here.");
return false;
}
if (fishingSpot.getPrimaryItem() != -1)
{
if (!p.getInventory().hasItem(fishingSpot.getPrimaryItem()))
{
p.getPackets().sendMessage("You need " + fishingSpot.getPrimaryName() + " to fish here.");
return false;
}
}
if (fishingSpot.getSecondaryItem() != -1)
{
if (!p.getInventory().hasItem(fishingSpot.getSecondaryItem()))
{
p.getPackets().sendMessage("You need " + fishingSpot.getSecondaryName() + " to fish here.");
return false;
}
}
if (p.getInventory().findFreeSlot() == -1)
{
p.getPackets().sendChatboxInterface(210);
p.getPackets().modifyText("Your inventory is too full to catch any more fish.", 210, 1);
return false;
}
return true;
}
示例7: canMakeFire
private static bool canMakeFire(Player p, int logIndex, bool colouredLog)
{
if (p.getTemporaryAttribute("unmovable") != null) {
return false;
}
if (Server.getGlobalObjects().fireExists(p.getLocation())) {
p.getPackets().sendMessage("You cannot light a fire here.");
return false;
}
if ((p.getSkills().getGreaterLevel(Skills.SKILL.FIREMAKING) < FIRE_LEVEL[logIndex]) && !colouredLog) {
p.getPackets().sendMessage("You need a Firemaking level of " + FIRE_LEVEL[logIndex] + " to light this log.");
return false;
}
if (!p.getInventory().hasItem(TINDERBOX)) {
p.getPackets().sendMessage("You need a tinderbox if you intend on actually make a fire!");
return false;
}
return true;
}
示例8: cutTree
public static void cutTree(Player p, ushort treeId, Location treeLocation, int i, bool newCut, int distance)
{
if (!newCut && p.getTemporaryAttribute("cuttingTree") == null) {
return;
}
if (newCut) {
if (i == 10 || i == 11) { // Magic or Yew tree.
if (!Server.getGlobalObjects().objectExists(treeId, treeLocation)) {
// misc.WriteError(p.getUsername() + " tried to cut a non existing Magic or Yew tree!");
// return;
}
}
Tree newTree = new Tree(i, treeId, treeLocation, LOGS[i], LEVEL[i], TREE_NAME[i], XP[i], distance);
p.setTemporaryAttribute("cuttingTree", newTree);
}
Tree treeToCut = (Tree) p.getTemporaryAttribute("cuttingTree");
if (!canCut(p, treeToCut, null)) {
resetWoodcutting(p);
return;
}
if (newCut) {
p.setLastAnimation(new Animation(getAxeAnimation(p)));
p.setFaceLocation(treeLocation);
p.getPackets().sendMessage("You begin to swing your axe at the tree..");
}
int delay = getCutTime(p, treeToCut.getTreeIndex());
Event cutTreeEvent = new Event(delay);
cutTreeEvent.setAction(() => {
cutTreeEvent.stop();
if (p.getTemporaryAttribute("cuttingTree") == null) {
resetWoodcutting(p);
return;
}
Tree tree = (Tree) p.getTemporaryAttribute("cuttingTree");
if (!canCut(p, treeToCut, tree)) {
resetWoodcutting(p);
return;
}
Server.getGlobalObjects().lowerHealth(tree.getTreeId(), tree.getTreeLocation());
if (!Server.getGlobalObjects().originalObjectExists(tree.getTreeId(), tree.getTreeLocation())) {
resetWoodcutting(p);
p.setLastAnimation(new Animation(65535));
}
if (p.getInventory().addItem(tree.getLog())) {
p.getPackets().closeInterfaces();
int index = tree.getTreeIndex();
string s = index == 1 || index == 3 || index == 8 ? "an" : "a";
p.getSkills().addXp(Skills.SKILL.WOODCUTTING, tree.getXp());
if (index == 6 ) {
p.getPackets().sendMessage("You retrieve some Hollow bark from the tree.");
} else {
p.getPackets().sendMessage("You cut down " + s + " " + tree.getName() + " log.");
}
if (misc.random(3) == 0) {
int nestId = misc.random(10) == 0 ? 5073 : 5074;
GroundItem g = new GroundItem(nestId, 1, new Location(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ()), p);
Server.getGroundItems().newEntityDrop(g);
p.getPackets().sendMessage("Something falls out of the tree and lands at your feet.");
}
}
cutTree(p, tree.getTreeId(), tree.getTreeLocation(), tree.getTreeIndex(), false, tree.getDistance());
});
Server.registerEvent(cutTreeEvent);
if (delay >= 2550) {
Event treeCuttingAnimationEvent = new Event(2550);
int time = delay;
treeCuttingAnimationEvent.setAction(() => {
time -= 2550;
if (time <= 0) {
treeCuttingAnimationEvent.stop();
}
Tree tree = (Tree) p.getTemporaryAttribute("cuttingTree");
if (!canCut(p, treeToCut, tree)) {
treeCuttingAnimationEvent.stop();
return;
}
p.setFaceLocation(treeLocation);
p.setLastAnimation(new Animation(getAxeAnimation(p)));
});
Server.registerEvent(treeCuttingAnimationEvent);
}
}
示例9: canCut
private static bool canCut(Player p, Tree tree, Tree tree2)
{
if (tree == null || p == null || !Server.getGlobalObjects().originalObjectExists(tree.getTreeId(), tree.getTreeLocation())) {
return false;
}
if (!p.getLocation().withinDistance(tree.getTreeLocation(), tree.getDistance())) {
return false;
}
if (tree2 != null) {
if (!tree.Equals(tree2)) {
return false;
}
}
if (p.getSkills().getGreaterLevel(Skills.SKILL.WOODCUTTING) < tree.getLevel())
{
p.getPackets().sendMessage("You need a Woodcutting level of " + tree.getLevel() + " to cut that tree.");
return false;
}
if (!hasAxe(p)) {
p.getPackets().sendMessage("You need an axe to cut down a tree!");
return false;
}
if (p.getInventory().findFreeSlot() == -1) {
p.getPackets().sendChatboxInterface(210);
p.getPackets().modifyText("Your inventory is too full to carry any logs.", 210, 1);
return false;
}
return true;
}
示例10: faceAltar
private static void faceAltar(Player p, int i)
{
p.setFaceLocation(new Location(ALTAR_COORDS[i][0], ALTAR_COORDS[i][1], p.getLocation().getZ()));
}
示例11: openSlayerShop
public static bool openSlayerShop(Player p, Npc npc)
{
int id = npc.getId();
if (id != 8273 && id != 1597 && id != 8274 && id != 1598 && id != 8275 || p.isDead()) {
return false;
}
p.setEntityFocus(npc.getClientIndex());
AreaEvent openSlayerShopAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
openSlayerShopAreaEvent.setAction(() => {
p.setFaceLocation(npc.getLocation());
npc.setFaceLocation(p.getLocation());
p.setShopSession(new ShopSession(p, 2));
});
Server.registerCoordinateEvent(openSlayerShopAreaEvent);
return true;
}
示例12: canThieveNpc
private static bool canThieveNpc(Player p, Npc npc, int index)
{
if (p == null || npc == null || npc.isDead() || npc.isHidden() || npc.isDestroyed() || p.isDead() || p.isDestroyed()) {
return false;
}
if (!p.getLocation().withinDistance(npc.getLocation(), 2)) {
return false;
}
if (p.getSkills().getGreaterLevel(Skills.SKILL.THIEVING) < NPC_LVL[index]) {
p.getPackets().sendMessage("You need a Thieving level of " + NPC_LVL[index] + " to rob this Npc.");
p.setFaceLocation(npc.getLocation());
return false;
}
if (p.getInventory().findFreeSlot() == -1) {
p.getPackets().sendMessage("You need a free inventory space for any potential loot.");
return false;
}
if (p.getTemporaryAttribute("stunned") != null) {
return false;
}
if (p.getTemporaryAttribute("lastPickPocket") != null) {
if (Environment.TickCount - (int)p.getTemporaryAttribute("lastPickPocket") < 1500) {
return false;
}
}
return true;
}
示例13: homeTeleport
public static void homeTeleport(Player p)
{
if (p.getTemporaryAttribute("teleporting") != null || p.getTemporaryAttribute("homeTeleporting") != null || p.getTemporaryAttribute("unmovable") != null || p.getTemporaryAttribute("cantDoAnything") != null)
{
return;
}
if (Location.inFightPits(p.getLocation()))
{
p.getPackets().sendMessage("You are unable to teleport from the fight pits.");
return;
}
if (Location.inFightCave(p.getLocation()))
{
FightCave.antiTeleportMessage(p);
return;
}
if (p.getTemporaryAttribute("teleblocked") != null)
{
p.getPackets().sendMessage("A magical force prevents you from teleporting!");
return;
}
if (Location.inWilderness(p.getLocation()) && p.getLocation().wildernessLevel() >= 20)
{
p.getPackets().sendMessage("You cannot teleport above level 20 wilderness!");
return;
}
if (p.getDuel() != null)
{
if (p.getDuel().getStatus() < 4)
{
p.getDuel().declineDuel();
}
else if (p.getDuel().getStatus() == 5)
{
p.getPackets().sendMessage("You cannot teleport whilst in a duel.");
return;
}
else if (p.getDuel().getStatus() == 8)
{
if (p.getDuel().getWinner().Equals(p))
{
p.getDuel().recieveWinnings(p);
}
}
}
p.getPackets().closeInterfaces();
p.setTemporaryAttribute("teleporting", true);
p.setTemporaryAttribute("homeTeleporting", true);
p.getWalkingQueue().resetWalkingQueue();
p.getPackets().clearMapFlag();
SkillHandler.resetAllSkills(p);
Event teleportHomeAnimationEvent = new Event(500);
int currentStage = 0;
teleportHomeAnimationEvent.setAction(() =>
{
if (p.getTemporaryAttribute("homeTeleporting") == null)
{
p.setLastAnimation(new Animation(65535, 0));
p.setLastGraphics(new Graphics(65535, 0));
resetTeleport(p);
teleportHomeAnimationEvent.stop();
return;
}
if (currentStage++ >= 16)
{
resetTeleport(p);
p.teleport(new Location(HOME_TELE[0] + Misc.random(HOME_TELE[2]), HOME_TELE[1] + Misc.random(HOME_TELE[3]), 0));
teleportHomeAnimationEvent.stop();
return;
}
p.setLastAnimation(new Animation(HOME_ANIMATIONS[currentStage], 0));
p.setLastGraphics(new Graphics(HOME_GRAPHICS[currentStage], 0));
});
Server.registerEvent(teleportHomeAnimationEvent);
}
示例14: useTeletab
public static bool useTeletab(Player p, int item, int slot)
{
int index = -1;
for (int i = 0; i < TELETABS.Length; i++)
{
if (item == TELETABS[i])
{
index = i;
}
}
if (index == -1)
{
return false;
}
if (p.getTemporaryAttribute("teleporting") != null || p.getTemporaryAttribute("homeTeleporting") != null || p.getTemporaryAttribute("unmovable") != null || p.getTemporaryAttribute("cantDoAnything") != null)
{
return false;
}
if (p.getTemporaryAttribute("teleblocked") != null)
{
p.getPackets().sendMessage("A magical force prevents you from teleporting!");
return false;
}
if (Location.inFightPits(p.getLocation()))
{
p.getPackets().sendMessage("You are unable to teleport from the fight pits.");
return false;
}
if (Location.inFightCave(p.getLocation()))
{
FightCave.antiTeleportMessage(p);
return false;
}
if (Location.inWilderness(p.getLocation()) && p.getLocation().wildernessLevel() >= 20)
{
p.getPackets().sendMessage("You cannot teleport above level 20 wilderness!");
return false;
}
if (p.getDuel() != null)
{
if (p.getDuel().getStatus() < 4)
{
p.getDuel().declineDuel();
}
else if (p.getDuel().getStatus() == 8)
{
if (p.getDuel().getWinner().Equals(p))
{
p.getDuel().recieveWinnings(p);
}
}
}
int x = TELE_X[index] + Misc.random(TELE_EXTRA_X[index]);
int y = TELE_Y[index] + Misc.random(TELE_EXTRA_Y[index]);
p.getPackets().closeInterfaces();
p.getPackets().sendBlankClientScript(1297);
p.getWalkingQueue().resetWalkingQueue();
p.getPackets().clearMapFlag();
SkillHandler.resetAllSkills(p);
if (p.getInventory().deleteItem(item, slot, 1))
{
p.setTemporaryAttribute("unmovable", true);
p.setTemporaryAttribute("teleporting", true);
p.setLastAnimation(new Animation(9597));
p.setLastGraphics(new Graphics(1680, 0, 0));
//p.setLastGraphics(new Graphics(678, 0, 0)); // blue gfx
Event teleportEvent = new Event(900);
int teleportCounter = 0;
teleportEvent.setAction(() =>
{
if (teleportCounter == 0)
{
p.setLastAnimation(new Animation(4071));
teleportCounter++;
}
else
{
p.setLastAnimation(new Animation(65535));
p.removeTemporaryAttribute("unmovable");
p.teleport(new Location(x, y, 0));
resetTeleport(p);
teleportEvent.stop();
}
});
Server.registerEvent(teleportEvent);
return true;
}
return true;
}
示例15: stopAllOtherMiners
private static void stopAllOtherMiners(Player player, Rock rock)
{
foreach (Player p in Server.getPlayerList())
{
if (p != null && player.getLocation().withinDistance(p.getLocation(), 5) && !p.Equals(player))
{
if (p.getTemporaryAttribute("miningRock") != null)
{
Rock otherPlayerRock = (Rock)p.getTemporaryAttribute("miningRock");
if (otherPlayerRock.getRockLocation().Equals(rock.getRockLocation()))
{
p.setLastAnimation(new Animation(65535));
}
}
}
}
}