void CurrentSession_GamerJoined(object sender, GamerJoinedEventArgs e)
        {
            if (Gamer.SignedInGamers[PlayerIndex.One].Privileges.AllowCommunication != GamerPrivilegeSetting.Everyone)
            {
                if (Gamer.SignedInGamers[PlayerIndex.One].Privileges.AllowCommunication == GamerPrivilegeSetting.Blocked || (Gamer.SignedInGamers[PlayerIndex.One].Privileges.AllowCommunication == GamerPrivilegeSetting.FriendsOnly && !Gamer.SignedInGamers[PlayerIndex.One].IsFriend(e.Gamer)))
                {
                    StateManager.NetworkData.CurrentSession.LocalGamers[0].EnableSendVoice(e.Gamer, false);
                }

            }

            GamerInfos.Clear();
            for (int i = 0; i < StateManager.NetworkData.CurrentSession.MaxGamers; i++)
            {
                if (gamerInfos[i] != null)
                {
                    AdditionalSprites.Remove(gamerInfos[i]);
                }
                string text = "";
                bool visible = false;
                if (i < StateManager.NetworkData.CurrentSession.AllGamers.Count)
                {
                    if (StateManager.NetworkData.CurrentSession.AllGamers[i].IsLocal)
                    {
                        SelectedShips.Remove(StateManager.NetworkData.CurrentSession.AllGamers[i].Id);
                        SelectedShips.Add(StateManager.NetworkData.CurrentSession.AllGamers[i].Id, new ShipStats() { Type = StateManager.NetworkData.SelectedNetworkShip.Type, Tier = ShipTier.Tier2 });
                        if (SelectedShips[StateManager.NetworkData.CurrentSession.AllGamers[i].Id].Type == ShipType.NoShip)
                        {
                            SelectedShips[StateManager.NetworkData.CurrentSession.AllGamers[i].Id] = new ShipStats() { Tier = ShipTier.NoShip, Type = ShipType.NoShip };
                        }
                    }
                    text = string.Format("{0} - {1}{2}{3}", StateManager.NetworkData.CurrentSession.AllGamers[i].Gamertag, StateManager.NetworkData.CurrentSession.AllGamers[i].IsLocal ? StateManager.NetworkData.SelectedNetworkShip.Type.ToFriendlyString() : "No ship", StateManager.NetworkData.CurrentSession.AllGamers[i].IsLocal ? StateManager.NetworkData.SelectedNetworkShip.Type == ShipType.NoShip ? "" : ", " : "", StateManager.NetworkData.CurrentSession.AllGamers[i].IsLocal ? StateManager.NetworkData.SelectedNetworkShip.Type == ShipType.NoShip ? "" : ShipTier.Tier2.ToFriendlyString().ToLower() : "");
                    visible = true;
                }
                TextSprite gamerInfo = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, text, Color.White);
                gamerInfo.Y = i == 0 ? title.Y + title.Height + 10 : gamerInfos[i - 1].Y + gamerInfos[i - 1].Height + 5;
                gamerInfo.X = gamerInfo.GetCenterPosition(Graphics.Viewport).X;
                gamerInfo.Visible = visible;
                AdditionalSprites.Add(gamerInfo);
                gamerInfos[i] = gamerInfo;
                if (i < StateManager.NetworkData.CurrentSession.AllGamers.Count)
                {
                    GamerInfos.Add(StateManager.NetworkData.CurrentSession.AllGamers[i].Id, gamerInfo);
                }
            }

            foreach (NetworkGamer ng in StateManager.NetworkData.CurrentSession.AllGamers)
            {
                if (!SelectedShips.ContainsKey(ng.Id))
                {
                    SelectedShips.Add(ng.Id, new ShipStats() { Type = ShipType.NoShip, Tier = ShipTier.NoShip });
                }
            }

            if (!e.Gamer.IsLocal)
            {
                StateManager.NetworkData.DataWriter.Write(StateManager.NetworkData.SelectedNetworkShip.Type.ToString());
                foreach (LocalNetworkGamer g in StateManager.NetworkData.CurrentSession.LocalGamers)
                {
                    g.SendData(StateManager.NetworkData.DataWriter, SendDataOptions.Reliable);
                }
            }
        }
