Beispiel #1
0
        protected void ReceiveIncomingInvite(RemotePlayer source)
        {
            bool added = false;

            lock (this.IncomingInvites)
            {
                if (!this.IncomingInvites.ContainsKey(source.ID))
                {
                    this.IncomingInvites.Add(source.ID, source);
                    added = true;
                }
            }
            if (added)
            {
                this.Connection.Send(new S2C_IncomingPlayerInvite(source.GetDisplay()));
            }
        }
Beispiel #2
0
        //private void IncomingInvites_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        //{
        //    //inbox
        //    if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
        //    {
        //        foreach (var from in e.NewItems)
        //        {
        //            this.Connection.Send(new S2C_IncomingPlayerInvite(from as RemotePlayer));
        //        }

        //    }
        //    else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
        //    {
        //        foreach (var from in e.OldItems)
        //        {
        //            this.Connection.Send(new S2C_RevokedIncomingPlayerInvite((from as RemotePlayer).Connection.ConnectionInfo.NetworkIdentifier));
        //        }
        //    }
        //}

        //private void SentInvites_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        //{
        //    //outbox
        //    if(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
        //    {
        //        foreach (var target in e.NewItems)
        //        {
        //            (target as RemotePlayer).IncomingInvites.Add(this);
        //            //S2C_SentPlayerInvite
        //        }

        //    }
        //    else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
        //    {
        //        foreach(var target in e.OldItems)
        //        {
        //            (target as RemotePlayer).IncomingInvites.Remove(this);
        //            //S2C_RevokeSentPlayerInvite
        //        }
        //    }
        //}

        /// <summary>
        /// Send a game invite.
        /// </summary>
        /// <param name="player2">Invitation target</param>
        public void SendInvite(RemotePlayer destination)
        {
            bool added = false;

            lock (this.SentInvites)
            {
                if (!this.SentInvites.ContainsKey(destination.ID))
                {
                    this.SentInvites.Add(destination.ID, destination);
                    added = true;
                }
            }
            if (added)
            {
                destination.ReceiveIncomingInvite(this);
                Connection.Send(new S2C_SentPlayerInvite(destination.GetDisplay()));
            }
        }
Beispiel #3
0
 public RemotePlayer GetOpponent(RemotePlayer player)
 {
     return((player.ID == BlueSide.RemotePlayer.ID) ? RedSide.RemotePlayer : BlueSide.RemotePlayer);
 }
Beispiel #4
0
 public Player GetPlayer(RemotePlayer player)
 {
     return((player.ID == BlueSide.RemotePlayer.ID) ? BlueSide : RedSide);
 }
Beispiel #5
0
 public Player(PlayerSide side, RemotePlayer remotePlayer, Game game)
 {
     this.PlayerSide   = side;
     this.RemotePlayer = remotePlayer;
     this.Game         = game;
 }