Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game over working(sorta) #117

Open
wants to merge 60 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
f24c40d
btnrun
robcam1401 Oct 13, 2023
343bda1
btnrun
robcam1401 Oct 13, 2023
09f563d
BackgroundMusic
Oct 22, 2023
ccbbcda
Background
Nabinta1 Oct 22, 2023
31fe7ad
ok
Nabinta1 Oct 22, 2023
773c2df
okok
Nabinta1 Oct 22, 2023
248b07c
wav file
Nabinta1 Oct 22, 2023
0dd830e
fff
Nabinta1 Oct 23, 2023
631f8cc
bjdvjdhv
Nabinta1 Oct 23, 2023
132b661
pooo
Nabinta1 Oct 23, 2023
0cffd76
attack button sound
ark020 Oct 23, 2023
3f558bd
This is a blank death screen for CoNiya
ark020 Oct 23, 2023
660ca72
Delete FrmBattle.cs
robcam1401 Oct 23, 2023
3199dcd
Uploaded to the right location
ark020 Oct 23, 2023
8c853ba
Delete DeathScreen.cs
robcam1401 Oct 23, 2023
df56b20
Add files via upload
ark020 Oct 23, 2023
045409f
Revert "Uploaded to the right location"
robcam1401 Oct 23, 2023
44ac188
Revert "Add files via upload"
robcam1401 Oct 23, 2023
a818444
adds in the incomplete file for defeated enemy
robcam1401 Oct 25, 2023
41d1e1c
Add files via upload
ark020 Oct 25, 2023
9f8c3b9
Kamehameha
ark020 Oct 25, 2023
39d9090
Merge pull request #2 from robcam1401/attckbttnsound
ark020 Oct 25, 2023
65b2cbb
Update FrmBattle.cs
robcam1401 Oct 25, 2023
0aac330
enemyDisappear
robcam1401 Oct 27, 2023
facb572
Update FrmLevel.cs
robcam1401 Oct 27, 2023
70d74ea
Merge pull request #3 from robcam1401/enemyDisapper
robcam1401 Oct 27, 2023
4e7c112
Update Resources.Designer.cs
ark020 Oct 27, 2023
920c201
Merge pull request #4 from robcam1401/kamehameha-resource-code
ark020 Oct 27, 2023
407a58d
Added script for shield during battle
nischalp14 Oct 28, 2023
ce842bc
Update FrmLevel.cs
coniya Oct 29, 2023
eef9f4e
Merge pull request #5 from robcam1401/enemyDisapper
coniya Oct 29, 2023
9a42a9c
Shield functionality
Nabinta1 Oct 29, 2023
64be700
Add files via upload
ark020 Oct 29, 2023
d7cc146
shield functinality update
Nabinta1 Oct 29, 2023
5756f95
Trackbar scroller
Nabinta1 Oct 29, 2023
4b15e4c
Attack button sound
ark020 Oct 30, 2023
df91cff
Add files via upload
ark020 Oct 30, 2023
7b5169c
Update FrmBattle.cs
robcam1401 Oct 30, 2023
6d5bcb3
Update FrmLevel.cs
robcam1401 Oct 30, 2023
fb38df9
Documentation files
robcam1401 Oct 30, 2023
4694b8f
Add files via upload
robcam1401 Nov 4, 2023
0f5b73b
Add files via upload
robcam1401 Nov 4, 2023
50ba94c
Merge pull request #6 from robcam1401/LvScnHealthBar
robcam1401 Nov 6, 2023
005f4c2
Update FrmLevel.cs
robcam1401 Nov 6, 2023
bba7ed8
Merge pull request #7 from robcam1401/LvScnHealthBar
robcam1401 Nov 6, 2023
6166d00
Add files via upload
Nabinta1 Nov 8, 2023
26dccea
Merge pull request #10 from robcam1401/disclaimer
Nabinta1 Nov 8, 2023
30ccaf9
Revert "Add files via upload"
robcam1401 Nov 8, 2023
19ee73f
Merge pull request #11 from robcam1401/revert-10-disclaimer
robcam1401 Nov 8, 2023
9dda060
game over
coniya Nov 8, 2023
c97a7fe
Merge pull request #12 from robcam1401/gameOverScreen-Working
coniya Nov 8, 2023
dcc1543
Revert "game over"
coniya Nov 8, 2023
9c0b4aa
Merge pull request #13 from robcam1401/revert-12-gameOverScreen-Working
coniya Nov 8, 2023
243c5e2
Create gameOverScreen.Designer.cs
coniya Nov 10, 2023
9ccf36b
Create gameOverScreen.cs
coniya Nov 10, 2023
0aa411f
Add files via upload
coniya Nov 10, 2023
5443cb8
Add files via upload
coniya Nov 10, 2023
d374915
Delete Project/Fall2020_CSC403_Project/gameOverScreen.Designer.cs
robcam1401 Nov 10, 2023
d7518da
Delete Project/Fall2020_CSC403_Project/gameOverScreen.cs
robcam1401 Nov 10, 2023
d0da3f0
Add files via upload
robcam1401 Nov 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Documentation 1.pdf
Binary file not shown.
184 changes: 184 additions & 0 deletions FrmBattle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
using Fall2020_CSC403_Project.code;
using Fall2020_CSC403_Project.Properties;
using System;
using System.Drawing;
using System.Media;
using System.Windows.Forms;
using NAudio.Wave;

