コード例 #1
0
		public GameCoordinator(Window window)
		{
			var screenSpace = new Camera2DScreenSpace(window);
			screenSpace.LookAt = Vector2D.Half;
			DisplayIntroLogo();
			rabbitMatrix = new RabbitGrid(20, 12,
				new Rectangle(ScreenSpace.Current.Left + 0.05f, ScreenSpace.Current.Top + 0.1f,
					ScreenSpace.Current.Viewport.Width - 0.1f, ScreenSpace.Current.Viewport.Height - 0.15f));
			userInterface = new UserInterface();
			userInterface.Money = 50;
			rabbitMatrix.MoneyEarned += money => userInterface.Money += money;
			rabbitMatrix.RabbitKilled += () => userInterface.Kills++;
			userInterface.DidDamage += rabbitMatrix.DoDamage;
			window.ViewportSizeChanged += size => rabbitMatrix.RecalculateRabbitPositionsAndSizes(new Rectangle(
				ScreenSpace.Current.Left + 0.05f, ScreenSpace.Current.Top + 0.1f,
				ScreenSpace.Current.Viewport.Width - 0.1f, ScreenSpace.Current.Viewport.Height - 0.15f));
			RespondToInput();
		}
コード例 #2
0
        public GameCoordinator(Window window)
        {
            var screenSpace = new Camera2DScreenSpace(window);

            screenSpace.LookAt = Vector2D.Half;
            DisplayIntroLogo();
            rabbitMatrix = new RabbitGrid(20, 12,
                                          new Rectangle(ScreenSpace.Current.Left + 0.05f, ScreenSpace.Current.Top + 0.1f,
                                                        ScreenSpace.Current.Viewport.Width - 0.1f, ScreenSpace.Current.Viewport.Height - 0.15f));
            userInterface               = new UserInterface();
            userInterface.Money         = 50;
            rabbitMatrix.MoneyEarned   += money => userInterface.Money += money;
            rabbitMatrix.RabbitKilled  += () => userInterface.Kills++;
            userInterface.DidDamage    += rabbitMatrix.DoDamage;
            window.ViewportSizeChanged += size => rabbitMatrix.RecalculateRabbitPositionsAndSizes(new Rectangle(
                                                                                                      ScreenSpace.Current.Left + 0.05f, ScreenSpace.Current.Top + 0.1f,
                                                                                                      ScreenSpace.Current.Viewport.Width - 0.1f, ScreenSpace.Current.Viewport.Height - 0.15f));
            RespondToInput();
        }