/// <summary> /// Przycisk wyśiwetlający szczegóły bitwy /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonShowBattle_Click(object sender, EventArgs e) { FormBattle formBattle = new FormBattle(this); formBattle.Show(); }
/// <summary> /// Funkcja obsługująca zdarzenia trwające co interwał czasu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timerMain_Tick(object sender, EventArgs e) { timeCounter++; labelTime.Text = "Dzień: " + timeCounter; Gold += 5; if (Gold >= repairCost && repairCost != 0 && !IsBattle) { buttonRepair.Enabled = true; } else { buttonRepair.Enabled = false; } if (IsBattle) { buttonShop.Enabled = false; PlayerArmy.Attack(EnemyArmy, random); EnemyArmy.Attack(PlayerArmy, random); buttonShowBattle.Enabled = true; EnemyArmy.RefreshUnitList(); PlayerArmy.RefreshUnitList(); ListSource.ResetBindings(false); } else { buttonShop.Enabled = true; buttonShowBattle.Enabled = false; if (battleBreakCount > 0) { battleBreakCount--; } } if (random.Next(2) == 1 && !IsBattle && battleBreakCount == 0) { EnemyArmy = new Army(timeCounter / 9); FormBattle formBattle = new FormBattle(this); formBattle.Show(); IsBattle = true; battleBreakCount = 25; Gold += EnemyArmy.GetTotalArmyCost() / 3; } if (EnemyArmy != null) { if (!EnemyArmy.UnitList.Any()) { IsBattle = false; } if (!PlayerArmy.UnitList.Any()) { MessageBox.Show("PORAŻKA"); EndGame(); } } labelGold.Text = "Złoto: " + Gold; if (timeCounter == 300) { labelScore.Text = "Wygrana!"; labelScore.ForeColor = Color.Khaki; labelScore.Visible = true; EndGame(); } }