namespace Fall2020_CSC403_Project {
public partial class FrmBattle : Form {
public static FrmBattle instance = null;
private Enemy enemy;
private Player player;
private WaveOutEvent waveOut;
private AudioFileReader audioFile;
private SoundPlayer attackSound;
private bool shieldActivated = false;


private FrmBattle() {
InitializeComponent();
player = Game.player;
PlayAudio("data/Bg.wav");
attackSound = new SoundPlayer(Resources.Kamehameha); // Load the attack sound from resources

}
private void PlayAudio(string filePath)
{
waveOut = new WaveOutEvent();
audioFile = new AudioFileReader(filePath);
waveOut.Init(audioFile);
waveOut.Play();
}

private void SetVolume(float volume)
{
if (waveOut != null)
{
waveOut.Volume = volume;
}
}

private void trackBarVolume_Scroll(object sender, EventArgs e)
{
TrackBar trackBar = (TrackBar)sender;
float volume = trackBar.Value / 100f; // Convert to a scale of 0 to 1
SetVolume(volume);
}



public void Setup() {
// update for this enemy
picEnemy.BackgroundImage = enemy.Img;
picEnemy.Refresh();
BackColor = enemy.Color;
picBossBattle.Visible = false;

// Observer pattern
enemy.AttackEvent += PlayerDamage;
player.AttackEvent += EnemyDamage;

// show health
UpdateHealthBars();
}

public void SetupForBossBattle() {
picBossBattle.Location = Point.Empty;
picBossBattle.Size = ClientSize;
picBossBattle.Visible = true;

//SoundPlayer simpleSound = new SoundPlayer(Resources.final_battle);
//simpleSound.Play();

//tmrFinalBattle.Enabled = true;

string audioFilePath = "data/Bg.wav";
waveOut = new WaveOutEvent();
audioFile = new AudioFileReader(audioFilePath); waveOut.Init(audioFile); waveOut.Play();
tmrFinalBattle.Enabled = true;

trackBarVolume.ValueChanged += VolumeTrackBar_ValueChanged;
}

private void VolumeTrackBar_ValueChanged(object sender, EventArgs e)
{
if (audioFile != null)
{
float volume = trackBarVolume.Value / 100.0f;
audioFile.Volume = volume;
}
}

private void FrmBattle_FormClosing(object sender, FormClosingEventArgs e)
{
waveOut?.Dispose();
audioFile?.Dispose();

}

public static FrmBattle GetInstance(Enemy enemy) {
if (instance == null) {
instance = new FrmBattle();
instance.enemy = enemy;
instance.Setup();
}
return instance;
}

private void UpdateHealthBars() {
float playerHealthPer = player.Health / (float)player.MaxHealth;
float enemyHealthPer = enemy.Health / (float)enemy.MaxHealth;

const int MAX_HEALTHBAR_WIDTH = 226;
lblPlayerHealthFull.Width = (int)(MAX_HEALTHBAR_WIDTH * playerHealthPer);
lblEnemyHealthFull.Width = (int)(MAX_HEALTHBAR_WIDTH * enemyHealthPer);

lblPlayerHealthFull.Text = player.Health.ToString();
lblEnemyHealthFull.Text = enemy.Health.ToString();
}

private void btnAttack_Click(object sender, EventArgs e) {

//player.OnAttack(-4);
if (shieldActivated)
{
if (player.Health > 0)
{
player.OnAttack(-2);
}
}
else
{
if(enemy.Health > 0)
{
enemy.OnAttack(-2);
}
if(player.Health > 0)
{
player.OnAttack(-4);
}
}

attackSound.Play();
shieldActivated = false;
UpdateHealthBars();
if (player.Health <= 0 || enemy.Health <= 0) {
instance = null;
Close();
}
//shieldActivated = false;
}

private void EnemyDamage(int amount) {
enemy.AlterHealth(amount);
}

private void PlayerDamage(int amount) {
player.AlterHealth(amount);
}

private void tmrFinalBattle_Tick(object sender, EventArgs e) {
picBossBattle.Visible = false;
tmrFinalBattle.Enabled = false;
}
private void btnRun_Click(object sender, EventArgs e) {
instance = null;
Close();
}
// private bool sheildActivated = false;
private void btnShield_Click(object sender, EventArgs e)
{
btnShield.Enabled = false;
shieldActivated = true;
}


private void FrmBattle_Load(object sender, EventArgs e)
{

}
}
}

