示例#1
0
        /// <summary>
        /// Sends back ssplayer using ChatEvent. Updates modlvl too.
        /// </summary>
        /// <param name="e">Player Name</param>
        /// <returns>SSPlayer with all updated info</returns>
        public SSPlayer GetPlayer(ChatEvent e)
        {
            SSPlayer ssp = GetPlayer(e.PlayerName);

            ssp.ModLevel = e.ModLevel;
            return(ssp);
        }
示例#2
0
        public void RefreshDisplay_Player(SSPlayer Player)
        {
            List <ushort> AllLvz = new List <ushort>();

            foreach (ushort[] ids in this.m_ScoreBoards.Values)
            {
                foreach (ushort id in ids)
                {
                    AllLvz.Add(id);
                }
            }

            foreach (ushort id in this.m_SingleImages.Values)
            {
                AllLvz.Add(id);
            }

            Dictionary <ushort, bool> update = new Dictionary <ushort, bool>();

            foreach (ushort id in AllLvz)
            {
                bool result;
                update[id] = this.m_PubDisplay.TryGetValue(id, out result) ? result : false;

                if (update.Count >= m_UpdateLimit)
                {
                    this.sendUpdate(Player.PlayerId, update);
                    update = new Dictionary <ushort, bool>();
                }
            }
            this.sendUpdate(Player.PlayerId, update);
        }
示例#3
0
        /// <summary>
        /// This sends the needed packet out to change lvz.
        /// This should be sent after you ave finished modifying the display.
        /// Example: Update Points, Update Currency, etc ... Then Refresh Display.
        /// </summary>
        /// <param name="ssp"></param>
        /// <param name="q"></param>
        public void RefreshDisplay_Priv(SSPlayer ssp)
        {
            // List of lvz to update
            Dictionary <ushort, bool> updateList = new Dictionary <ushort, bool>();

            // Itirate through entire list
            foreach (ushort id in ssp.Display.Keys)
            {
                // Check if lvz needs updating
                if (ssp.Display[id] != ssp.Display_Old[id])
                {
                    // add update to list
                    updateList.Add(id, ssp.Display[id]);
                    // update the users old display
                    ssp.Display_Old[id] = !ssp.Display_Old[id];
                }
            }

            // Pack the event into q
            if (updateList.Count > 0)
            {
                LVZToggleEvent update = new LVZToggleEvent();
                update.TargetPlayerId = ssp.PlayerId;
                update.LVZObjects     = updateList;
                psyGame.Send(update);
            }
        }
示例#4
0
        /// <summary>
        /// Creates and stores player using the PlayerEnteredEvent.
        /// </summary>
        /// <param name="e">Player Name</param>
        /// <returns>SSPlayer with all updated info</returns>
        public SSPlayer GetPlayer(PlayerEnteredEvent e)
        {
            // Grab player - most likely not on list but a new will be created
            SSPlayer ssp = GetPlayer(e.PlayerName);

            // update all info using player entered
            ssp.PlayerEntered = e;
            //return it
            return(ssp);
        }
示例#5
0
        public void LoadSingleDisplay_Priv(string DisplayName, SSPlayer ssp)
        {
            ushort lvzid;

            if (m_SingleDisplayList.TryGetValue(DisplayName, out lvzid))
            {
                // if lvz isnt already included it will add it here
                ssp.Display[lvzid]     = false;
                ssp.Display_Old[lvzid] = false;
            }
        }
示例#6
0
        /// <summary>
        /// <para>Sends back ssplayer using the PlayerPositionEvent.</para>
        /// </summary>
        /// <param name="e">Player Name</param>
        /// <returns>SSPlayer with all updated info</returns>
        public SSPlayer GetPlayer(PlayerPositionEvent e)
        {
            // Grab player info
            SSPlayer ssp = GetPlayer(e.PlayerName);

            ssp.ModLevel = e.ModLevel;
            // Update PlayerPosition
            ssp.Position = e;
            //return info
            return(ssp);
        }
