Indiefreaks.Xna.Sessions.SessionManager.GetNextFreeLogicalPlayerIndex C# (CSharp) Method

GetNextFreeLogicalPlayerIndex() protected static method

protected static GetNextFreeLogicalPlayerIndex ( ) : LogicalPlayerIndex
return LogicalPlayerIndex
        protected static LogicalPlayerIndex GetNextFreeLogicalPlayerIndex()
        {
            LogicalPlayerIndex nextLogicalPlayerIndex;
            if (!LogicalPlayers.ContainsKey(LogicalPlayerIndex.One))
                nextLogicalPlayerIndex = LogicalPlayerIndex.One;
            else if (!LogicalPlayers.ContainsKey(LogicalPlayerIndex.Two))
                nextLogicalPlayerIndex = LogicalPlayerIndex.Two;
            else if (!LogicalPlayers.ContainsKey(LogicalPlayerIndex.Three))
                nextLogicalPlayerIndex = LogicalPlayerIndex.Three;
            else if (!LogicalPlayers.ContainsKey(LogicalPlayerIndex.Four))
                nextLogicalPlayerIndex = LogicalPlayerIndex.Four;
            else
                nextLogicalPlayerIndex = LogicalPlayerIndex.None;

            if (nextLogicalPlayerIndex == LogicalPlayerIndex.None)
                throw new CoreException("Too many players!");

            return nextLogicalPlayerIndex;
        }