public void AddRebuyClickHandler(Object sender, EventArgs e, int playerIndex, CurrentGameData currentGameData) { PlayerData player = currentGameData.players[playerIndex]; if (player.Rebuys < Int32.Parse(settings[Settings.Default.IniSection]["MaximumRebuys"])) { player.Rebuys++; lblRebuys[playerIndex].Text = player.Rebuys.ToString(); } else { player.Rebuys = 0; lblRebuys[playerIndex].Text = player.Rebuys.ToString(); } // If bounties is set to On Re-buy, show bounty pop up if (Equals(settings[Settings.Default.IniSection]["Bounties"], "1")) { AddBounty(player, playerIndex, true, sender, currentGameData); } #if DEBUG // Output rebuys to console for easy debugging Console.Write("Rebuys:\n"); foreach (PlayerData p in currentGameData.players) { Console.Write(p.Name + ": " + p.Rebuys + "\n"); } Console.Write("--------\n"); #endif ((Panel)((TableLayoutPanel)((Button)sender).Parent).Parent).Focus(); currentGameData.UpdateCurrentGameData(PlayersLeft); }
// Start is called before the first frame update void Start() { m_NumberManager = GameObject.Find("Main Camera").GetComponent <NumberManager>() as NumberManager; m_Checkbox = GameObject.Find("Checkbox").GetComponent <Checkbox>() as Checkbox; m_GameData = GameObject.Find("GameDataObject").GetComponent <CurrentGameData>() as CurrentGameData; m_SurvivalHearts = GameObject.Find("Main Camera").GetComponent <SurvivalHearts>() as SurvivalHearts; m_Scores = GameObject.Find("Main Camera").GetComponent <Scores>() as Scores; }
// Use this for initialization void Start() { m_FlagManager = GameObject.Find("Main Camera").GetComponent <FlagManager>() as FlagManager; m_Checkbox = GameObject.Find("Checkbox").GetComponent <Checkbox>() as Checkbox; m_GameData = GameObject.Find("GameDataObject").GetComponent <CurrentGameData>() as CurrentGameData; m_SurvivalLifes = GameObject.Find("Main Camera").GetComponent <SurvivalLives>() as SurvivalLives; m_ShortGame = GameObject.Find("Main Camera").GetComponent <ShortGameMode>() as ShortGameMode; m_Scores = GameObject.Find("Main Camera").GetComponent <Scores>() as Scores; }
public void SaveGameData(CurrentGameData gameData) { if (gameData.IsEmpty) { return; } var serializedGameData = JsonConvert.SerializeObject(gameData); Preferences.Set(SavedGameKey, serializedGameData); }
public GameInitializer(string configPath) { LoadJson(configPath); _allColourCollection = _configFile.ColourList; _playableColours = _configFile.TotalColoursPicked; _generatedColourList = new string[_playableColours]; GenerateRandomColours(); var gameDataObject = new CurrentGameData(_generatedColourList, _playableColours, _configFile.TurnLimit); var outputController = new OutputController(gameDataObject); outputController.StartGame(); }
// Start is called before the first frame update void Start() { StartedGameOverTimer = false; EndGUIActivated = false; m_GameData = GameObject.Find("GameDataObject").GetComponent <CurrentGameData>() as CurrentGameData; m_Scores = GameObject.Find("Main Camera").GetComponent <Scores>() as Scores; if (GameSettings.Instance.GetGameMode() == GameSettings.EGameMode.TIME_TRIAL_MODE) { this.enabled = true; } else { this.enabled = false; } }
public Button NewRemoveButton(CurrentGameData currentGameData) { Button button = new Button { Text = "Remove", BackColor = Color.Gainsboro, Dock = DockStyle.Fill, Margin = new System.Windows.Forms.Padding(0, 0, 51, 0), Tag = this.Count }; button.Click += new EventHandler((sender, e) => RemoveClickHandler(sender, e, this.List.IndexOf(((Button)sender).Parent), currentGameData)); button.TabStop = false; return(button); }
// Start is called before the first frame update void Start() { LifeNumber = 3; if (GameSettings.Instance.GetGameMode() == GameSettings.EGameMode.SURVIVAL_MODE) { this.enabled = true; foreach (GameObject g in Hearts) { g.SetActive(true); } } else { this.enabled = false; } m_GameData = GameObject.Find("GameDataObject").GetComponent <CurrentGameData>() as CurrentGameData; m_Scores = GameObject.Find("Main Camera").GetComponent <Scores>() as Scores; }
// Start is called before the first frame update void Start() { MaxQuestionsNumber = Questions.Count; m_GameData = GameObject.Find("GameDataObject").GetComponent <CurrentGameData>() as CurrentGameData; m_Scores = GameObject.Find("Main Camera").GetComponent <Scores>() as Scores; if (GameSettings.Instance.GetGameMode() == GameSettings.EGameMode.SHORT_MODE) { this.enabled = true; foreach (GameObject o in Questions) { o.SetActive(true); } } else { this.enabled = false; } }
public void SaveGameData(CurrentGameData gameData) { }
public void AddBounty(PlayerData player, int labelIndex, Boolean OnRebuy, Object sender, CurrentGameData currentGameData) { string[] aPlayers; int i = 0; if (player.Eliminated) { aPlayers = new string[PlayersLeft]; } else { aPlayers = new string[PlayersLeft - 1]; } // Populate array to show in the input box foreach (PlayerData playerData in currentGameData.players) { if (playerData.Name != player.Name) { if (playerData.Eliminated != true) { aPlayers[i] = playerData.Name; i++; } } } // Dislpay input box to choose which player got the bounty InputBox.ShowDialog("Who kocked this person out.", "Bounty", InputBox.Buttons.OkCancel, InputBox.Type.ComboBox, aPlayers, false, new Font("Arial", 10F, FontStyle.Bold)); if (InputBox.ResultValue.Length != 0) { i = 0; // Loop through players to find out which panel matches the player chosen foreach (PlayerData playerData in currentGameData.players) { if (playerData.Name == InputBox.ResultValue) { playerData.Bounties++; lblBounties[i].Text = playerData.Bounties.ToString(); lastPlayerWithBounty = playerData.Name; } i++; } } else if (OnRebuy) { player.Rebuys--; lblRebuys[labelIndex].Text = player.Rebuys.ToString(); } else { PlayersLeft++; lblPlace[labelIndex].Text = ""; player.Eliminated = false; ((Button)sender).Text = "Remove"; } #if DEBUG // Output bounties to console for easy debugging Console.Write("Bounties:\n"); foreach (PlayerData playerData in currentGameData.players) { Console.Write(playerData.Name + ": " + playerData.Bounties + "\n"); } Console.Write("--------\n"); #endif currentGameData.UpdateCurrentGameData(PlayersLeft); }
public void RemoveClickHandler(Object sender, EventArgs e, int playerIndex, CurrentGameData currentGameData) { PlayerData player = currentGameData.players[playerIndex]; int i = 0; int index = this.List.IndexOf(((Button)sender).Parent); if (currentGameData.State == State.NotStarted) { currentGameData.players.RemoveAt(playerIndex); Remove(sender); PlayersLeft--; } else if (((Button)sender).Text == "Undo") { PlayersLeft++; lblPlace[playerIndex].Text = ""; player.Eliminated = false; player.Place = 0; ((Button)sender).Text = "Remove"; // Loop through players to the player with the last bounty foreach (PlayerData playerData in currentGameData.players) { if (playerData.Name == lastPlayerWithBounty) { playerData.Bounties--; lblBounties[i].Text = playerData.Bounties.ToString(); } i++; } } else { ((Panel)((TableLayoutPanel)((Button)sender).Parent).Parent).AutoScrollPosition = new Point(0, 0); ((Button)sender).Text = "Undo"; // Set place label switch (PlayersLeft) { case 1: lblPlace[index].Text = "1st"; break; case 2: lblPlace[index].Text = "2nd"; break; case 3: lblPlace[index].Text = "3rd"; break; default: lblPlace[index].Text = PlayersLeft + "th"; break; } player.Eliminated = true; player.Place = PlayersLeft; #if DEBUG // Output isEliminated to console for easy debugging Console.Write("Eliminated:\n"); foreach (PlayerData playerData in currentGameData.players) { Console.Write(playerData.Name + ": " + playerData.Eliminated + "\n"); } Console.Write("--------\n"); #endif i = 0; int j = 0; foreach (Control c in this) { if (c != (TableLayoutPanel)((Button)sender).Parent) { if (lblPlace[j].Text.Length == 0) { i++; c.Top = i * 67; } else { btnRemove[j].Enabled = false; //Convert.ToInt32(c.Tag) - 1 } } j++; } // Reposition Panel to last panel ((TableLayoutPanel)((Button)sender).Parent).Top = PlayersLeft * 67; PlayersLeft--; if (!Equals(settings[Settings.Default.IniSection]["Bounties"], "0")) { if (PlayersLeft > 0) { AddBounty(player, index, false, sender, currentGameData); } } if (PlayersLeft == 1) { DisableButtons(); frmMain.EndOfGame(lblPlace); } } currentGameData.UpdateCurrentGameData(PlayersLeft); }
public TableLayoutPanel AddNewPanel(TableLayoutPanel header, CurrentGameData currentGameData) { // Create a new instance of the Button class. TableLayoutPanel newPanel = new TableLayoutPanel(); // Add the button to the collection's internal list. this.List.Add(newPanel); ((Panel)header.Parent).AutoScrollPosition = new Point(0, 0); // Add the button to the controls collection of the form // referenced by the HostForm field. HostForm.Controls.Add(newPanel); // Set intial properties for the button object. newPanel.Top = Count * 67; newPanel.Left = 6; newPanel.Width = header.Width;//753; newPanel.Height = 52; newPanel.ColumnCount = 6; // Determine if the bounty column should be shown if (!Equals(settings[Settings.Default.IniSection]["Bounties"], "0")) { newPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); newPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); newPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); newPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); newPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); newPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); } else { newPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); newPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); newPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); newPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 0F)); newPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); newPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); } newPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); newPanel.Tag = this.Count.ToString(); lblPlace.Add(NewPlaceLabel()); newPanel.Controls.Add(lblPlace[Count - 1], 0, 0); Label lblPlayer = new Label(); newPanel.Controls.Add(lblPlayer, 1, 0); lblPlayer.Text = currentGameData.players[currentGameData.players.Count - 1].Name; lblPlayer.Dock = DockStyle.Fill; lblPlayer.TextAlign = ContentAlignment.MiddleCenter; lblPlayer.Margin = new System.Windows.Forms.Padding(1, 1, 1, 1); lblPlayer.Tag = this.Count; lblRebuys.Add(NewRebuyLabel()); newPanel.Controls.Add(lblRebuys[Count - 1], 2, 0); lblBounties.Add(NewBountyLabel()); newPanel.Controls.Add(lblBounties[Count - 1], 3, 0); btnAddRebuy.Add(NewAddRebuyButton(currentGameData)); newPanel.Controls.Add(btnAddRebuy[Count - 1], 4, 0); btnRemove.Add(NewRemoveButton(currentGameData)); newPanel.Controls.Add(btnRemove[Count - 1], 5, 0); //btnRemove.Text = "Remove"; //btnRemove.BackColor = Color.Gainsboro; //btnRemove.Dock = DockStyle.Fill; //btnRemove.Margin = new System.Windows.Forms.Padding(0, 0, 51, 0); //btnRemove.Tag = this.Count; //btnRemove.Click += new EventHandler(this.RemoveClickHandler); PlayersLeft++; using (Control c = new Control() { Parent = ((Panel)header.Parent), Dock = DockStyle.Bottom }) { ((Panel)header.Parent).ScrollControlIntoView(c); c.Parent = null; } return(newPanel); }
// Start is called before the first frame update void Start() { NumberOfFlagsObjects = FlagsObjects.Length; m_GameData = GameObject.Find("GameDataObject").GetComponent <CurrentGameData>() as CurrentGameData; IsFirstRun = true; }
// Use this for initialization void Start() { /******************************************** * TEMP code for testing ********************************************/ // Unit Types // Container for all application data GameDataContainer = new GameDataContainer(); GameDataContainer.LoadUnitTypes(); UnitType heavyInf = GameDataContainer.UnitTypes[0]; UnitType dragon = GameDataContainer.UnitTypes[2]; // temp initilization CurrentGameData = new CurrentGameData(GameDataContainer); // instantiate terrain, main function InstantiateTerrain(CurrentGameData.TerrainTiles); // temp set owner Stack playerStack = GameObject.Find("PlayerStack").GetComponent <Stack>(); playerStack.StackData.Owner = CurrentGameData.Players[0]; var playerUnit = new Unit(heavyInf); var playerUnit2 = new Unit(heavyInf); var playerUnit3 = new Unit(dragon); playerStack.AddUnit(playerUnit); playerStack.AddUnit(playerUnit2); playerStack.AddUnit(playerUnit3); playerStack.NextTurn(); AddStackToAllStacks(playerStack); Stack enemyStack = GameObject.Find("EnemyStack").GetComponent <Stack>(); enemyStack.StackData.Owner = CurrentGameData.Players[1]; var enemyUnit = new Unit(heavyInf); enemyStack.AddUnit(enemyUnit); enemyStack.NextTurn(); AddStackToAllStacks(enemyStack); Stack enemyStack2 = GameObject.Find("EnemyStack2").GetComponent <Stack>(); enemyStack2.StackData.Owner = CurrentGameData.Players[1]; var enemyUnit2 = new Unit(heavyInf); enemyStack2.AddUnit(enemyUnit2); enemyStack2.NextTurn(); AddStackToAllStacks(enemyStack2); #region CameraInitialized // camera init vals // limit the camera based on the map size float vertExtent = MainCamera.orthographicSize; float horzExtent = vertExtent * Screen.width / Screen.height; // Size taken from bottom panel float uiPaddingBot = 2 * MainCamera.orthographicSize * (BottomUI.GetComponent <RectTransform>().rect.height / Screen.height); float uiPaddingTop = 2 * MainCamera.orthographicSize * (TopPanel.GetComponent <RectTransform>().rect.height / Screen.height); // off set is calculated based on the size of the map float offset = CurrentGameData.MapSize / 2f - 0.5f; CameraMinX = horzExtent - ((float)CurrentGameData.MapSize) / 2.0f + offset; CameraMaxX = ((float)CurrentGameData.MapSize) / 2.0f - horzExtent + offset; CameraMinY = vertExtent - ((float)CurrentGameData.MapSize) / 2.0f + offset - uiPaddingBot; CameraMaxY = ((float)CurrentGameData.MapSize) / 2.0f - vertExtent + offset + uiPaddingTop; if (CameraMaxX - CameraMinX < 0) { float diffX = CameraMinX - CameraMaxX; CameraMaxX += diffX / 2; CameraMinX -= diffX / 2; } if (CameraMaxY - CameraMinY < 0) { float diffY = CameraMinY - CameraMaxY; CameraMaxY += diffY / 2; CameraMinY -= diffY / 2; } #endregion }
// Start is called before the first frame update void Start() { m_GameData = GameObject.Find("GameDataObject").GetComponent <CurrentGameData>() as CurrentGameData; m_Scroes = 0; m_WrongScores = 0; }
public OutputController(CurrentGameData gameData) { _gameData = gameData; _turnCounter = 0; _winningOutput = WinningStringCreator(_gameData.GetColoursPicked()); }