private void UpdatePlayFieldSize() { this.screenRect.X = 0; this.screenRect.Y = 0; this.screenRect.Width = this.playField.ActualWidth; this.screenRect.Height = this.playField.ActualHeight; this.bannerRect.X = 10; this.bannerRect.Y = this.screenRect.Height - 50; this.bannerRect.Width = screenRect.Width - 30; this.bannerRect.Height = 40; BannerText.UpdateBounds(this.bannerRect); this.playerBounds.X = 0; this.playerBounds.Width = this.playField.ActualWidth; this.playerBounds.Y = this.playField.ActualHeight * 0.2; this.playerBounds.Height = this.playField.ActualHeight * 0.75; if (this.game != null) { foreach (var player in this.game.players) { player.Value.SetBounds(this.playerBounds); } } }
public static void Draw(UIElementCollection children) { if (myBannerText == null) { return; } Label text = myBannerText.GetLabel(); if (text == null) { myBannerText = null; return; } children.Add(text); }
private void WindowLoaded(object sender, RoutedEventArgs e) { this.playField.ClipToBounds = true; this.UpdatePlayFieldSize(); this.game = new Game(this.points, this.Dispatcher, this.screenRect, this.playField); timeBeginPeriod(timerResolution); var myGameThread = new Thread(this.game.GameThread); myGameThread.SetApartmentState(ApartmentState.STA); myGameThread.Start(); FlyingText.NewFlyingText(this.screenRect.Width / 30, new Point(this.screenRect.Width / 2, this.screenRect.Height / 2), "Kinect Fun!"); BannerText.NewBanner( Properties.Resources.Vocabulary, this.bannerRect, true, Color.FromArgb(200, 255, 255, 255)); }
private void CheckPlayers() { foreach (var player in this.players) { if (!player.Value.IsAlive) { // Player left scene since we aren't tracking it anymore, so remove from dictionary this.players.Remove(player.Value.GetId()); break; } } // Count alive players int alive = this.players.Count(player => player.Value.IsAlive); if (alive != this.PlayersAlive) { if (alive == 2) { this.SetGameMode(GameMode.TwoPlayer); } else if (alive == 1) { this.SetGameMode(GameMode.OnePlayer); } else if (alive == 0) { this.SetGameMode(GameMode.Off); } if (this.PlayersAlive == 0) { BannerText.NewBanner( Properties.Resources.Vocabulary, this.rect, true, Color.FromArgb(200, 255, 255, 255)); this.GameIsStarted = false; } this.PlayersAlive = alive; } }
private void HandleGameTimer(int param) { if (!GameIsStarted) { playField.Children.Clear(); foreach (var player in this.players) { player.Value.Draw(playField.Children); } BannerText.Draw(playField.Children); FlyingText.Draw(playField.Children); } else { CheckColisions(); } this.CheckPlayers(); }
public static void NewBanner(string s, Rect rect, bool scroll, System.Windows.Media.Color col) { myBannerText = (s != null) ? new BannerText(s, rect, scroll, col) : null; }