Represents a Local player that is identified in the game session
Esempio n. 1
0
 /// <summary>
 /// Raised when a player joined the Session
 /// </summary>
 /// <param name="identifiedPlayer"></param>
 protected virtual void OnPlayerJoined(IdentifiedPlayer identifiedPlayer)
 {
     if (PlayerJoined != null)
     {
         PlayerJoined(this, new IdentifiedPlayerEventArgs(identifiedPlayer));
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Raised when a player left the Session
 /// </summary>
 /// <param name="identifiedPlayer"></param>
 protected virtual void OnPlayerLeft(IdentifiedPlayer identifiedPlayer)
 {
     if (PlayerLeft != null)
     {
         PlayerLeft(this, new IdentifiedPlayerEventArgs(identifiedPlayer));
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Raised when a Player is identified
        /// </summary>
        public void OnPlayerLogin(IdentifiedPlayer identifiedPlayer)
        {
            identifiedPlayer.LogicalPlayerIndex = GetNextFreeLogicalPlayerIndex();
            LogicalPlayers.Add(identifiedPlayer.LogicalPlayerIndex, identifiedPlayer);

            if (PlayerLogin != null)
            {
                PlayerLogin(this, new IdentifiedPlayerEventArgs(identifiedPlayer));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Raised when a Player logs off
        /// </summary>
        public void OnPlayerLogoff(IdentifiedPlayer identifiedPlayer)
        {
            LogicalPlayers.Remove(identifiedPlayer.LogicalPlayerIndex);

            if (PlayerLogoff != null)
            {
                PlayerLogoff(this, new IdentifiedPlayerEventArgs(identifiedPlayer));
            }

            identifiedPlayer.LogicalPlayerIndex = LogicalPlayerIndex.None;
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a new PlayerAgent
        /// </summary>
        /// <param name="identifiedPlayer">The identified player instance</param>
        public T CreatePlayerAgent <T>(IdentifiedPlayer identifiedPlayer) where T : PlayerAgent, new()
        {
            if (Status != SessionState.Starting && Status != SessionState.Playing)
            {
                throw new CoreException("Session must be started to create a PlayerAgent");
            }

            var playerAgent = new T {
                IdentifiedPlayer = identifiedPlayer
            };

            _playerAgents.Add(playerAgent);

            return(playerAgent);
        }
Esempio n. 6
0
        /// <summary>
        /// Raised when a Player logs off
        /// </summary>
        public void OnPlayerLogoff(IdentifiedPlayer identifiedPlayer)
        {
            LogicalPlayers.Remove(identifiedPlayer.LogicalPlayerIndex);

            if (PlayerLogoff != null)
                PlayerLogoff(this, new IdentifiedPlayerEventArgs(identifiedPlayer));

            identifiedPlayer.LogicalPlayerIndex = LogicalPlayerIndex.None;
        }
Esempio n. 7
0
        /// <summary>
        /// Raised when a Player is identified
        /// </summary>
        public void OnPlayerLogin(IdentifiedPlayer identifiedPlayer)
        {
            identifiedPlayer.LogicalPlayerIndex = GetNextFreeLogicalPlayerIndex();
            LogicalPlayers.Add(identifiedPlayer.LogicalPlayerIndex, identifiedPlayer);

            if (PlayerLogin != null)
                PlayerLogin(this, new IdentifiedPlayerEventArgs(identifiedPlayer));
        }
Esempio n. 8
0
        /// <summary>
        /// Raised when a player joins the session
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnLivePlayerJoined(object sender, GamerJoinedEventArgs e)
        {
            IdentifiedPlayer identifiedPlayer = null;

            if (e.Gamer.IsLocal)
            {
                var localNetworkGamer = (LocalNetworkGamer) e.Gamer;

                IdentifiedPlayer[] localPlayersArray = new IdentifiedPlayer[SessionManager.LocalPlayers.Count];
                SessionManager.LocalPlayers.Values.CopyTo(localPlayersArray, 0);
                
                for (int i = 0; i < localPlayersArray.Length; i++)
                {
                    var localPlayer = localPlayersArray[i];

                    if (localPlayer.UniqueId == e.Gamer.Gamertag)
                    {
                        identifiedPlayer = new LiveIdentifiedPlayer(localPlayer.Input, localNetworkGamer);
                        _localPlayers.Add(identifiedPlayer);
                        _allPlayers.Add(identifiedPlayer);
                        break;
                    }
                }
            }
            else
            {
                NetworkGamer networkGamer = e.Gamer;
                identifiedPlayer = new LiveIdentifiedPlayer(networkGamer);
                _remotePlayers.Add(identifiedPlayer);
                _allPlayers.Add(identifiedPlayer);
            }

            OnPlayerJoined(identifiedPlayer);
        }
Esempio n. 9
0
 /// <summary>
 /// Creates a new instance
 /// </summary>
 /// <param name="identifiedPlayer">The identified player</param>
 public IdentifiedPlayerEventArgs(IdentifiedPlayer identifiedPlayer)
 {
     IdentifiedPlayer = identifiedPlayer;
 }
Esempio n. 10
0
 /// <summary>
 /// Creates a new instance
 /// </summary>
 /// <param name="identifiedPlayer">The identified player</param>
 public IdentifiedPlayerEventArgs(IdentifiedPlayer identifiedPlayer)
 {
     IdentifiedPlayer = identifiedPlayer;
 }
Esempio n. 11
0
 /// <summary>
 /// Creates a new PlayerAgent
 /// </summary>
 /// <param name="identifiedPlayer">The identified player instance</param>
 public PlayerAgent CreatePlayerAgent(IdentifiedPlayer identifiedPlayer)
 {
     return(CreatePlayerAgent <PlayerAgent>(identifiedPlayer));
 }