private void neuesSpielToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show(this, "Sind Sie sich sicher, dass Sie das aktuelle Spiel abbrechen und ein neues Spiel starten möchten?", "Neues Spiel?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { Spider.Class.Game.Mode currentMode = Class.Game.Mode.OneSuit; using (ModeDialog mld = new ModeDialog()) { if (mld.ShowDialog(this) == DialogResult.OK) { currentMode = mld.SelectedMode; } } this.currentGame.MStructures.Clear(); this.currentGame.OtherCards.Clear(); this.Controls.Remove(this.currentRenderer); this.currentGame = new Class.Game(this, currentMode); this.currentGame.Refresh += CurrentGame_Refresh; this.currentGame.ReDraw += CurrentGame_ReDraw; this.currentRenderer.OnDraw(); if (this.info.HW_ACC) { this.currentRenderer = new Spider.Class.Render.SlimDXRenderer(); } else { this.currentRenderer = new Spider.Class.Render.GDIRenderer(); } this.currentRenderer.MouseDown += CurrentRenderer_MouseDown; currentRenderer.OnInit(this.currentGame, this, this.info); currentRenderer.OnDraw(); } }
private void frmMain_Load(object sender, EventArgs e) { using (ModeDialog mld = new ModeDialog()) { if (mld.ShowDialog(this) == DialogResult.OK) { this.currentGame = new Class.Game(this, mld.SelectedMode); } } currentRenderer.OnInit(this.currentGame, this, this.info); this.currentGame.ReDraw += CurrentGame_ReDraw; this.currentGame.Refresh += CurrentGame_Refresh; this.mStrip.BackColor = Color.LightSkyBlue; this.mStrip.ForeColor = Color.Black; }
private void spielLadenToolStripMenuItem_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog() { Filter = ".xml|" }) { if (ofd.ShowDialog(this) == DialogResult.OK) { try { Serialization.Serialization <Class.Game> gameSer = new Serialization.Serialization <Class.Game>(); this.currentGame.MStructures.Clear(); this.currentGame.OtherCards.Clear(); this.Controls.Remove(this.currentRenderer); this.currentGame = gameSer.Read(ofd.FileName, Serialization.Serialization <Class.Game> .Typ.Normal); this.currentGame.ReDraw += CurrentGame_ReDraw; this.currentGame.Refresh += CurrentGame_Refresh; this.Invalidate(); if (this.info.HW_ACC) { this.currentRenderer = new Spider.Class.Render.SlimDXRenderer(); } else { this.currentRenderer = new Spider.Class.Render.GDIRenderer(); } this.currentRenderer.MouseDown += CurrentRenderer_MouseDown; currentRenderer.OnInit(this.currentGame, this, this.info); currentRenderer.OnDraw(); this.currentRenderer.OnDraw(); } catch (Exception) { MessageBox.Show(this, "Die Datei ist ungültig! Bitte wählen Sie eine gültige Datei aus!", "Gültige Datei auswählen!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void spielLadenToolStripMenuItem_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog() { Filter = ".xml|" }) { if (ofd.ShowDialog(this) == DialogResult.OK) { try { Serialization.Serialization<Class.Game> gameSer = new Serialization.Serialization<Class.Game>(); this.currentGame.MStructures.Clear(); this.currentGame.OtherCards.Clear(); this.Controls.Remove(this.currentRenderer); this.currentGame = gameSer.Read(ofd.FileName, Serialization.Serialization<Class.Game>.Typ.Normal); this.currentGame.ReDraw += CurrentGame_ReDraw; this.currentGame.Refresh += CurrentGame_Refresh; this.Invalidate(); if (this.info.HW_ACC) this.currentRenderer = new Spider.Class.Render.SlimDXRenderer(); else this.currentRenderer = new Spider.Class.Render.GDIRenderer(); this.currentRenderer.MouseDown += CurrentRenderer_MouseDown; currentRenderer.OnInit(this.currentGame, this, this.info); currentRenderer.OnDraw(); this.currentRenderer.OnDraw(); } catch (Exception) { MessageBox.Show(this, "Die Datei ist ungültig! Bitte wählen Sie eine gültige Datei aus!", "Gültige Datei auswählen!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void neuesSpielToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show(this, "Sind Sie sich sicher, dass Sie das aktuelle Spiel abbrechen und ein neues Spiel starten möchten?", "Neues Spiel?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { Spider.Class.Game.Mode currentMode = Class.Game.Mode.OneSuit; using (ModeDialog mld = new ModeDialog()) { if (mld.ShowDialog(this) == DialogResult.OK) { currentMode = mld.SelectedMode; } } this.currentGame.MStructures.Clear(); this.currentGame.OtherCards.Clear(); this.Controls.Remove(this.currentRenderer); this.currentGame = new Class.Game(this, currentMode); this.currentGame.Refresh += CurrentGame_Refresh; this.currentGame.ReDraw += CurrentGame_ReDraw; this.currentRenderer.OnDraw(); if (this.info.HW_ACC) this.currentRenderer = new Spider.Class.Render.SlimDXRenderer(); else this.currentRenderer = new Spider.Class.Render.GDIRenderer(); this.currentRenderer.MouseDown += CurrentRenderer_MouseDown; currentRenderer.OnInit(this.currentGame, this, this.info); currentRenderer.OnDraw(); } }
public static bool DistributeNewCars(ExtendendList<Structure> tmpLst, Game currentGame) { if (Structure.CanDistributeCards(tmpLst)) { if (currentGame.OtherCards.Count != 0 && currentGame.OtherCards.Count > 9) { int count = 0; ExtendendList<Cart> saved = new ExtendendList<Cart>(); foreach (Structure str in tmpLst) { Cart toAdd = currentGame.OtherCards[count]; saved.Add(toAdd); toAdd.Active = true; str.lstCards.Add(toAdd); count++; } for (int i = 0; i <= count - 1; i++) currentGame.OtherCards.Remove(saved[i]); Structure.SetState(tmpLst, false); } return true; } else return false; }
public static ExtendendList<Structure> CreateStructureList(Game currentGame) { ExtendendList<Cart> mCarts = Class.Cart.CreateNewCarts(currentGame.GameMode); ExtendendList<Structure> mStructures = new ExtendendList<Class.Structure>(); ExtendendList<Class.Cart> tmpLst = new ExtendendList<Class.Cart>(); int index = 0, ct = 0; for (int i = 0; i <= 9; i++) { Structure.SType cType = (i >= 4) ? Structure.SType.Five : SType.Six; Structure str = new Structure(null, cType); int cCards = (i >= 4) ? 5 : 6; for (int c = 0; c <= cCards - 1; c++) { Cart curCart = mCarts[index]; // curCart.owner = str; if (c == cCards - 1) curCart.Active = true; tmpLst.Add(curCart); index++; ct++; } str.lstCards = tmpLst.Clone(); tmpLst.Clear(); mStructures.Add(str); } currentGame.OtherCards.Clear(); for (int c = ct; c <= mCarts.Count - 1; c++) currentGame.OtherCards.Add(mCarts[c]); return mStructures; }