public void AddPlayer(Player playerToAdd) { if (!players.Contains(playerToAdd)) { playerToAdd.ResetNetMessages(); players.Add(playerToAdd); } }
/// <summary> /// Gets the thing with the specified parameters or /// null if such a thing can't be found. Note: The thing /// must be visible for the player. /// </summary> /// <param name="player">The player for whom to get the item.</param> /// <param name="pos">The position of the item.</param> /// <param name="stackpos">The stackposition of the thing.</param> /// <param name="usePosZ">Use position.z for index instead of stackpos.</param> /// <returns>The thing or null if can't be found.</returns> public Thing GetThing(Player player, Position pos, byte stackpos, bool usePosZ) { //container/inventory if (CarryingPos(pos)) { if (ContainerPos(pos)) { //From container int containerIndex = pos.y - CONTAINER_HEADER; int itemIndex = usePosZ ? pos.z : stackpos; Container container = player.GetContainerByIndex(containerIndex); if (container == null) { return null; } return container.GetItemByIndex(itemIndex); } else { //inventory return player.GetInventoryItem((byte)pos.y); } } else if (player.CanSee(pos)) { //ground if (stackpos == Constants.STACKPOS_TOP_ITEM) { return map.GetTopThing(pos); } else { Tile tile = map.GetTile(pos); if (tile == null) { return null; } return tile.GetThing(stackpos); } } return null; }
public void SaveComment(string comment, Player player) { TextWriter tw = new StreamWriter(GetPath("comments.txt"), true); tw.WriteLine("********************************************"); tw.WriteLine("Player name: " + player.Name); tw.WriteLine("Comment: " + comment); tw.WriteLine("********************************************"); tw.WriteLine(""); tw.Close(); }
/// <summary> /// Process when a player says something. /// </summary> /// <param name="player">The player who is talking.</param> /// <param name="world">A reference to the gameworld.</param> private void ProcessChat(Player player, GameWorld world) { byte speakType = netmsg.GetByte(); string reciever = null; ushort channelID = 0; if (speakType == Constants.SPEAK_PRIVATE_MSG || speakType == Constants.SPEAK_RV_COUNSELLOR) { reciever = netmsg.GetStringL(); return; } else if (speakType == Constants.SPEAK_CHANNEL_YELLOW) { channelID = netmsg.GetU16(); return; } string msg = netmsg.GetStringL(); Console.WriteLine("msg: " + msg); //Test for acceptable string length if (msg.Length > MAX_STRING_LENGTH) { return; } world.HandleChat(player, msg); }
/// <summary> /// Process a player's walk. /// </summary> /// <param name="player">The player doing the action.</param> /// <param name="world">A reference to the gameworld.</param> private void ProcessWalkNorth(Player player, GameWorld world) { world.HandleManualWalk(player, Direction.NORTH); }
/// <summary> /// Create a spell that a player casts by speaking. /// </summary> /// <param name="name">The name of the spell.</param> /// <param name="player">The player casting.</param> /// <returns></returns> public static Spell CreateSpell(string name, Player player) { string arg = GetArgument(name); Spell spell = new Spell(); name = GetSpellName(name); instantSpells[name.ToLower()].InitDelegate. Invoke(new object[] { arg, player, spell }); return spell; }
private void HandlePush(Player player, Position posFrom, ushort thingID, byte stackpos, Position posTo, byte count) { this.player = player; this.posFrom = posFrom; this.thingID = thingID; this.stackpos = stackpos; this.posTo = posTo; this.count = count; }
public void HandlePush(Player player, Position posFrom, ushort thingID, byte stackpos, Position posTo, byte count, Creature creatureMoved) { HandlePush(player, posFrom, thingID, stackpos, posTo, count); creatureToMove = creatureMoved; if (!creatureMoved.IsOfType(Constants.TYPE_MOVEABLE) || map.GetTile(posTo) == null) { return; } if (map.GetTile(posTo).ContainsType(Constants.TYPE_BLOCKS_AUTO_WALK) || !creatureToMove.IsNextTo(posTo) || !player.IsNextTo(posFrom)) { return; } world.HandleMove(creatureMoved, posTo, creatureToMove.CurrentDirection); }
public override void AppendHandlePush(Player player, Position posFrom, ushort thingID, byte stackpos, Position posTo, byte count, GameWorld world) { world.GetMovingSystem().HandlePush(player, posFrom, thingID, stackpos, posTo, count, this); }
/// <summary> /// Adds itself to the protocol specified via the parameters. /// Only to be used when sending map tiles. /// </summary> /// <param name="proto">The protocol to add to.</param> /// <param name="player">The player for whom the add is being done.</param> public override void AddItself(ProtocolSend proto, Player player) { bool knowsCreature = player.KnowsCreature(this); proto.AddTileCreature(this, knowsCreature); }
public abstract void AddStats(Player player);
public abstract void AddScreenMoveByOne(Direction direction, Position oldPos, Position newPos, Map map, Player player);
public abstract void AddSkills(Player player);
public abstract void AddScreenMap(Map map, Player player);
public abstract void AddLoginBytes(Player player, Map map);
public abstract void AddFullInventory(Player player);
/// <summary> /// Process a player's walk. /// </summary> /// <param name="player">The player doing the action.</param> /// <param name="world">A reference to the gameworld.</param> private void ProcessWalkSouth(Player player, GameWorld world) { world.HandleManualWalk(player, Direction.SOUTH); }
/// <summary> /// Remove a viewer, without appending/sending protocol information, /// from the contanier. /// </summary> /// <param name="player"></param> public void RemoveViewer(Player player) { viewers.Remove(player); }
/// <summary> /// Process a player's walk. /// </summary> /// <param name="player">The player doing the action.</param> /// <param name="world">A reference to the gameworld.</param> private void ProcessWalkWest(Player player, GameWorld world) { world.HandleManualWalk(player, Direction.WEST); }
/// <summary> /// Use the thing. /// </summary> /// <param name="user">The player using the thing.</param> public override void UseThing(Player user, GameWorld world) { user.OpenContainer(this); }
public override void AddFullInventory(Player player) { for (byte i = 1; i <= 10; i++) { //TODO: Fix hard codec constants if (player.GetInventoryItem(i) != null) { netmsg.AddByte(0x78); netmsg.AddByte(i); // AddItem(player.GetInventoryItem(i)[i], // player.gameServRef.gameMap.getItemDesc(player.inventory[i])); } else { netmsg.AddByte(0x79); netmsg.AddByte((byte)i); } } }
/// <summary> /// Gets detailed information about this container as a string. /// </summary> /// <returns>Detailed information.</returns> protected override string GetDetailedInformation(Player player) { return " (Vol:" + MaxCap + ")"; }
/// <summary> /// Sends the protocol data for adding itself to the ground. /// </summary> /// <param name="proto">A reference to the protocol.</param> /// <param name="player">The player for whom to add this to.</param> /// <param name="stackPos">The stack position of this thing.</param> public override void AddThisToGround(ProtocolSend proto, Player Player, Position pos, byte stackPos) { proto.AddScreenCreature(this, Player.KnowsCreature(this), pos, stackPos); }
/// <summary> /// Add a viewer, without appending/sending protocol information, /// to the container. /// </summary> /// <param name="player"></param> public void AddViewer(Player player) { viewers.Add(player); }
/// <summary> /// See GetThing()'s overloaded method. /// </summary> /// <param name="player"></param> /// <param name="?"></param> /// <param name="stackpos"></param> /// <returns></returns> public Thing GetThing(Player player, Position pos, byte stackpos) { return GetThing(player, pos, stackpos, false); }
/// <summary> /// Adds a single map tile. /// </summary> /// <param name="tile">Maptile to add.</param> /// <param name="player">Player for whom the map tile is being added.</param> private void AddMapTile(Tile tile, Player player) { if (tile != null) { foreach (Thing t in tile.GetThings()) { t.AddItself(this, player); } } }
/// <summary> /// Handle moving from a player. Note: This method is not thread-safe! /// </summary> /// <param name="player">The player moving the thing.</param> /// <param name="posFrom">The position where the thing current is.</param> /// <param name="thingID">The thing's id.</param> /// <param name="stackpos">The thing's stackpos.</param> /// <param name="posTo">The new position to place the item.</param> /// <param name="count">How much of the thing to move, if applicable.</param> public void HandlePush(Player player, Position posFrom, ushort thingID, byte stackpos, Position posTo, byte count, Item itemMoved) { HandlePush(player, posFrom, thingID, stackpos, posTo, count); itemToMove = itemMoved; //TODO: Finish validating moves... if (!IsItemMoveValid()) { return; } HandleItemMove(); }
//public abstract bool ProcessNextMessage(Player player, GameWorld world); /// <summary> /// Stars listening asynchronously and handles the messages as needed. /// </summary> public virtual void StartReceiving(GameWorld world, Player player) { }
public override string GetLookAt(Player player) { //TODO: Handle article return base.GetLookAt(player) + Name.ToLower() + "."; }
public static Spell CreateRuneSpell(string name, Player player, Position pos) { Spell spell = new Spell(); otherSpells[name.ToLower()].InitDelegate.Invoke (new object[] { name, player, pos, spell }); return spell; }