10 changes: 5 additions & 5 deletions Project/Fall2020_CSC403_Project/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
98 changes: 49 additions & 49 deletions Project/Fall2020_CSC403_Project/ClassDiagram1.cd
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="Fall2020_CSC403_Project.FrmBattle" Collapsed="true">
<Position X="9.25" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>ECgACABACCCBABCAAACAAIACBghAAABBAAAIAAAAAAI=</HashCode>
<FileName>FrmBattle.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Fall2020_CSC403_Project.FrmLevel" Collapsed="true">
<Position X="11" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAggAAACAuAMAsAAAACIgECGgAQAQKERAKAAgEUGCQA=</HashCode>
<FileName>FrmLevel.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Fall2020_CSC403_Project.code.BattleCharacter">
<Position X="1.5" Y="5.25" Width="1.5" />
<TypeIdentifier />
</Class>
<Class Name="Fall2020_CSC403_Project.code.Character">
<Position X="2.75" Y="0.5" Width="1.5" />
<TypeIdentifier />
</Class>
<Class Name="Fall2020_CSC403_Project.code.Collider">
<Position X="9.75" Y="2.5" Width="1.5" />
<TypeIdentifier />
</Class>
<Class Name="Fall2020_CSC403_Project.code.Enemy">
<Position X="2.75" Y="9" Width="1.5" />
<TypeIdentifier />
</Class>
<Class Name="Fall2020_CSC403_Project.code.Game">
<Position X="9.5" Y="4.75" Width="1.5" />
<TypeIdentifier />
</Class>
<Class Name="Fall2020_CSC403_Project.code.NPC">
<Position X="5" Y="5.25" Width="1.5" />
<TypeIdentifier />
</Class>
<Class Name="Fall2020_CSC403_Project.code.Player">
<Position X="0.5" Y="9" Width="1.5" />
<TypeIdentifier />
</Class>
<Struct Name="Fall2020_CSC403_Project.code.Vector2">
<Position X="5.75" Y="2.75" Width="1.5" />
<TypeIdentifier />
</Struct>
<Font Name="Segoe UI" Size="9" />
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="Fall2020_CSC403_Project.FrmBattle" Collapsed="true">
<Position X="9.25" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>ECgACABACCCBABCAAACAAIACBghAAABBAAAIAAAAAAI=</HashCode>
<FileName>FrmBattle.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Fall2020_CSC403_Project.FrmLevel" Collapsed="true">
<Position X="11" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAggAAACAuAMAsAAAACIgECGgAQAQKERAKAAgEUGCQA=</HashCode>
<FileName>FrmLevel.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Fall2020_CSC403_Project.code.BattleCharacter">
<Position X="1.5" Y="5.25" Width="1.5" />
<TypeIdentifier />
</Class>
<Class Name="Fall2020_CSC403_Project.code.Character">
<Position X="2.75" Y="0.5" Width="1.5" />
<TypeIdentifier />
</Class>
<Class Name="Fall2020_CSC403_Project.code.Collider">
<Position X="9.75" Y="2.5" Width="1.5" />
<TypeIdentifier />
</Class>
<Class Name="Fall2020_CSC403_Project.code.Enemy">
<Position X="2.75" Y="9" Width="1.5" />
<TypeIdentifier />
</Class>
<Class Name="Fall2020_CSC403_Project.code.Game">
<Position X="9.5" Y="4.75" Width="1.5" />
<TypeIdentifier />
</Class>
<Class Name="Fall2020_CSC403_Project.code.NPC">
<Position X="5" Y="5.25" Width="1.5" />
<TypeIdentifier />
</Class>
<Class Name="Fall2020_CSC403_Project.code.Player">
<Position X="0.5" Y="9" Width="1.5" />
<TypeIdentifier />
</Class>
<Struct Name="Fall2020_CSC403_Project.code.Vector2">
<Position X="5.75" Y="2.75" Width="1.5" />
<TypeIdentifier />
</Struct>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>
Binary file not shown.
Loading