Esempio n. 2
0
 void session_GamerJoined(object sender, GamerJoinedEventArgs p)
 {
     menu.AddComponent(new TextComponent(100, 100 * (session.AllGamers.Count + 1), p.Gamer.Gamertag, "KartsFont"));
 }
Esempio n. 3
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);
        }
 void GamerJoined(object sender, GamerJoinedEventArgs e)
 {
     // Gamer joined. Set the tag for the gamer to a new UserControlledSprite.
     // If the gamer is the host, create a chaser; if not, create a chased.
     if (e.Gamer.IsHost)
     {
         e.Gamer.Tag = CreateChasingSprite();
     }
     else
     {
         e.Gamer.Tag = CreateChasedSprite();
     }
 }
Esempio n. 5
0
 static void networkSession_GamerJoined(object sender, GamerJoinedEventArgs e)
 {
     GamerJoined(sender, e);
 }
Esempio n. 6
0
 void session_GamerJoined(object sender, GamerJoinedEventArgs p)
 {
     Console.Write("Gamer Joined: " + p.Gamer.Gamertag);
 }
Esempio n. 7
0
        /// <summary>
        /// This event handler will be called whenever a new gamer joins the session.
        /// We use it to allocate a Tank object, and associate it with the new gamer.
        /// </summary>
        void GamerJoinedEventHandler(object sender, GamerJoinedEventArgs e)
        {
            int gamerIndex = networkSession.AllGamers.IndexOf(e.Gamer);

            e.Gamer.Tag = new Player();
        }
Esempio n. 8
0
        void networkSession_GamerJoined(object sender, GamerJoinedEventArgs e)
        {
            //using .Tag property to store whos turn it is (Turn[1] is true)
            //Host gets White pieces and moves first

            e.Gamer.Tag = e.Gamer.IsHost ? Turn[1] : Turn[0];
        }
Esempio n. 9
0
        private void GamerJoinedEventHandler(object sender, GamerJoinedEventArgs e)
        {
            int gamerIndex = networkSession.AllGamers.IndexOf(e.Gamer);

            RemotePlayers.Add(new Being(this));
            RemotePlayers[RemotePlayers.Count - 1].camera.Position = Vector3.Zero;
            //e.Gamer.Tag = new Being(this);
        }
Esempio n. 10
0
 /// <summary>
 /// This event handler will be called whenever a new gamer joins the session.
 /// We use it to allocate a Ship object, and associate it with the new gamer.
 /// </summary>
 void GamerJoinedEventHandler(object sender, GamerJoinedEventArgs e)
 {
     //int gamerIndex = networkSession.AllGamers.IndexOf(e.Gamer);
     RacerType pType = RacerType.Remote;
     if (e.Gamer.IsLocal) pType = RacerType.LocalHuman;
     //TODO: uncomment this code and make it work//e.Gamer.Tag = Race.addPlayer(pType);
 }
