本文整理汇总了C#中WorldServer.player.Player.getBank方法的典型用法代码示例。如果您正苦于以下问题:C# Player.getBank方法的具体用法?C# Player.getBank怎么用?C# Player.getBank使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldServer.player.Player
的用法示例。
在下文中一共展示了Player.getBank方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: execute
public void execute(Player player, string[] arguments)
{
if (!player.inCombat())
player.getBank().openBank();
}
示例3: loadPlayer
public ReturnCode loadPlayer(Connection connection)
{
if (connection == null)
return ReturnCode.COULD_NOT_COMPLETE;
LoginDetails loginDetails = connection.getLoginDetails();
if (loginDetails == null || loginDetails.getUsername() == "" || loginDetails.getLongName() == 0)
return ReturnCode.INVALID_PASSWORD;//ReturnCode.INVALID_PASSWORD;
foreach (char c in loginDetails.getUsername().ToCharArray())
{
if (!char.IsLetterOrDigit(c) && !char.IsWhiteSpace(c))
return ReturnCode.INVALID_PASSWORD;
}
Player createdPlayer = new Player(connection);
connection.setPlayer(createdPlayer); //player finally created.
createdPlayer.setLoginDetails(loginDetails);
if (!File.Exists(misc.getServerPath() + @"\accounts\" + loginDetails.getUsername() + ".xml")) {
createdPlayer.setRights(2); //all new users admins atm (change later).
createdPlayer.setLocation(new Location(2323, 3174, 0));
return ReturnCode.LOGIN_OK; //new user.
}
//Yeah reading XML files is a bit homo.
try
{
int temp;
long lTemp;
string username = createdPlayer.getLoginDetails().getUsername().ToLower();
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(misc.getServerPath() + @"\accounts\" + username + ".xml");
XmlNode xmlNode = xmlDocument.SelectSingleNode("/Player/Login/Password");
if (xmlNode == null) return ReturnCode.INVALID_PASSWORD; //no password node.
if (createdPlayer.getLoginDetails().getPassword() != xmlNode.InnerText)
return ReturnCode.INVALID_PASSWORD;
XmlNode loginElement = xmlDocument.SelectSingleNode("/Player/Login");
if(loginElement != null && loginElement.HasChildNodes) {
XmlNodeList childs = loginElement.ChildNodes;
foreach (XmlElement element in childs)
{
switch (element.Name)
{
case "Rights":
if (!int.TryParse(element.InnerText, out temp))
temp = 0;
createdPlayer.setRights(temp);
break;
case "BankPin":
if (element.InnerText == "") continue;
createdPlayer.getBank().setBankPin(element.InnerText);
break;
}
}
}
loginElement = xmlDocument.SelectSingleNode("/Player/Position");
if (loginElement != null && loginElement.HasChildNodes)
{
XmlNodeList childs = loginElement.ChildNodes;
Location location = new Location();
foreach (XmlElement element in childs)
{
switch (element.Name)
{
case "X":
if (!int.TryParse(element.InnerText, out temp)) {
createdPlayer.setLocation(Constants.HOME_SPAWN_LOCATION);
break;
}
location.setX(temp);
break;
case "Y":
if (!int.TryParse(element.InnerText, out temp)) {
createdPlayer.setLocation(Constants.HOME_SPAWN_LOCATION);
break;
}
location.setY(temp);
break;
case "Z":
if (!int.TryParse(element.InnerText, out temp))
temp = 0;
location.setZ(temp);
break;
}
}
createdPlayer.setLocation(location);
if (Location.atDuelArena(createdPlayer.getLocation()))
DuelSession.teleportDuelArenaHome(createdPlayer);
}
xmlNode = xmlDocument.SelectSingleNode("/Player/Settings/RunEnergy");
if (xmlNode == null)
{
temp = 100;
} else {
if (!int.TryParse(xmlNode.InnerText, out temp))
temp = 100;
//.........这里部分代码省略.........