示例#7
0
        /// <summary>
        /// This will load a Scoreboard to a users profile so we can check update lvz as they are toggled.
        /// Add/Remove them as status changes.
        /// </summary>
        /// <param name="ssp">Player Profile</param>
        /// <param name="listname">Name of Lvz set to be loaded</param>
        /// <param name="q">Chat Q so we can add the lvz toggle commands.</param>
        public void LoadScoreboard_Priv(SSPlayer ssp, string listname)
        {
            ushort[] lvzList;

            if (m_ScoreBoardList.TryGetValue(listname, out lvzList))
            {
                for (int i = 0; i < lvzList.Length; i += 1)
                {
                    ssp.Display.Add(lvzList[i], false);
                    ssp.Display_Old.Add(lvzList[i], false);
                }
            }
        }
示例#8
0
 // Change of score
 public void ScoreChange_Player(string BoardName, int NewScore, SSPlayer Player)
 {
     // Container for lvz ids contained in our master list of scoreboards
     ushort[] LvzList;
     // Grab the list from our master list
     if (m_ScoreBoards.TryGetValue(BoardName, out LvzList))
     {
         // Use public as display to target, do scorechange
         this.scoreChange(NewScore, LvzList, Player.Display);
         return;
     }
     psyGame.SafeSend(msg.debugChan("[ Display Manager ] A scorechange attempted on an unregistered (private) Scoreboard. Scoreboard = [ " + BoardName + " ]"));
 }
示例#9
0
        /// <summary>
        /// <para>Send a private team message using freq number with attached sound code.</para>
        /// <para>YOU MUST SEND A PLAYER LIST ON INITIALIZATION FOR THIS TO WORK</para>
        /// </summary>
        /// <param name="Frequency">Freq number to send message to</param>
        /// <param name="Message">Message to send</param>
        /// <returns>Returns Configured ChatEvent</returns>
        public ChatEvent team_pm(ushort Frequency, string Message, SoundCodes SoundCode)
        {
            if (m_PlayerList == null)
            {
                return(null);
            }
            SSPlayer ssp = m_PlayerList.Find(player => player.Frequency == Frequency);

            if (ssp == null)
            {
                return(null);
            }
            return(team_pm(ssp.PlayerName, Message, SoundCode));
        }
示例#10
0
        // Grab player from list. If not in list create a player and put into list
        public SSPlayer GetPlayer(string PlayerName)
        {
            SSPlayer ssp = m_PlayerList.Find(player => player.PlayerName == PlayerName);

            if (ssp != null)
            {
                return(ssp);
            }

            ssp            = new SSPlayer();
            ssp.PlayerName = PlayerName;
            m_PlayerList.Add(ssp);

            return(m_PlayerList.Find(player => player.PlayerName == PlayerName));
        }
示例#11
0
        /// <summary>
        /// This will unload a display from a users profile.
        /// </summary>
        /// <param name="ssp">Player Profile</param>
        /// <param name="listname">Name of Lvz set to be loaded</param>
        /// <param name="q">Chat Q so we can add the lvz toggle commands.</param>
        public void UnloadScoreboard_Priv(SSPlayer ssp, string listname)
        {
            ushort[] lvzList;

            if (m_ScoreBoardList.TryGetValue(listname, out lvzList))
            {
                for (int i = 0; i < lvzList.Length; i += 1)
                {
                    if (ssp.Display.ContainsKey(lvzList[i]))
                    {
                        ssp.Display.Remove(lvzList[i]);
                        ssp.Display_Old.Remove(lvzList[i]);
                    }
                }
            }
        }
示例#12
0
        /// <summary>
        /// Sends back ssplayer using the TeamChangeEvent.
        /// </summary>
        /// <param name="e">Player Name</param>
        /// <returns>SSPlayer with all updated info</returns>
        public SSPlayer GetPlayer(TeamChangeEvent e)
        {
            // Grab player
            SSPlayer ssp = GetPlayer(e.PlayerName);

            ssp.ModLevel = e.ModLevel;
            // Update old ship to new ship if its not a spec event
            if ((DateTime.Now - ssp.SCTimeStamp).TotalMilliseconds > 20)
            {
                ssp.OldShip = ssp.Ship;
            }
            // Update player freq info
            ssp.OldFrequency = ssp.Frequency;
            ssp.Frequency    = e.Frequency;
            // send it back
            return(ssp);
        }
