Game over handling ready
This commit is contained in:
20
WinGreed/GameOverCheck.cs
Normal file
20
WinGreed/GameOverCheck.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinGreed
|
||||
{
|
||||
public class GameOverCheck
|
||||
{
|
||||
public GameOverCheck()
|
||||
{
|
||||
this.lvsave = null;
|
||||
this.points = 0;
|
||||
}
|
||||
|
||||
public ListViewItem lvsave { get; set; }
|
||||
public int points { get; set; }
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,9 @@ namespace WinGreed
|
||||
{
|
||||
public partial class frmStart : Form
|
||||
{
|
||||
private bool GameOver = false;
|
||||
private GameOverCheck gocFirst = new GameOverCheck();
|
||||
private GameOverCheck gocSecond = new GameOverCheck();
|
||||
private frmPersonRound fPR = null;
|
||||
private int actPlayerNo = -1;
|
||||
public frmStart()
|
||||
@ -21,6 +24,42 @@ namespace WinGreed
|
||||
fPR.TotPoints = int.Parse(nextLvInstance.SubItems[2].Text);
|
||||
fPR.ShowDialog();
|
||||
nextLvInstance.SubItems[2].Text = fPR.TotPoints.ToString();
|
||||
if (GameOver)
|
||||
{
|
||||
if (nextLvInstance == gocFirst.lvsave)
|
||||
{
|
||||
PlaySomething();
|
||||
if (gocSecond.lvsave != null)
|
||||
{
|
||||
gocSecond.lvsave.SubItems[1].Text = (int.Parse(gocSecond.lvsave.SubItems[1].Text) + 1).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
nextLvInstance.SubItems[1].Text = (int.Parse(nextLvInstance.SubItems[1].Text) + 1).ToString();
|
||||
}
|
||||
btnSpela.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fPR.TotPoints > gocFirst.points && nextLvInstance != gocFirst.lvsave)
|
||||
{
|
||||
if(nextLvInstance != gocSecond.lvsave && fPR.TotPoints > gocSecond.points)
|
||||
{
|
||||
gocSecond.points = fPR.TotPoints;
|
||||
gocSecond.lvsave = nextLvInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fPR.TotPoints > 10000)
|
||||
{
|
||||
GameOver = true;
|
||||
gocFirst.points = fPR.TotPoints;
|
||||
gocFirst.lvsave = nextLvInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user