Beispiel #1
0
        /// <summary>
        /// Stops all stats accumulated from this point on from counting
        /// </summary>
        public void suspendStats()
        {
            _suspStats = new Data.PlayerStats(_stats);

            _suspInventory = _inventory;
            _inventory     = new Dictionary <int, InventoryItem>();

            foreach (InventoryItem ii in _suspInventory.Values)
            {
                InventoryItem nii = new InventoryItem();

                nii.item     = ii.item;
                nii.quantity = ii.quantity;

                _inventory.Add(nii.item.id, nii);
            }

            _suspSkills = _skills;
            _skills     = new Dictionary <int, SkillItem>();

            foreach (SkillItem si in _suspSkills.Values)
            {
                SkillItem nsi = new SkillItem();

                nsi.skill    = si.skill;
                nsi.quantity = si.quantity;

                _skills.Add(nsi.skill.SkillId, nsi);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Deserializes the data present in the packet contents into data fields in the class.
        /// </summary>
        public override void Deserialize()
        {
            player.id    = _contentReader.ReadUInt16();
            player.magic = _contentReader.ReadInt32();

            stats = PlayerStats.Deserialize(_contentReader);
        }
Beispiel #3
0
        /// <summary>
        /// Updates the players score
        /// </summary>
        private void updateTickers()
        {
            int    kills  = 0;
            int    deaths = 0;
            string format = "";

            //1st and 2nd place
            List <Player> ranked = new List <Player>();

            foreach (Player p in _arena.Players)
            {
                if (p == null)
                {
                    continue;
                }
                if (p.StatsCurrentGame == null)
                {
                    continue;
                }
                ranked.Add(p);
            }
            //Order by placed kills
            IEnumerable <Player> ranking = ranked.OrderByDescending(player => player.StatsCurrentGame.kills);
            int idx = 3;

            foreach (Player rankers in ranking)
            {
                if (idx-- == 0)
                {
                    break;
                }
                Data.PlayerStats current = rankers.StatsCurrentGame;
                switch (idx)
                {
                case 2:
                    format = String.Format("1st: {0}(K={1} D={2})", rankers._alias, current.kills, current.deaths);
                    break;

                case 1:
                    format = (format + String.Format(" 2nd: {0}(K={1} D={2})", rankers._alias, current.kills, current.deaths));
                    break;
                }
            }
            _arena.setTicker(0, 2, 0, format);

            //Personal scores
            _arena.setTicker(2, 3, 0, delegate(Player p)
            {
                if (p.StatsCurrentGame != null)
                {
                    kills  = p.StatsCurrentGame.kills;
                    deaths = p.StatsCurrentGame.deaths;
                }
                //Update their ticker
                return(String.Format("HP={0}          Personal Score: Kills={1} - Deaths={2}", p._state.health, kills, deaths));
            });
        }
Beispiel #4
0
        ///////////////////////////////////////////////////
        // Member Functions
        //////////////////////////////////////////////////
        /// <summary>
        /// Creates an empty packet of the specified type. This is used
        /// for constructing new packets for sending.
        /// </summary>
        public SC_PlayerLogin()
            : base(TypeID)
        {
            stats  = new InfServer.Data.PlayerStats();
            player = new PlayerInstance();

            alias        = "";
            loginMessage = "";
            squad        = "";
        }
Beispiel #5
0
        /// <summary>
        /// Deserializes the data present in the packet contents into data fields in the class.
        /// </summary>
        public override void Deserialize()
        {
            player.id    = _contentReader.ReadUInt16();
            player.magic = _contentReader.ReadInt32();

            stats     = PlayerStats.Deserialize(_contentReader);
            scoreType = (ScoreType)_contentReader.ReadByte();
            time      = _contentReader.ReadInt64();
            //Lets convert our ticks to a date
            date = new DateTime(time);
        }
Beispiel #6
0
        /// <summary>
        /// Serializes the data stored in the packet class into a byte array ready for sending.
        /// </summary>
        public override void Serialize()
        {               //Just need the id
            Write((byte)TypeID);

            Write((byte)type);
            Write(columns, 128);

            if (data != null)
            {
                Write(data);
                return;
            }

            int idx = 0;

            Data.PlayerStats stats = dataFunc(idx);

            while (stats != null)
            {
                Player p = playerFunc(idx++);

                Write(p._alias, 0);
                Write((p._squad != null ? p._squad : ""), 0);

                Write((short)2);
                Write(stats.vehicleDeaths);
                Write(stats.vehicleKills);
                Write(stats.killPoints);
                Write(stats.deathPoints);
                Write(stats.assistPoints);
                Write(stats.bonusPoints);
                Write(stats.kills);
                Write(stats.deaths);
                Write((int)0);
                Write(stats.playSeconds);
                Write(stats.zonestat1);
                Write(stats.zonestat2);
                Write(stats.zonestat3);
                Write(stats.zonestat4);
                Write(stats.zonestat5);
                Write(stats.zonestat6);
                Write(stats.zonestat7);
                Write(stats.zonestat8);
                Write(stats.zonestat9);
                Write(stats.zonestat10);
                Write(stats.zonestat11);
                Write(stats.zonestat12);

                stats = dataFunc(idx);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Restores the suspended stats
        /// </summary>
        public void restoreStats()
        {               //Restore it all!
            //Sanity checks
            if (_suspStats == null)
            {
                return;
            }

            //Retrieve his stats
            _stats         = _suspStats;
            _statsSession  = new Data.PlayerStats();
            _statsGame     = (_statsLastGame == null) ? new InfServer.Data.PlayerStats() : _statsLastGame;
            _statsLastGame = null;

            _inventory = _suspInventory;
            _skills    = _suspSkills;

            //Destroy suspended stats
            _suspStats     = null;
            _suspInventory = null;
            _suspSkills    = null;
        }
Beispiel #8
0
        /// <summary>
        /// Deserializes the data present in the packet contents into data fields in the class.
        /// </summary>
        public override void Deserialize()
        {
            player.id    = _contentReader.ReadUInt16();
            player.magic = _contentReader.ReadInt32();
            alias        = ReadNullString();

            bNewAlias    = _contentReader.ReadBoolean();
            bSuccess     = _contentReader.ReadBoolean();
            loginMessage = ReadNullString();

            //If login failed, there's no need to read further
            if (!bSuccess)
            {
                return;
            }

            squad      = ReadNullString();
            squadID    = _contentReader.ReadInt64();
            permission = (InfServer.Data.PlayerPermission)_contentReader.ReadByte();
            developer  = _contentReader.ReadBoolean();
            admin      = _contentReader.ReadBoolean();

            bFirstTimeSetup = _contentReader.ReadBoolean();

            //If it's a first time, then no need to init rest of the stats
            if (bFirstTimeSetup)
            {
                return;
            }

            stats = PlayerStats.Deserialize(_contentReader);

            bool bBanner = _contentReader.ReadBoolean();

            if (bBanner)
            {
                banner = _contentReader.ReadBytes(432);
            }
        }
Beispiel #9
0
 /// <summary>
 /// Clears the player's stats for the current game
 /// </summary>
 public void clearCurrentStats()
 {
     _statsGame = new InfServer.Data.PlayerStats();
 }
Beispiel #10
0
 ///////////////////////////////////////////////////
 // Member functions
 ///////////////////////////////////////////////////
 /// <summary>
 /// Causes the player's current game stats to be considered last game, and last game deprecated
 /// </summary>
 public void migrateStats()
 {
     _statsLastGame = (_statsGame == null) ? new InfServer.Data.PlayerStats() : _statsGame;
     _statsGame     = new InfServer.Data.PlayerStats();
 }
Beispiel #11
0
 /// <summary>
 /// Wipes all of the players total statistics
 /// </summary>
 public void WipeStats()
 {
     _stats = new Data.PlayerStats();
 }
Beispiel #12
0
 /// <summary>
 /// Clears the player's stats for the current game
 /// </summary>
 public void clearCurrentStats()
 {
     _statsGame = new Data.PlayerStats();
 }