private void defeatEnemy_Tick(object sender, EventArgs e) { levelUp.Visible = false; defeatEnemy.Enabled = false; instance = null; Close(); }
private void Fight(Enemy enemy) { player.ResetMoveSpeed(); player.MoveBack(); frmBattle = FrmBattle.GetInstance(enemy); if (enemy == bossKoolaid) { frmBattle.SetupForBossBattle(); } frmBattle.Refresh(); frmBattle.ShowDialog(); //check if enemies are dead if (enemySmiley.Health <= 0 && picEnemySmiley.Visible == true) { Rectangle rect = new Rectangle(picEnemySmiley.Location, new Size(0, 0)); enemySmiley.Collider = new Collider(rect); picEnemySmiley.Visible = false; } else if (enemyCheeto.Health <= 0 && picEnemyCheeto.Visible == true) { picEnemyCheeto.Visible = false; } else if (enemyPoisonPacket.Health <= 0 && picEnemyPoisonPacket.Visible == true) { picEnemyPoisonPacket.Visible = false; } else if (bossKoolaid.Health <= 0 && picBossKoolAid.Visible == true) { picBossKoolAid.Visible = false; } }
public static FrmBattle GetInstance(Enemy enemy) { if (instance == null) { instance = new FrmBattle(); instance.enemy = enemy; instance.Setup(); } return(instance); }
private void Fight(Enemy enemy) { player.ResetMoveSpeed(); player.MoveBack(); frmBattle = FrmBattle.GetInstance(enemy); frmBattle.Show(); if (enemy == bossKoolaid) { frmBattle.SetupForBossBattle(); } }
private void btnAttack_Click(object sender, EventArgs e) { player.OnAttack(-4); if (enemy.Health > 0) { enemy.OnAttack(-2); } UpdateHealthBars(); if (player.Health <= 0 || enemy.Health <= 0) { instance = null; Close(); } }
//hanlde processing for the battle ending to trigger appropriate event based on winner and close out of battle properly private void BattleEndSequence(bool playerWon) { //events need to be removed at end. Else EVERY instance of player and enemy made will acculumalte across battles enemy.AttackEvent -= PlayerDamage; player.AttackEvent -= EnemyDamage; if (playerWon) { enemy.HandleLostInBattle(); } else { player.HandleLostInBattle(); } TriggerTimedTextBoxUpdate((playerWon ? player.CharacterName : enemy.CharacterName) + " won the battle.", baseMillisecondDelay); instance = null; Close(); }
private void btnAttack_Click(object sender, EventArgs e) { //check to see if player has selected a weapon to use if (player.hasWeapon && listWeapons.Items.Count > 0 && listWeapons.SelectedItems.Count > 0) { Items i = player.curWeapons.Find(item => item.Name == listWeapons.SelectedItems[0].Text); // Console.WriteLine(i); listWeapons.Items[listWeapons.SelectedIndices[0]].Remove(); player.hasWeapon = listWeapons.Items.Count <= 0 ? false: true; player.OnAttack(-(i.Value)); player.curWeapons.Remove(i); } else { player.OnAttack(-4); } if (enemy.Health > 0) { //Armor Bar update if (player.totalArmor > 0) { player.totalArmor += (int)(enemy.strength * -2); if (player.totalArmor < 0) { //use Observer to attack with new amount enemy.OnAttackafterArmor(player.totalArmor); player.totalArmor = 0; } UpdateArmorBar(); } else { enemy.OnAttack(-2); // final boss direct hit, strength reduced if (finalBattle) { Console.WriteLine("Strength Reduced"); directHit.Visible = true; tmrStrengthReduced.Enabled = true; //enemy Health Increased enemy.Health += 3; //strength reduced player.strength -= 0.50; player.strength = player.strength < 1.5 ? 2 : player.strength; } } } UpdateHealthBars(); properImages(); //if (player.Health < 1) { picPlayer.BackgroundImage = global::Fall2020_CSC403_Project.Properties.Resources.peanut; } // LEVEL Up - increase strength when enemy is defeated if (enemy.Health <= 0 && player.Health > 0) { Console.WriteLine("Level Up"); levelUp.Visible = true; defeatEnemy.Enabled = true; //strength increased player.strength += 0.425; if (enemy.personalItem != null) { player.Loot(enemy); } } else if (player.Health <= 0 || enemy.Health <= 0) { instance = null; battleEnded = true; Close(); } }