public Agresor(KontrolerWalki pole, Stworzenie _agresor, MainGameForm _frm) { this.poleWalki = pole; this.agresor = _agresor; this.obroncy = new List<Stworzenie>(); this.frm = _frm; }
public GameBase(MainGameForm.MessageHandler messageHandler, MainGameForm mainGameForm) { this.player = new Characters.player(); this.messageHandler = messageHandler; this.mainGameForm = mainGameForm; this.mainGameForm.TurnChangedEvent += mainGameForm_TurnChangedEvent; }
private static int PlayTurn(string plrfile = null) { if (plrfile != null) { if (File.Exists(plrfile)) { try { Galaxy.Current.LoadCommands(); } catch { MessageBox.Show("An error occurred while loading your commands. You will need to restart your turn from the beginning."); Galaxy.Load(Galaxy.Current.GameFileName); // in case some commands got loaded } } else { MessageBox.Show(plrfile + " does not exist. You will need to start your turn from the beginning."); } } Design.ImportFromLibrary(); var form = new MainGameForm(false, true); form.KeyPreview = true; form.StartPosition = FormStartPosition.CenterScreen; form.KeyDown += GuiExtensions.childForm_KeyDown_forDebugConsole; Application.Run(form); return(0); }
public static KontrolerWalki GetInstance( MainGameForm _frm) { if (instance == null) { instance = new KontrolerWalki(_frm); return instance; } else return instance; }
/// <summary> /// Creates a log form. /// </summary> /// <param name="mainGameForm"></param> /// <param name="battle">The battle whose log we should display, or null to display the turn log.</param> public LogForm(MainGameForm mainGameForm, IList <LogMessage> log) { InitializeComponent(); this.mainGameForm = mainGameForm; messages = log.OrderByDescending(m => m.TurnNumber).ToArray(); try { this.Icon = new Icon(FrEee.WinForms.Properties.Resources.FrEeeIcon); } catch { } ShowInTaskbar = !mainGameForm.HasLogBeenShown; }
private void btnPlayerView_Click(object sender, EventArgs e) { if (gridEmpires.SelectedRows.Count == 1) { var status = (EmpireStatus)gridEmpires.SelectedRows[0].DataBoundItem; var emp = status.Empire; if (emp.IsDefeated) { MessageBox.Show(emp + " is defeated. There is nothing to view."); } else { if (MessageBox.Show("Really show the player view for " + emp + "?\nThis is intended primarily for AI debugging, but it can also be used to cheat in multiplayer!", "Confirm Player View", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { if (emp.IsPlayerEmpire) { // load GAM file if possible var savefile = Galaxy.Current.GetGameSavePath(emp); try { Galaxy.Load(savefile); } catch (IOException) { MessageBox.Show("Could not load " + savefile + ". Attempting to recreate player view."); Galaxy.Current.CurrentEmpire = emp; Galaxy.Current.Redact(); } } else { // AI empires have no GAM files, so create their views in memory Galaxy.Current.CurrentEmpire = emp; Galaxy.Current.Redact(); } Design.ImportFromLibrary(); var form = new MainGameForm(true, false); Hide(); this.ShowChildForm(form); Show(); ReloadGalaxy(); Bind(); // in case the host saved the commands } } } else { MessageBox.Show("Please select an empire in order to show the player view."); } }
private void btnLoadGame_Click(object sender, EventArgs e) { if (save == "Yes") { //load save MainGameForm f1 = new MainGameForm(); f1.StartPosition = FormStartPosition.CenterParent; f1.ShowDialog(this); } else { MessageBox.Show("No save found. Start new game."); } }
public static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var selector = new LocaleSelector(); selector.Activate(); selector.ShowDialog(null); if (selector.DialogResult != DialogResult.OK) { return; } CultureInfo.CurrentCulture = selector.TargetCulture; CultureInfo.CurrentUICulture = selector.TargetCulture; CultureInfo.DefaultThreadCurrentCulture = selector.TargetCulture; CultureInfo.DefaultThreadCurrentUICulture = selector.TargetCulture; var rnd = new Random(); WaitRollDice.Rnd = rnd; ItemContainer.Rnd = rnd; var view = new MainGameForm(); // Construct the initial game data structures var presenter = new Presenter(view); var board = new GameBoard(); var bank = new Bank(); var playerList = new List <Player> { new Player(PlayerColor.Blue), new Player(PlayerColor.Orange), new Player(PlayerColor.Red), new Player(PlayerColor.White) }; var gameModel = new GameModel(board, bank, playerList, presenter); var manager = new TurnManager(gameModel); presenter.RegisterTurnManager(manager); board.InitializeView(presenter); var t = new Thread(presenter.MainLoop); t.Start(); Application.Run(view); }
private void LoadGalaxyFromFile(string filename, bool?loadPlr = null) { Cursor = Cursors.WaitCursor; var plrfile = Path.GetFileNameWithoutExtension(filename) + ".plr"; Galaxy.Load(filename); if (Galaxy.Current.CurrentEmpire == null) { // host view, load host console Cursor = Cursors.WaitCursor; var form = new HostConsoleForm(); Cursor = Cursors.Default; Hide(); this.ShowChildForm(form); Show(); } else { // player view, load up the game if (File.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Savegame", plrfile))) { if (loadPlr == null) { loadPlr = MessageBox.Show("Player commands file exists for this turn. Resume turn from where you left off?", "Resume Turn", MessageBoxButtons.YesNo) == DialogResult.Yes; } if (loadPlr.Value) { Galaxy.Current.LoadCommands(); } } // load library designs Design.ImportFromLibrary(); // display game view var form = new MainGameForm(false, true); Cursor = Cursors.Default; Hide(); this.ShowChildForm(form); Show(); } }
public TestGame(MainGameForm.MessageHandler messageHandler, MainGameForm mainGameForm) : base(messageHandler, mainGameForm) { Init(); }
private KontrolerWalki(MainGameForm _frm) { this.mainGameForm = _frm; listaAgresorow = new List<Agresor>(); }
private void btnQuickStart_Click(object sender, EventArgs e) { var status = new Status { Progress = 0d, Message = "Initializing", Exception = null, }; string[] warnings = new string[0]; Thread t = new Thread(new ThreadStart(() => { #if RELEASE try { #endif bool doOrDie = true; if (Mod.Current == null) { status.Message = "Loading mod"; Mod.Load(null, true, status, 0.5); if (Mod.Errors.Any()) { Action a = delegate() { doOrDie = this.ShowChildForm(new ModErrorsForm()) == System.Windows.Forms.DialogResult.OK; }; this.Invoke(a); } } if (doOrDie) { status.Message = "Setting up game"; var setup = GameSetup.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "GameSetups", "Quickstart.gsu")); warnings = setup.Warnings.ToArray(); if (warnings.Any()) { MessageBox.Show(warnings.First(), "Game Setup Error"); } else { var dlg = new OpenFileDialog(); dlg.InitialDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Empires"); dlg.Filter = "Empires (*.emp)|*.emp"; var result = dlg.ShowDialog(); if (result == DialogResult.OK) { // replace existing first player with selected empire var et = EmpireTemplate.Load(dlg.FileName); setup.EmpireTemplates.RemoveAt(0); setup.EmpireTemplates.Insert(0, et); // set race trait points to however many were spent setup.EmpirePoints = et.PointsSpent; } status.Message = "Setting up galaxy"; Galaxy.Initialize(setup, null, status, 1.0); var name = Galaxy.Current.Name; var turn = Galaxy.Current.TurnNumber; status.Message = "Loading game"; Galaxy.Load(name + "_" + turn + "_0001.gam"); } } #if RELEASE } catch (Exception ex) { status.Exception = ex; } #endif })); t.Name = "Game Setup"; t.SetApartmentState(ApartmentState.STA); this.ShowChildForm(new StatusForm(t, status)); if (status.Exception == null && !warnings.Any()) { Design.ImportFromLibrary(); var game = new MainGameForm(false, true); this.ShowChildForm(game); game.FormClosed += (s, args) => { game.Dispose(); Show(); }; Hide(); } }
private KontrolerGry(MainGameForm _form) { this.form = _form; poleWalki = KontrolerWalki.GetInstance(form); }
public static KontrolerGry GetInstance(MainGameForm _form) { if (instance == null) { instance = new KontrolerGry(_form); return instance; } else { return instance; } }
private void btnStartGame_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to start the game as a " + _player.GenderName + " " + _player.MagicAffinityName + _player.RaceName + " " + _player.ClassName + "?", "Warning!!", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (AvailableClasses[_player.ClassID - 1] && AvailableRaces[_player.RaceID - 1]) { StreamWriter sw = new StreamWriter("PlayerInfo.txt"); sw.WriteLine(_player.GenderID.ToString()); sw.WriteLine(_player.ClassID.ToString()); sw.WriteLine(_player.RaceID.ToString()); sw.WriteLine(_player.BaseStrengh.ToString()); sw.WriteLine(_player.BaseHp.ToString()); sw.WriteLine(_player.BaseArmor.ToString()); sw.WriteLine(_player.BaseAttackDamage.ToString()); sw.WriteLine(_player.BaseAgility.ToString()); sw.WriteLine(_player.BaseEvasion.ToString()); sw.WriteLine(_player.BaseAttackSpeed.ToString()); sw.WriteLine(_player.BaseArmorPenetration.ToString()); sw.WriteLine(_player.BaseIntelligence.ToString()); sw.WriteLine(_player.BaseMagicDefense.ToString()); sw.WriteLine(_player.BaseMagicPenetration.ToString()); sw.WriteLine(_player.BaseMagicPower.ToString()); sw.WriteLine(_player.ClassName.ToString()); sw.WriteLine(_player.GenderName.ToString()); sw.WriteLine(_player.RaceName.ToString()); sw.Close(); foreach (Weapon s in World.Weapons) { if (s.ID == _player.ClassID) { StreamWriter sw1 = new StreamWriter("EquipedWeapon.txt"); sw1.WriteLine(s.Class); sw1.WriteLine(s.ID); sw1.WriteLine(s.ImageAdress); sw1.WriteLine(s.Info); sw1.WriteLine(s.Lvl); sw1.WriteLine(s.MaxDmg); sw1.WriteLine(s.MinDmg); sw1.WriteLine(s.Name); sw1.WriteLine(s.CritChance); sw1.WriteLine(s.CritMult); sw1.WriteLine(s.Armor); sw1.WriteLine(s.MagicDefense); sw1.WriteLine(s.ArmorPenetration); sw1.Close(); } } StreamWriter sw2 = new StreamWriter("EquipedArmor.txt"); sw2.WriteLine("0"); sw2.WriteLine("0"); sw2.WriteLine("0"); sw2.WriteLine("0"); sw2.WriteLine("0"); sw2.WriteLine("0"); sw2.WriteLine("0"); sw2.WriteLine("0"); sw2.Close(); MainGameForm f = new MainGameForm(); f.StartPosition = FormStartPosition.CenterParent; f.ShowDialog(this); } else { MessageBox.Show("Unavailable class or Race"); } } else if (dialogResult == DialogResult.No) { //do nothing lel } }
public BabySitting(MainGameForm.MessageHandler messageHandler, MainGameForm mainGameForm) { this.messageHandler = messageHandler; this.mainGameForm = mainGameForm; Init(); }