本文整理汇总了C#中RunescapeServer.player.Player.getRunEnergy方法的典型用法代码示例。如果您正苦于以下问题:C# Player.getRunEnergy方法的具体用法?C# Player.getRunEnergy怎么用?C# Player.getRunEnergy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RunescapeServer.player.Player
的用法示例。
在下文中一共展示了Player.getRunEnergy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: savePlayer
public bool savePlayer(Player p)
{
if (p == null) return false;
try
{
string username = p.getLoginDetails().getUsername().ToLower();
/* Character saving code goes here */
XmlTextWriter writer = new XmlTextWriter(misc.getServerPath() + @"\accounts\" + username + ".xml", null);
writer.Formatting = Formatting.Indented;
writer.WriteStartElement("Player");
writer.WriteStartElement("Login");
writer.WriteElementString("Password", p.getLoginDetails().getPassword());
writer.WriteElementString("Rights", p.getRights().ToString());
writer.WriteElementString("BankPin", p.getBank().getBankPin());
writer.WriteEndElement();
writer.WriteStartElement("Position");
writer.WriteElementString("X", p.getLocation().getX().ToString());
writer.WriteElementString("Y", p.getLocation().getY().ToString());
writer.WriteElementString("Z", p.getLocation().getZ().ToString());
writer.WriteEndElement();
writer.WriteStartElement("Settings");
writer.WriteElementString("RunEnergy", p.getRunEnergy().ToString());
writer.WriteStartElement("PrivacySettings");
writer.WriteElementString("Public", p.getFriends().getPrivacyOption(0).ToString());
writer.WriteElementString("Private", p.getFriends().getPrivacyOption(1).ToString());
writer.WriteElementString("Trade", p.getFriends().getPrivacyOption(2).ToString());
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteStartElement("Friends");
foreach(long friend in p.getFriends().getFriendsList())
writer.WriteElementString("Friend", friend.ToString());
writer.WriteEndElement();
writer.WriteStartElement("Ignores");
foreach (long ignore in p.getFriends().getIgnoresList())
writer.WriteElementString("Ignore", ignore.ToString());
writer.WriteEndElement();
writer.WriteStartElement("Stats");
foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL))) {
writer.WriteStartElement(skill.ToString()); //skill name.
writer.WriteElementString("CurrentLevel", p.getSkills().getCurLevel(skill).ToString());
writer.WriteElementString("XP", p.getSkills().getXp(skill).ToString());
writer.WriteEndElement();
}
writer.WriteEndElement();
Item item;
writer.WriteStartElement("EquipmentItems");
foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) {
if (equip == ItemData.EQUIP.NOTHING) continue;
item = p.getEquipment().getSlot(equip);
if (item.getItemId() == -1) continue; //empty slot.
writer.WriteStartElement(equip.ToString());
writer.WriteElementString("Id", item.getItemId().ToString());
writer.WriteElementString("Amount", item.getItemAmount().ToString());
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteStartElement("InventoryItems");
for (int i = 0; i < Inventory.MAX_INVENTORY_SLOTS; i++) {
item = p.getInventory().getSlot(i);
if (item.getItemId() == -1) continue; //empty slot.
writer.WriteStartElement("Item");
writer.WriteElementString("Slot", i.ToString());
writer.WriteElementString("Id", item.getItemId().ToString());
writer.WriteElementString("Amount", item.getItemAmount().ToString());
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteStartElement("BankItems");
for (int i = 0; i < Bank.MAX_BANK_SLOTS; i++)
{
item = p.getBank().getSlot(i);
if (item.getItemId() == -1) continue; //empty slot.
writer.WriteStartElement("Item");
writer.WriteElementString("Slot", i.ToString());
writer.WriteElementString("Id", item.getItemId().ToString());
writer.WriteElementString("Amount", item.getItemAmount().ToString());
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndElement();
//Write the XML to file and close the writer
writer.Close();
}
catch (Exception)
{
return false;
}
//.........这里部分代码省略.........
示例2: drinkPotion
private static void drinkPotion(Player p, int i, int j, int slot) {
//TODO antipoisons/antifire
int lastPotion = -1;
int delay = 500;
long lastDrink = 0;
if (p.isDead() || p.getTemporaryAttribute("willDie") != null) {
return;
}
if (p.getDuel() != null) {
if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_DRINKS)) {
p.getPackets().sendMessage("Drinks have been disabled for this duel!");
return;
}
}
if (p.getTemporaryAttribute("lastDrankPotion") != null) {
lastPotion = (int) p.getTemporaryAttribute("lastDrankPotion");
}
if (p.getTemporaryAttribute("drinkPotionTimer") != null) {
lastDrink = (int) p.getTemporaryAttribute("drinkPotionTimer");
}
int time = (j == lastPotion) ? 1000 : 500;
if (Environment.TickCount - lastDrink < time) {
return;
}
p.getPackets().closeInterfaces();
p.setTemporaryAttribute("drinkPotionTimer", Environment.TickCount);
p.setTemporaryAttribute("lastDrankPotion", j);
p.setTarget(null);
p.resetCombatTurns();
p.setEntityFocus(65535);
p.removeTemporaryAttribute("autoCasting");
Event drinkPotionEvent = new Event(delay);
drinkPotionEvent.setAction(() => {
drinkPotionEvent.stop();
if (p.isDead() || p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) <= 0) {
return;
}
int item = i != 0 && POTIONS[i - 1][j] != -1 ? POTIONS[i - 1][j] : 229;
if (!p.getInventory().replaceItemSlot(POTIONS[i][j], item, slot)) {
return;
}
string drinkPotion = ItemData.forId(POTIONS[0][j]).getName().Replace("(", "").Replace(")", "").Replace("3", "").Replace("2", "").Replace("1", "").ToLower();
p.getPackets().sendMessage("You drink some of your " + drinkPotion + ".");
p.getPackets().sendMessage("You have " + (i == 0 ? "no" : i.ToString()) + " doses of potion left.");
switch(j) {
case 0: //Attack potion [+3 and 10% of max attack]
statBoost(p, Skills.SKILL.ATTACK, 0.10, 3, false);
break;
case 1: //Antipoison potion
p.setPoisonAmount(0);
break;
case 2: //Strength potion [+3 and 10% of max strength]
statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
break;
case 3: //Restore potion [restores randomly between 10-39 points]
restorePotion(p, Skills.SKILL.DEFENCE, 10, 39);
restorePotion(p, Skills.SKILL.ATTACK, 10, 39);
restorePotion(p, Skills.SKILL.STRENGTH, 10, 39);
restorePotion(p, Skills.SKILL.RANGE, 10, 39);
restorePotion(p, Skills.SKILL.HITPOINTS, 10, 39);
break;
case 4: //Energy potion [restores 20% energy]
double newEnergy = p.getRunEnergy() * 0.20;
p.setRunEnergy(((p.getRunEnergy() + (int)newEnergy >= 100) ? 100 : (p.getRunEnergy() + (int)newEnergy)));
break;
case 5: //Defence potion [Should be +3 and 10% of max defence]
statBoost(p, Skills.SKILL.DEFENCE, 0.10, 3, false);
break;
case 6: //Agility potion [restores 2 or 3 agility points]
int newAgility = misc.random(2, 3) + p.getSkills().getCurLevel(Skills.SKILL.AGILITY);
if (newAgility < p.getSkills().getMaxLevel(Skills.SKILL.AGILITY))
p.getSkills().setCurLevel(Skills.SKILL.AGILITY, newAgility);
break;
case 7: //Combat potion [Should be 10% of attack+strength and +3 to each].
statBoost(p, Skills.SKILL.ATTACK, 0.10, 3, false);
statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
break;
case 8: //Prayer potion, [heals 7-31, formula = 7+floor(prayerlevel/4)]
int newPrayer = 7 + (int)Math.Floor((double)(p.getSkills().getMaxLevel(Skills.SKILL.PRAYER) / 4)) + p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
if (newPrayer < p.getSkills().getCurLevel(Skills.SKILL.PRAYER))
p.getSkills().setCurLevel(Skills.SKILL.PRAYER, newPrayer);
checkOverdose(p, Skills.SKILL.PRAYER);
break;
case 9: //Summoning potion [25% of players summoning + 7]
int newSummoning = (7 + (int)((double)p.getSkills().getMaxLevel(Skills.SKILL.SUMMONING) * 0.25)) + p.getSkills().getCurLevel(Skills.SKILL.SUMMONING);
if (newSummoning < p.getSkills().getCurLevel(Skills.SKILL.SUMMONING))
p.getSkills().setCurLevel(Skills.SKILL.SUMMONING, newSummoning);
statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
break;
//.........这里部分代码省略.........