Example #1
0
 /// <summary>
 /// Constructs this object.
 /// </summary>
 /// <param name="proto">The protocol used to 
 /// communicate to the player with.</param>
 public Player(ProtocolSend proto)
 {
     protocolS = proto;
     lockThis = new Object();
     SpellLightLevel = 0x01;
     Level = 1;
     CurrentCapacity = 410;
     CurrentMana = 410;
     MagicLevel = 1;
     Experience = 0;
     InitializeAdvanceFactors();
     InitializeRegeneration();
     skills = new byte[Constants.SKILL_MAX];
     skillTries = new uint[Constants.SKILL_MAX];
     for (int i = 0; i < Constants.SKILL_MAX; i++) {
         skills[i] = 10;
         skillTries[i] = 0;
     }
     inventory = new Item[Constants.INV_MAX];
     for (int i = 0; i < Constants.INV_MAX; i++) {
         inventory[i] = null;
     }
     CurrentFightMode = FightMode.NORMAL;
     knownCreatures = new Queue<uint>();
     openContainers = new Container[Constants.MAX_CONTAINERS];
     AddType(Constants.TYPE_MOVEABLE);
     ManaShield = false;
     BaseSpeed = 220;
 }
Example #2
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);
 }
Example #3
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);
 }
Example #4
0
 /// <summary>
 /// Adds itself to the specified protocol.
 /// </summary>
 /// <remarks>This add is only called for map tiles and therefore,
 /// it only needs to know how to add itself to maptiles.</remarks>
 /// <param name="proto">The protocol to add itself to.</param>
 /// <param name="player">The player for whom to add.</param>
 public override void AddItself(ProtocolSend proto, Player player)
 {
     proto.AddGroundItem(this);
 }
Example #5
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.AddItem(pos, this, stackPos);
 }
Example #6
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);
        }
Example #7
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);
 }
Example #8
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.AddItem(pos, this, stackPos);
 }
Example #9
0
 /// <summary>
 /// Adds itself to the specified protocol.
 /// </summary>
 /// <remarks>This add is only called for map tiles and therefore,
 /// it only needs to know how to add itself to maptiles.</remarks>
 /// <param name="proto">The protocol to add itself to.</param>
 /// <param name="player">The player for whom to add.</param>
 public override void AddItself(ProtocolSend proto, Player player)
 {
     proto.AddGroundItem(this);
 }
Example #10
0
        private void HandlePlayerConnection(Socket socket, ProtocolReceive protocolReceive, ProtocolSend protocolSend)
        {
            LoginInfo playerLogin = protocolReceive.HandlePlayerLogin(socket);
            GameWorld localWorld = world;
            #if DEBUG
            // TODO: Write message here ("Logging in (name/password-hash)...")
            #endif
            // TODO: Kick current player and let this one log in
            if (localWorld.IsPlayerOnline(playerLogin.GetUsername()))
            {
                protocolSend.Reset();
                protocolSend.AddSorryBox("A player with this name is already online.");
                protocolSend.MarkSocketAsClosed();
                protocolSend.WriteToSocket();
            #if DEBUG
                // TODO: Write message here ("Player is already online")
            #endif
                return;
            }

            Player player = new Player(protocolSend);

            if (!player.LoadPlayer(playerLogin))
            {
                protocolSend.Reset();
                protocolSend.AddSorryBox("A player with this name is already online.");
                protocolSend.MarkSocketAsClosed();
                protocolSend.WriteToSocket();
            #if DEBUG
                // TODO: Write message here ("Invalid username or password.")
            #endif
                return;
            }

            localWorld.SendAddPlayer(player, player.CurrentPosition);
            protocolReceive.StartReceiving(world, player);
            #if DEBUG
            // TODO: Write message here ("Logged in (name)")
            #endif
            // TODO?: Threading
            //new PlayerThread(player, localWorld, protoReceive).StartThread();
        }
Example #11
0
        private void HandlePlayerConnection(Socket socket, ProtocolReceive protocolReceive, ProtocolSend protocolSend)
        {
            LoginInfo playerLogin = protocolReceive.HandlePlayerLogin(socket);
            GameWorld localWorld  = world;

#if DEBUG
            // TODO: Write message here ("Logging in (name/password-hash)...")
#endif
            // TODO: Kick current player and let this one log in
            if (localWorld.IsPlayerOnline(playerLogin.GetUsername()))
            {
                protocolSend.Reset();
                protocolSend.AddSorryBox("A player with this name is already online.");
                protocolSend.MarkSocketAsClosed();
                protocolSend.WriteToSocket();
#if DEBUG
                // TODO: Write message here ("Player is already online")
#endif
                return;
            }

            Player player = new Player(protocolSend);

            if (!player.LoadPlayer(playerLogin))
            {
                protocolSend.Reset();
                protocolSend.AddSorryBox("A player with this name is already online.");
                protocolSend.MarkSocketAsClosed();
                protocolSend.WriteToSocket();
#if DEBUG
                // TODO: Write message here ("Invalid username or password.")
#endif
                return;
            }

            localWorld.SendAddPlayer(player, player.CurrentPosition);
            protocolReceive.StartReceiving(world, player);
#if DEBUG
            // TODO: Write message here ("Logged in (name)")
#endif
            // TODO?: Threading
            //new PlayerThread(player, localWorld, protoReceive).StartThread();
        }
Example #12
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 abstract void AddItself(ProtocolSend proto, Player player);
Example #13
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 abstract void AddThisToGround(ProtocolSend proto,
                                      Player player, Position pos, byte stackPos);