示例#13
0
        /// <summary>
        /// <para>Sends back ssplayer using the ShipChangeEvent.</para>
        /// </summary>
        /// <param name="e">Player Name</param>
        /// <returns>SSPlayer with all updated info</returns>
        public SSPlayer GetPlayer(ShipChangeEvent e)
        {
            // Grab player info
            SSPlayer ssp = GetPlayer(e.PlayerName);

            ssp.ModLevel = e.ModLevel;
            // Update sc timestamp
            ssp.SCTimeStamp = DateTime.Now;
            // Special case update for freq
            if (ssp.Frequency != m_SpecFreq)
            {
                ssp.OldFrequency = ssp.Frequency;
            }
            // Ship updates
            ssp.OldShip = e.PreviousShipType;
            ssp.Ship    = e.ShipType;
            //return info
            return(ssp);
        }
示例#14
0
        // Not sure if i need 2 methods yet - making this one just in case - may combine later
        public void ScoreChange_Priv(SSPlayer ssp, string listname, int newscore)
        {
            // Container for lvz ids contained in our master list of of scoreboards
            ushort[] alldisplaylvz;
            // Grab the list from our master list
            if (m_ScoreBoardList.TryGetValue(listname, out alldisplaylvz))
            {
                // Holds the individual digits
                List <int> listOfInts = new List <int>();
                // Holds the digits converted into lvz ids
                List <ushort> newscoreids = new List <ushort>();

                // Splits the score up into individual digits
                // and inverts them so we can start converting into
                //lvz starting with ones,tens,hund...
                while (newscore > 0)
                {
                    listOfInts.Add(newscore % 10);
                    newscore = newscore / 10;
                }

                // We grab lvzList[0] and use it for our start index of lvz
                // and use it to convert to lvz from that point
                for (int i = 0; i < listOfInts.Count; i += 1)
                {
                    newscoreids.Add((ushort)(alldisplaylvz[0] + (10 * i) + listOfInts[i]));
                }

                // First we toggle all lvz off
                for (int i = 0; i < alldisplaylvz.Length; i += 1)
                {
                    ssp.Display[alldisplaylvz[i]] = false;
                }

                // Then we turn on the lvz for our new score
                for (int i = 0; i < newscoreids.Count; i += 1)
                {
                    ssp.Display[newscoreids[i]] = true;
                }
            }
        }
示例#15
0
 //--------------------------------//
 //              Player            //
 //--------------------------------//
 /// <summary>
 /// <para>Loads a scoreboard the the player's private display.</para>
 /// <para>The scoreboard MUST be registered before you try to load it.</para>
 /// <para>Use RegisterScoreBoard() to do so.</para>
 /// </summary>
 /// <param name="BoardName">The name the SB was registered with. Example:  LoadScoreBoard_Player("KillsSB", SSPlayer)</param>
 /// <param name="Player">SSPlayer that needs SB load.</param>
 public void LoadScoreBoard_Player(string BoardName, SSPlayer Player)
 {
     this.loadScoreBoard(BoardName, Player.Display, Player.Display_Old);
 }
示例#16
0
 private void updatePlayerDisplay(SSPlayer Player)
 {
     this.updateDisplay(Player.PlayerId, Player.Display, Player.Display_Old);
 }
示例#17
0
 /// <summary>
 /// <para>Use this after you getPlayer(PlayerLeftEvent) to delete from list.</para>
 /// <para>That way you can get all the necessary info from it before its deleted.</para>
 /// </summary>
 /// <param name="ssPlayer"></param>
 public void RemovePlayer(SSPlayer ssPlayer)
 {
     m_PlayerList.Remove(ssPlayer);
 }
示例#18
0
 public void UnloadScoreBoard_Player(string BoardName, SSPlayer Player)
 {
     this.unloadScoreBoard(Player.PlayerId, BoardName, Player.Display, Player.Display_Old);
 }