Esempio n. 11
0
 void networkSession_GamerJoined(object sender, GamerJoinedEventArgs e)
 {
     if (!e.Gamer.IsLocal)
     {
         e.Gamer.Tag = new Player(Content, e.Gamer.Gamertag + e.Gamer.ToString());
     }
     else
     {
         e.Gamer.Tag = GetPlayer(e.Gamer.Gamertag, e.Gamer.Gamertag + e.Gamer.ToString());
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Handle a new player joining the session.
        /// </summary>
        void networkSession_GamerJoined(object sender, GamerJoinedEventArgs e)
        {
            // make sure the data exists for the new gamer
            for (int i = 0; i < networkSession.AllGamers.Count; i++)
            {
                if (networkSession.AllGamers[i] == e.Gamer)
                {
                    PlayerData playerData = new PlayerData();
                    e.Gamer.Tag = playerData;
                    playerData.ShipVariation = (byte)(i % 4);
                    playerData.ShipColor = (byte)i;
                }
            }

            // send my own data to the new gamer
            if ((networkSession.LocalGamers.Count > 0) && !e.Gamer.IsLocal)
            {
                PlayerData playerData = networkSession.LocalGamers[0].Tag as PlayerData;
                if (playerData != null)
                {
                    packetWriter.Write((int)World.PacketTypes.PlayerData);
                    playerData.Serialize(packetWriter);
                    networkSession.LocalGamers[0].SendData(packetWriter, 
                        SendDataOptions.ReliableInOrder, e.Gamer);
                }
            }
        }
Esempio n. 13
0
 void session_GamerJoined(object sender, GamerJoinedEventArgs e)
 {
     Screen playerList = allScreens["playerList"];
     Texture2D newGamerImage = new TextureFactory(GraphicsDevice).CreateSquare(64, Color.Red);
     try
     {
         newGamerImage = Texture2D.FromStream(GraphicsDevice, e.Gamer.GetProfile().GetGamerPicture());
     }
     catch { };
     Vector2 pos = new Vector2(100, 50);
     foreach (Sprite s in playerList.Sprites)
     {
         pos.Y += s.Height + 5;
     }
     Sprite gamerIcon = new Sprite(newGamerImage, pos, spriteBatch);
     playerList.Sprites.Add(gamerIcon);
     TextSprite gamerName = new TextSprite(spriteBatch, new Vector2(pos.X + gamerIcon.Width + 5, pos.Y), font, e.Gamer.Gamertag);
     allScreens["playerList"].AdditionalSprites.Add(gamerName);
     if (session.AllGamers.Count >= 2 && session.IsHost)
     {
         //TODO
         session.StartGame();
     }
 }
Esempio n. 14
0
        private void GamerJoined(object sender, GamerJoinedEventArgs e)
        {
            var gamer = e.Gamer;

            if(gamer.IsLocal)
            {
                return;
            }

            var player = new RemotePlayer(Game, gamer);
            gamer.Tag = player;
        }
Esempio n. 15
0
        /// <summary>
        /// Event handler called when a gamer joins the session.
        /// Displays a notification message.
        /// </summary>
        void GamerJoined(object sender, GamerJoinedEventArgs e)
        {
            if (e.Gamer != networkSession.LocalGamers[0])
            {
                networkHelper.ClientPacketWriter.Write('T');
                networkHelper.ClientPacketWriter.Write(localPlayer.TeamID);
                networkHelper.SendToAll(networkSession, networkHelper.ClientPacketWriter, SendDataOptions.ReliableInOrder);

            }
        }
Esempio n. 16
0
 /* Event handler for gamer joined; forward to the game if it's listening.
  */
 void session_GamerJoined(object sender, GamerJoinedEventArgs e)
 {
     Trace.WriteLine(String.Format("Gamer joined: {0}", e.Gamer.Gamertag));
       if (e.Gamer.IsLocal)
       {
     return;
       }
       if (session != null)
       {
     UpdateVoice();
     if (sessionType == SessionType.HighscoresOnly)
     {
       //  stay open for five minutes, or until the host kills it
       sessionCloseTime = Timing.NowTicks + 300 * 10000000L;
     }
     if (toSend.Count == 0 && storage.HasLoaded)
     {
       LoadHighscores();
     }
       }
       if (sessionType == SessionType.HighscoresAndGame ||
     sessionType == SessionType.HighscoresOnly)
       {
     if (e.Gamer is NetworkGamer)
     {
       NetworkGamer ng = e.Gamer as NetworkGamer;
       if (!ng.IsLocal)
       {
     joinedGamers.Add(e.Gamer, new JoinedGamer(ng));
       }
     }
       }
       if (GamerJoined != null)
       {
     gea.Gamer = e.Gamer;
     gea.Joined = true;
     GamerJoined(this, gea);
       }
 }
Esempio n. 17
0
 public static void Session_GamerJoined(object sender, GamerJoinedEventArgs args)
 {
     Console.WriteLine("Player:" + args.Gamer.Gamertag + " has joined the game.");
 }
Esempio n. 18
0
        /// <summary>
        /// Called when a gamer joins the game
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void session_GamerJoined(object sender, GamerJoinedEventArgs e)
        {
            Console.WriteLine("A new Gamer, " + e.Gamer.Gamertag + " has joined");
            if (gameMode == GameMode.Network_Multiplayer)
            {
                lob.AddPlayerToLobby(e.Gamer.Gamertag);
            }
            foreach (PlayerInfo info in activePlayers)
            {
                if (info.PlayerName == e.Gamer.Gamertag)
                    return;
            }

            PlayerInfo player = new PlayerInfo();
            bool result = player.GetPlayerInfoFromServer(e.Gamer.Gamertag, SERVER_IP, SERVER_PORT_NUM);
            if (!result)
            {
                player = new PlayerInfo();
                player.PlayerName = e.Gamer.Gamertag;
                player.Ammo_Level = 0;
                player.Armour_Level = 0;
                player.Money = 10;
                player.Speed_Level = 0;
                Console.WriteLine("Creating new profile");
                Console.WriteLine(player.ToString());
            }
            player.Player_Ship = AvailableShips[0];

            if (gameMode == GameMode.Network_Multiplayer && e.Gamer.Gamertag != SignedInGamer.SignedInGamers[0].Gamertag)
                player.PlayerLocation = Player_Location.Remote;
            else
                player.PlayerLocation = Player_Location.Local;

            activePlayers.Add(player);

            if (player.PlayerName == SignedInGamer.SignedInGamers[0].Gamertag)
            {
                playerIndex = activePlayers.Count - 1;
            }
        }
Esempio n. 19
0
 void session_GamerJoined(object sender, GamerJoinedEventArgs e)
 {
     if (e.Gamer.IsHost)
     {
         message = "The Host started the session!";
     }
     else
     {
         message = "Gamer " + e.Gamer.Tag + " joined the session!";
         // Other player joined, start the game!
         session.StartGame();
         gameStart = true;
     }
 }
Esempio n. 20
0
        void Session_GamerJoined(object sender, GamerJoinedEventArgs e)
        {
            Vector2 Pos = new Vector2(Map.MapSize / 2, Map.MapSize - 8);
            e.Gamer.Tag = new LivingEntity(Pos);

            if (!e.Gamer.IsHost)
            {
                packetWriter.Write((Int16)2);
                for (int i = 0; i < Map.MapSize; ++i)
                    for (int j = 0; j < Map.MapSize; ++j)
                        packetWriter.Write((Int16)game1.GameMap.MapArray[i, j]);
                try
                {
                    Session.LocalGamers[0].SendData(packetWriter, SendDataOptions.InOrder, e.Gamer);
                }
                catch (Exception ex)
                {   //why fail, why? I dont want to send it to everyone!
                    ex.ToString();
                }
            }
        }
Esempio n. 21
0
 void GamerJoinedEventHandler(object sender, GamerJoinedEventArgs e)
 {
     //new gamer, add tank object
     e.Gamer.Tag = new Tank(this);
     Components.Add(e.Gamer.Tag as Tank);
 }
Esempio n. 22
0
        void NetworkSession_GamerJoined( object p_Sender,
			GamerJoinedEventArgs p_Args )
        {
            if( !p_Args.Gamer.IsLocal )
            {
                System.Diagnostics.Debug.WriteLine( "Gamer: " +
                    p_Args.Gamer.Gamertag + " joined" );
            }
        }
 /// <summary>
 /// Event handler called when a gamer joins the session.
 /// Displays a notification message.
 /// </summary>
 void GamerJoined(object sender, GamerJoinedEventArgs e)
 {
     if (notifyWhenPlayersJoinOrLeave)
     {
         messageDisplay.ShowMessage(Resources.MessageGamerJoined,
                                    e.Gamer.Gamertag);
     }
 }
Esempio n. 24
0
 public void GamerJoinedEventHandler(object sender, GamerJoinedEventArgs e)
 {
     OnNewGamer(e.Gamer, GetGamerIndex(e.Gamer));
     //int gamerIndex = networkSession.AllGamers.IndexOf(e.Gamer);
     //e.Gamer.Tag = new Player();
 }
Esempio n. 25
0
 void networkSession_GamerJoined(object sender, GamerJoinedEventArgs e)
 {
     if (!e.Gamer.IsLocal)
     {
         e.Gamer.Tag = new Human(e.Gamer.Gamertag);
     }
     else
     {
         e.Gamer.Tag = GetHuman(e.Gamer.Gamertag);
     }
 }
Esempio n. 26
0
 /// <summary>
 /// This event handler will be called whenever a new gamer joins the session.
 /// </summary>
 protected void GamerJoinedEventHandler(object sender, GamerJoinedEventArgs e)
 {
     networkErrorMessage = "No logic for GamerJoinedEvent";
     //Do something with the new player
 }
Esempio n. 27
0
        /// <summary>
        /// Handles a player joining the game.  The new gamer should be sent 
        /// all the entity components it will need to synchonize with this 
        /// peer (i.e. all the components this peer has authority over)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void GamerJoinedEventHandler(object sender, GamerJoinedEventArgs e)
        {
            // We only need to update remote gamers - local ones will share
            // our local game state
            if (!e.Gamer.IsLocal)
            {
                // Send components for all entitys that we have authority over
                // (i.e. those with a local component)
                foreach (Local local in game.LocalComponent.All)
                {
                    // Send position
                    if (game.PositionComponent.Contains(local.EntityID))
                    {
                        Position position = game.PositionComponent[local.EntityID];
                        packetWriter.Write(position.EntityID);
                        packetWriter.Write((short)PacketTypes.Position);
                        packetWriter.Write(position.Center);
                        packetWriter.Write(position.Radius);
                    }

                    // Send sprite
                    if (game.SpriteComponent.Contains(local.EntityID))
                    {
                        Sprite sprite = game.SpriteComponent[local.EntityID];
                        packetWriter.Write(sprite.EntityID);
                        packetWriter.Write((short)PacketTypes.Sprite);
                        packetWriter.Write(sprite.SpriteSheet.Name);
                        packetWriter.Write(sprite.SpriteBounds.X);
                        packetWriter.Write(sprite.SpriteBounds.Y);
                        packetWriter.Write(sprite.SpriteBounds.Width);
                        packetWriter.Write(sprite.SpriteBounds.Height);
                    }

                    // Send movement sprite
                    if (game.MovementSpriteComponent.Contains(local.EntityID))
                    {
                        MovementSprite sprite = game.MovementSpriteComponent[local.EntityID];
                        packetWriter.Write(sprite.EntityID);
                        packetWriter.Write((short)PacketTypes.MovementSprite);
                        packetWriter.Write(sprite.SpriteSheet.Name);
                        packetWriter.Write(sprite.SpriteBounds.X);
                        packetWriter.Write(sprite.SpriteBounds.Y);
                        packetWriter.Write(sprite.SpriteBounds.Width);
                        packetWriter.Write(sprite.SpriteBounds.Height);
                    }

                    // Send the data
                    session.LocalGamers[0].SendData(packetWriter, SendDataOptions.InOrder, e.Gamer);
                }
            }
        }
Esempio n. 28
0
 void SessionGamerJoinedHandler(object sender, GamerJoinedEventArgs e)
 {
     //throw new NotImplementedException();
 }
        /// <summary>
        /// This event handler will be called whenever a new gamer joins the session.
        /// We use it to allocate a Tank object, and associate it with the new gamer.
        /// </summary>
        void GamerJoinedEventHandler(object sender, GamerJoinedEventArgs e)
        {
            int gamerIndex = networkSession.AllGamers.IndexOf(e.Gamer);

            e.Gamer.Tag = new Tank(gamerIndex, Content, screenWidth, screenHeight);
        }
Esempio n. 30
0
 static void GamerJoined(object sender, GamerJoinedEventArgs e)
 {
     //if (!e.Gamer.IsLocal)
     //    while ((e.Gamer.Tag as LinkedList<string>).Count != 0)
     //    {
     //        playerList.AddLast((e.Gamer.Tag as LinkedList<string>).First.Value);
     //        (e.Gamer.Tag as LinkedList<string>).RemoveFirst();
     //    }
 }