コード例 #1
0
ファイル: TurnHandler.cs プロジェクト: tomba/dwarrowdelf
        public TurnHandler(World world, ClientUser user)
        {
            m_world = world;
            m_user = user;

            m_world.TurnEnded += OnTurnEnded;
            m_world.TurnStarted += OnTurnStarted;

            LivingObject.LivingRequestsAction += OnLivingRequestsAction;
            user.DisconnectEvent += user_DisconnectEvent;
        }
コード例 #2
0
ファイル: ConnectManager.cs プロジェクト: Fulborg/dwarrowdelf
		async Task ConnectPlayerAsyncInt()
		{
			var player = new ClientUser();
			player.DisconnectEvent += OnDisconnected;
			player.StateChangedEvent += (state) => SetLogOnText(state.ToString(), 0);

			await player.LogOn("tomba");

			GameData.Data.User = player;

			var controllable = GameData.Data.World.Controllables.FirstOrDefault();
			if (controllable != null && controllable.Environment != null)
			{
				var mapControl = App.MainWindow.MapControl;
				mapControl.IsVisibilityCheckEnabled = !GameData.Data.User.IsSeeAll;
				mapControl.Environment = controllable.Environment;
				mapControl.CenterPos = new System.Windows.Point(controllable.Location.X, controllable.Location.Y);
				mapControl.Z = controllable.Location.Z;

				if (GameData.Data.World.GameMode == GameMode.Adventure)
					App.MainWindow.FocusedObject = controllable;
			}

			if (Program.StartupStopwatch != null)
			{
				Program.StartupStopwatch.Stop();
				Trace.WriteLine(String.Format("Startup {0} ms", Program.StartupStopwatch.ElapsedMilliseconds));
				Program.StartupStopwatch = null;
			}
		}
コード例 #3
0
ファイル: ConnectManager.cs プロジェクト: tomba/dwarrowdelf
		public async Task ConnectPlayerAsync(ConnectionType connectionType, IProgress<string> prog)
		{
			if (m_user != null)
				return;

			IConnection connection;

			switch (connectionType)
			{
				case ConnectionType.Tcp:
					connection = await TcpConnection.ConnectAsync(this.NetStats, "CNet");
					break;

				case ConnectionType.Direct:
					connection = DirectConnection.Connect(m_server.Game);
					break;

				case ConnectionType.Pipe:
					connection = PipeConnection.Connect();
					break;

				default:
					throw new Exception();
			}

			var user = new ClientUser(connection);
			user.DisconnectEvent += OnDisconnected;

			await user.LogOn("tomba", prog);

			m_user = user;

			if (this.UserConnected != null)
				this.UserConnected(user);

			user.StartProcessingMessages();
		}
コード例 #4
0
ファイル: ConnectManager.cs プロジェクト: tomba/dwarrowdelf
		void OnDisconnected()
		{
			m_user.DisconnectEvent -= OnDisconnected;
			m_user = null;

			if (m_disconnectEvent != null)
				m_disconnectEvent.Set();
		}
コード例 #5
0
ファイル: GameDataBase.cs プロジェクト: tomba/dwarrowdelf
        void ConnectManager_UserConnected(ClientUser user)
        {
            if (this.User != null)
                throw new Exception();

            this.User = user;
            this.GameMode = user.GameMode;
            this.World = user.World;
            this.IsVisibilityCheckEnabled = !user.IsSeeAll;

            user.DisconnectEvent += user_DisconnectEvent;

            m_turnHandler = new TurnHandler(this.World, this.User);

            if (this.GameMode == GameMode.Adventure)
            {
                var controllable = this.World.Controllables.First();
                this.FocusedObject = controllable;
            }

            if (this.UserConnected != null)
                this.UserConnected();
        }