コード例 #1
0
        public GameInstance(Database.Game game, Database.GameDevice device, UdpClient client, IPEndPoint endPoint)
        {
            _masterClient = new GamePlayer(device, client, endPoint);
            _masterClient.GotGameUpdate += new EventHandler<GameUpdateEventArgs>(_masterClient_GotGameUpdate);
            _masterClient.ClientDisconnected += new EventHandler(_masterClient_ClientDisconnected);
            _allPlayers.Add(_masterClient);
            _endPointMap.Add(endPoint.ToString().GetHashCode(), _masterClient);

            _game = game;
        }
コード例 #2
0
ファイル: WorldMgr.cs プロジェクト: icegbq/Orion
        /// <summary>
        /// Called when a server receives a tcpclient
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static GameClient AddClient(GameClient c)
        {
            int index = _cIndexer.GetIndex();

            if (index >= Constants.MaxClientCount)
            {
                Console.WriteLine("Failed to add client to list, count greater than MaxClientCount.");
                return null;
            }

            GamePlayer p = new GamePlayer(c);
            c.Player = p;
            c.Index = index;
            _clients[index] = c;
            p.AddToWorld();

            c.PacketLib.SendHello();
            return c;
        }
コード例 #3
0
        public void AddPlayer(Database.GameDevice gameDevice, UdpClient client, IPEndPoint endPoint)
        {
            lock (this)
            {
                GamePlayer addPlayer = new GamePlayer(gameDevice, client, endPoint);
                addPlayer.GotGameUpdate += new EventHandler<GameUpdateEventArgs>(_slaveClient_GotGameUpdate);
                addPlayer.ClientDisconnected += new EventHandler(addPlayer_ClientDisconnected);

                _endPointMap.Add(endPoint.ToString().GetHashCode(), addPlayer);
                _slaveClients.Add(addPlayer);
                _allPlayers.Add(addPlayer);
            }

            SendGameInfo();
        }
コード例 #4
0
ファイル: Mover.cs プロジェクト: benmandr/JDDestroyer
 public void removeObserver(GamePlayer player)
 {
     observers.RemoveAll(x => x.gamePlayer.Equals(player));
 }