示例#1
0
 public void AddPlayer(Player playerToAdd)
 {
     if (!players.Contains(playerToAdd)) {
         playerToAdd.ResetNetMessages();
         players.Add(playerToAdd);
     }
 }
示例#2
0
        /// <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;
        }
示例#3
0
 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();
 }
示例#4
0
        /// <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);
        }
示例#5
0
 /// <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);
 }
示例#6
0
 /// <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;
 }
示例#7
0
 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;
 }
示例#8
0
 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);
 }
示例#9
0
 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);
 }
示例#10
0
 /// <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);
 }
示例#11
0
 public abstract void AddStats(Player player);
示例#12
0
 public abstract void AddScreenMoveByOne(Direction direction, Position oldPos,
     Position newPos, Map map, Player player);
示例#13
0
 public abstract void AddSkills(Player player);
示例#14
0
 public abstract void AddScreenMap(Map map, Player player);
示例#15
0
 public abstract void AddLoginBytes(Player player, Map map);
示例#16
0
 public abstract void AddFullInventory(Player player);
示例#17
0
 /// <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);
 }
示例#18
0
 /// <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);
 }
示例#19
0
 /// <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);
 }
示例#20
0
 /// <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);
 }
示例#21
0
 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);
         }
     }
 }
示例#22
0
 /// <summary>
 /// Gets detailed information about this container as a string.
 /// </summary>
 /// <returns>Detailed information.</returns>
 protected override string GetDetailedInformation(Player player)
 {
     return " (Vol:" + MaxCap + ")";
 }
示例#23
0
 /// <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);
 }
示例#24
0
 /// <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);
 }
示例#25
0
 /// <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);
 }
示例#26
0
 /// <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);
         }
     }
 }
示例#27
0
        /// <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();
        }
示例#28
0
 //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)
 {
 }
示例#29
0
 public override string GetLookAt(Player player)
 {
     //TODO: Handle article
     return base.GetLookAt(player) + Name.ToLower() + ".";
 }
示例#30
0
 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;
 }