public static TableOfGame GetInstance() { if (instance == null) { instance = new TableOfGame(); } return(instance); }
//Construct public GameWindow() { this.WindowState = WindowState.Maximized; InitializeComponent(); TableOfGame.GetInstance().CreateTableOfGame(this.TableCanvas); this.WindowBorder.Background = TableOfGame.GetInstance().BackgroundColor; GameTextBlocks = new List <TextBlock>(); GameCheckBoxes = new List <CheckBox>(); AddTextsToList(); }
private void TableCanvas_Loaded(object sender, RoutedEventArgs e) { TableOfGame.GetInstance().SetWidthAndHeight((int)(this.TableCanvas.ActualWidth / TableOfGame.GetInstance().CellSize), (int)(this.TableCanvas.ActualHeight / TableOfGame.GetInstance().CellSize)); TableOfGame.GetInstance().InitializeFirstCells(); this.WindowBorder.Background = TableOfGame.GetInstance().BackgroundColor; SetTextColor(TableOfGame.GetInstance().TextColor); TableOfGame.GetInstance().PrintTable(); stopped = true; SetGameTimer(); }
private void BackgroundColorComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { string item = (string)((ComboBoxItem)((ComboBox)sender).SelectedValue).Content; if (item.Equals("Light Blue")) { TableOfGame.GetInstance().UserBackgroundColor = GetColor(0xE0E0FF); } if (item.Equals("Dark Blue")) { TableOfGame.GetInstance().UserBackgroundColor = GetColor(0x191970); } }
//Comparing public int CompareTo(object obj) { int r = (TableOfGame.GetInstance().WIDTH *(X - ((GameCell)obj).X)) - (Y - ((GameCell)obj).Y); if (r == 0) { this.Neihbours = ((GameCell)obj).Neihbours = Math.Max(((GameCell)obj).Neihbours, this.Neihbours) + 1; if (this.Color || ((GameCell)obj).Color) { this.Color = ((GameCell)obj).Color = true; } } return(r); }
private void AddRleButton_Click(object sender, RoutedEventArgs e) { string rle = this.RleText.Text, coords = this.CoordsText.Text; int z = coords.IndexOf(','); if (z > 0) { int x = StringToInt(coords.Substring(0, z)); int y = StringToInt(coords.Substring(z + 1)); TableOfGame.GetInstance().AddRle(rle, x, y); } else { TableOfGame.GetInstance().AddRle(rle); } TableOfGame.GetInstance().PrintTable(); }
private void GameTimer_Tick(object sender, EventArgs e) { if (!stopped) { GameTimer.Stop(); long delta = DateTime.Now.Millisecond; Dispatcher.Invoke((Action) delegate() { for (int i = 0; i < numberSteps; i++) { TableOfGame.GetInstance().MakeTurn(); } TableOfGame.GetInstance().PrintTable(); }); delta = DateTime.Now.Millisecond - delta; Console.WriteLine(delta + " " + TableOfGame.GetInstance().NumberOfCells()); GameTimer.Interval = Math.Max(0.1, zeroSpeed / speedModifier - (delta + 1000) % 1000); GameTimer.Start(); } }
private void ChangeUserThemeButton_Click(object sender, RoutedEventArgs e) { this.WindowBorder.Background = TableOfGame.GetInstance().UserBackgroundColor; SetTextColor(TableOfGame.GetInstance().UserTextColor); TableOfGame.GetInstance().AliveColor = TableOfGame.GetInstance().UserAliveColor; }
private void ThemeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.IsLoaded) { string item = (string)((ComboBoxItem)((ComboBox)sender).SelectedValue).Content; if (item.Equals("Light Blue")) { TableOfGame.GetInstance().BackgroundColor = GetColor(0xE0E0FF); TableOfGame.GetInstance().AliveColor = GetColor(0x191970); TableOfGame.GetInstance().TextColor = GetColor(0x000000); } if (item.Equals("Light Red")) { TableOfGame.GetInstance().BackgroundColor = GetColor(0xFFE0E0); TableOfGame.GetInstance().AliveColor = GetColor(0x701919); TableOfGame.GetInstance().TextColor = GetColor(0x000000); } if (item.Equals("Light Green")) { TableOfGame.GetInstance().BackgroundColor = GetColor(0xE0FFE0); TableOfGame.GetInstance().AliveColor = GetColor(0x197019); TableOfGame.GetInstance().TextColor = GetColor(0x000000); } if (item.Equals("Dark Blue")) { TableOfGame.GetInstance().AliveColor = GetColor(0xE0E0FF); TableOfGame.GetInstance().BackgroundColor = GetColor(0x191970); TableOfGame.GetInstance().TextColor = GetColor(0xFFFFFF); //StartButton.Background = TableOfGame.GetInstance().BackgroundColor; //StartButton.Foreground = TableOfGame.GetInstance().AliveColor; } if (item.Equals("Dark Red")) { TableOfGame.GetInstance().AliveColor = GetColor(0xFFE0E0); TableOfGame.GetInstance().BackgroundColor = GetColor(0x701919); TableOfGame.GetInstance().TextColor = GetColor(0xFFFFFF); } if (item.Equals("Dark Green")) { TableOfGame.GetInstance().AliveColor = GetColor(0xE0FFE0); TableOfGame.GetInstance().BackgroundColor = GetColor(0x197019); TableOfGame.GetInstance().TextColor = GetColor(0xFFFFFF); } if (item.Equals("User Theme")) { this.BackgroundColorComboBox.IsEnabled = true; this.AliveColorComboBox.IsEnabled = true; this.ChangeUserThemeButton.IsEnabled = true; this.WindowBorder.Background = TableOfGame.GetInstance().UserBackgroundColor; SetTextColor(TableOfGame.GetInstance().UserTextColor); TableOfGame.GetInstance().AliveColor = TableOfGame.GetInstance().UserAliveColor; } else { this.BackgroundColorComboBox.IsEnabled = false; this.AliveColorComboBox.IsEnabled = false; this.ChangeUserThemeButton.IsEnabled = false; this.WindowBorder.Background = TableOfGame.GetInstance().BackgroundColor; SetTextColor(TableOfGame.GetInstance().TextColor); } TableOfGame.GetInstance().PrintTable(); } }
private void ClearButton_Click(object sender, RoutedEventArgs e) { stopped = true; TableOfGame.GetInstance().ClearTable(); }
private void PrevStepButton_Click(object sender, RoutedEventArgs e) { stopped = true; TableOfGame.GetInstance().ReverseTurn(); TableOfGame.GetInstance().PrintTable(); }
private void NextStepButton_Click(object sender, RoutedEventArgs e) { stopped = true; TableOfGame.GetInstance().ForwardTurn(); TableOfGame.GetInstance().PrintTable(); }