private void ending(object o, EventArgs e) { Story credit = new Story("Credits"); credit.Done = game_end; StateManager.Instance.goForward(credit); }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (lbl_battleOutcome.Visible) { // The battle is over, player sees the outcome return; } if (ai.Active) { // The AI is doing his work, silly player not interfere ai.Update(gameTime); return; } if (targetMode) { // Player is selecting a target for character's action if (InputHandler.keyReleased(Keys.Down) || InputHandler.keyReleased(Keys.Up)) { // Focus on next/previous target map.CurLs.Clear(); foreach (Point c in targetableChar) { map.changeCurp(this, new EventArgObject(c)); if (c == targetableChar[menu_actions.Selected]) { map.CurLs.Add(p, Content.Graphics.Instance.Images.gui.cursorRed); } else map.CurLs.Add(p, Content.Graphics.Instance.Images.gui.cursor); } map.changeCurp(this, new EventArgObject(targetableChar[menu_actions.Selected])); showCharLabels(); } if (InputHandler.keyReleased(Keys.Enter)) { // Target confirmed Character m=cmap.get(scp.X, scp.Y); Character t=cmap.get(p.X, p.Y); String dmg; lbl_actionTaken.Text = ""; //Character execute his action and action label is displayed if (m is Fighter) dmg = ((Fighter)m).attack(t); else if (m is Archer) dmg = ((Archer)m).attack(t); else if (m is Scout) dmg = ((Scout)m).attack(t); else if (m is Healer) { dmg = ((Healer)m).heal(t).ToString(); lbl_actionTaken.Text = "Heal"; } else if (m is Caster) { dmg = ((Caster)m).attack(t, selectedSpell); lbl_actionTaken.Text = selectedSpell.Name; } else dmg = "Cant"; //missingno if (lbl_actionTaken.Text == "") lbl_actionTaken.Text = "Attack"; // Damage label is displayed lbl_dmg.Text = dmg; lbl_dmg.Position = new Vector2(p.X * 64 - map.getTlc.X * 64 + 10, p.Y * 64 - map.getTlc.Y * 64 + 20); lbl_dmg.visibleTemp(500); lbl_actionTaken.visibleTemp(500); // Character gains EXP if (dmg != "miss" || dmg != "Cant") { if (m is Healer) cmap.get(scp.X, scp.Y).gainExp(cmap.get(p.X, p.Y)); if (t.stats.hp <= 0) { // Enemy got killed cmap.get(scp.X, scp.Y).gainExp(cmap.get(p.X, p.Y)); enemy.delete(t.Position.X, t.Position.Y); cmap.set(p.X, p.Y, null); cmap.update(map); if (goal.Type == Objective.Objective_Type.DEFEAT_BOSS && t == goal.Char) { // Enemy killed was a boss region.win = true; lbl_battleOutcome.Text = "VICTORY!"; lbl_battleOutcome.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL; lbl_battleOutcome.visibleTemp(2000); MainWindow.InputEnabled = false; return; } if (enemy.Characters.Count == 0) { // Enemy killed was the last one remaining if (goal.Type == Objective.Objective_Type.DEFEAT_UNIT && enemy == goal.Unit) region.win = true; lbl_battleOutcome.Text = "VICTORY!"; lbl_battleOutcome.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL; lbl_battleOutcome.visibleTemp(2000); MainWindow.InputEnabled = false; return; } } } map.changeCurp(this, new EventArgObject(scp)); lbl_enterAction.Text = "Select Unit"; lbl_escAction.Text = "Cancel Move"; lbl_esc.Visible = false; lbl_escAction.Visible = false; freemode = true; map.ArrowEnabled = true; map.Enabled = true; lbl_v.Visible = true; lbl_vAction.Visible = true; lbl_e.Visible = true; lbl_eAction.Visible = true; cmap.get(p.X, p.Y).stats.movement = 0; lbl_move.Text = cmap.get(scp.X, scp.Y).stats.movement.ToString(); lbl_moved.Visible = true; map.TabStop = true; map.HasFocus = true; menu_actions.clear(); menu_actions.add(new Link("Attack")); menu_actions.add(new Link("Spell")); menu_actions.add(new Link("Items")); menu_actions.add(new Link("Wait")); lbl_actions.Visible = false; menu_actions.Visible = false; menu_actions.Enabled = false; menu_actions.ArrowEnabled = false; menu_actions.HasFocus = false; actionMode = false; targetMode = false; itemMode = false; map.CurLs.Clear(); } if (InputHandler.keyReleased(Keys.Escape)) { // Player cancel's the character's action hideCharLabels(); targetMode = false; menu_actions.clear(); menu_actions.add(new Link("Attack")); menu_actions.add(new Link("Spell")); menu_actions.add(new Link("Items")); menu_actions.add(new Link("Wait")); map.changeCurp(this, new EventArgObject(scp)); setEnabled(); map.CurLs.Clear(); } } else if (itemMode) { // Player is selecting an item to use if (InputHandler.keyReleased(Keys.Enter)) { // Confirm selected item if (!menu_actions.getLink(menu_actions.Selected).Enabled) return; itemMode = false; freemode = true; // Character uses item Item i = ally.Inventory.getConsumable()[menu_actions.Selected]; Character c = cmap.get(scp.X, scp.Y); if (i.Name == "The Prophet's Amulet" && region.RegionName == "Umbilicus") { Story s = new Story("Amulet"); s.Done = prophet_sret; StateManager.Instance.goForward(s); } else c.consume(i); // Item is removed from inventory ally.Inventory.Items.Remove(i); // Action & damage labels are displayed lbl_actionTaken.Text = i.Name; lbl_actionTaken.center(); lbl_actionTaken.visibleTemp(1000); lbl_dmg.Text = "hp: " + i.Effect.hp + "\nmana: " + i.Effect.mp; lbl_dmg.Position = new Vector2(scp.X * 64 - map.getTlc.X * 64 + 10, scp.Y * 64 - map.getTlc.Y * 64 + 20); lbl_dmg.visibleTemp(1000); lbl_enterAction.Text = "Select Unit"; lbl_escAction.Text = "Cancel Move"; lbl_esc.Visible = false; lbl_escAction.Visible = false; freemode = true; map.ArrowEnabled = true; map.Enabled = true; lbl_v.Visible = true; lbl_vAction.Visible = true; lbl_e.Visible = true; lbl_eAction.Visible = true; cmap.get(p.X, p.Y).stats.movement--; lbl_move.Text = cmap.get(scp.X, scp.Y).stats.movement.ToString(); lbl_moved.Visible = true; map.changeCurp(this, new EventArgObject(scp)); map.TabStop = true; map.HasFocus = true; menu_actions.clear(); menu_actions.add(new Link("Attack")); menu_actions.add(new Link("Spell")); menu_actions.add(new Link("Items")); menu_actions.add(new Link("Wait")); lbl_actions.Visible = false; menu_actions.Visible = false; menu_actions.Enabled = false; menu_actions.ArrowEnabled = false; menu_actions.HasFocus = false; actionMode = false; targetMode = false; itemMode = false; map.CurLs.Clear(); } if (InputHandler.keyReleased(Keys.Escape)) { // Player cancel's the character's action hideCharLabels(); targetMode = false; menu_actions.clear(); menu_actions.add(new Link("Attack")); menu_actions.add(new Link("Spell")); menu_actions.add(new Link("Items")); menu_actions.add(new Link("Wait")); map.changeCurp(this, new EventArgObject(scp)); setEnabled(); map.CurLs.Clear(); } } else if (spellMode) { // Player is selecting a spell for the character to cast if (InputHandler.keyReleased(Keys.Enter)) { // Confirm spell selection if (!menu_actions.getLink(menu_actions.Selected).Enabled) return; spellMode = false; targetMode = true; Caster cc = (Caster)cmap.get(scp.X, scp.Y); selectedSpell = cc.getCastableSpells().getSpell(menu_actions.SelectedText); targetMode = true; menu_actions.clear(); foreach (Point point in targetableChar) { menu_actions.add(new Link(cmap.get(point.X, point.Y).Name)); } map.CurLs.Clear(); foreach (Point c in targetableChar) { map.changeCurp(this, new EventArgObject(c)); if (c == targetableChar[menu_actions.Selected]) map.CurLs.Add(p, Content.Graphics.Instance.Images.gui.cursorRed); else map.CurLs.Add(p, Content.Graphics.Instance.Images.gui.cursor); } map.changeCurp(this, new EventArgObject(targetableChar[0])); showCharLabels(); } } else if (actionMode) { // Player is selecting what action the character is going to do if (InputHandler.keyReleased(Keys.Enter)) { // Action confirmed if (!menu_actions.getLink(menu_actions.Selected).Enabled) // Not an available action return; if (menu_actions.SelectedText == "Spell") { // Spell selected Caster c = (Caster)cmap.get(scp.X, scp.Y); menu_actions.clear(); Link l; foreach (Spell sp in c.getCastableSpells().toList()) { l = new Link(sp.Name); if (c.stats.mana < sp.ManaCost) disableLink(l); menu_actions.add(l); } setEnabled(); spellMode = true; } else if (menu_actions.SelectedText == "Items") { // Items selected menu_actions.clear(); foreach (Item i in ally.Inventory.getConsumable()) menu_actions.add(new Link(i.Name)); itemMode = true; } else if (menu_actions.SelectedText == "Attack" || menu_actions.SelectedText == "Heal") { // Attack or Heal selected targetMode = true; menu_actions.clear(); foreach (Point point in targetableChar) { menu_actions.add(new Link(cmap.get(point.X, point.Y).Name)); } map.CurLs.Clear(); foreach (Point c in targetableChar) { map.changeCurp(this, new EventArgObject(c)); if (c == targetableChar[menu_actions.Selected]) map.CurLs.Add(p, Content.Graphics.Instance.Images.gui.cursorRed); else map.CurLs.Add(p, Content.Graphics.Instance.Images.gui.cursor); } map.changeCurp(this, new EventArgObject(targetableChar[0])); showCharLabels(); } else { // Derp? lbl_enterAction.Text = "Select Unit"; lbl_escAction.Text = "Cancel Move"; lbl_esc.Visible = false; lbl_escAction.Visible = false; freemode = true; map.ArrowEnabled = true; map.Enabled = true; lbl_v.Visible = true; lbl_vAction.Visible = true; lbl_e.Visible = true; lbl_eAction.Visible = true; cmap.get(p.X, p.Y).stats.movement = 0; lbl_move.Text = cmap.get(scp.X, scp.Y).stats.movement.ToString(); lbl_moved.Visible = true; map.TabStop = true; map.HasFocus = true; lbl_actions.Visible = false; menu_actions.Visible = false; menu_actions.Enabled = false; menu_actions.ArrowEnabled = false; menu_actions.HasFocus = false; actionMode = false; } } if (InputHandler.keyReleased(Keys.Escape)) { // Cancel and go back to character's movement lbl_enterAction.Text = "Confirm Move"; lbl_escAction.Text = "Cancel Move"; map.TabStop = true; map.HasFocus = true; lbl_actions.Visible = false; menu_actions.Visible = false; menu_actions.Enabled = false; menu_actions.ArrowEnabled = false; menu_actions.HasFocus = false; actionMode = false; } } else if (!freemode) { // Player is currently moving a character if (InputHandler.keyReleased(Keys.Up)) { Point cp = scp; moveChar(new Point(cp.X, --cp.Y)); } if (InputHandler.keyReleased(Keys.Down)) { Point cp = scp; moveChar(new Point(cp.X, ++cp.Y)); } if (InputHandler.keyReleased(Keys.Left)) { Point cp = scp; moveChar(new Point(--cp.X, cp.Y)); } if (InputHandler.keyReleased(Keys.Right)) { Point cp = scp; moveChar(new Point(++cp.X, cp.Y)); } if (InputHandler.keyReleased(Keys.Escape)) { // Cancel character's movement lbl_enterAction.Text = "Select Unit"; lbl_esc.Visible = false; lbl_escAction.Visible = false; cmap.get(scp.X, scp.Y).stats.movement++; moveChar(returnP); cmap.get(scp.X, scp.Y).stats.movement = (int)cmap.get(scp.X, scp.Y).stats.traits.spd / 10; lbl_move.Text = cmap.get(scp.X, scp.Y).stats.movement.ToString(); freemode = true; map.ArrowEnabled = true; map.Enabled = true; lbl_v.Visible = true; lbl_vAction.Visible = true; lbl_e.Visible = true; lbl_eAction.Visible = true; } if (InputHandler.keyReleased(Keys.Enter)) { // Confirm character's movement lbl_enterAction.Text = "Select Action"; lbl_escAction.Text = "Cancel Action"; map.TabStop = false; map.HasFocus = false; menu_actions.clear(); Character c = cmap.get(scp.X, scp.Y); if (!(c is Healer)) menu_actions.add(new Link("Attack")); if (c is Healer) menu_actions.add(new Link("Heal")); else menu_actions.add(new Link("Spell")); menu_actions.add(new Link("Items")); menu_actions.add(new Link("Wait")); setEnabled(); lbl_actions.Visible = true; menu_actions.Visible = true; menu_actions.Enabled = true; menu_actions.ArrowEnabled = true; menu_actions.HasFocus = true; actionMode = true; } } else { //Freemode cmap.update(map); if (InputHandler.keyReleased(Keys.V) && lbl_v.Visible) { // View Character Infos StateManager.Instance.goForward(new CharManage(cmap.get(p.X, p.Y), null)); } if (InputHandler.keyReleased(Keys.E)) { // End turn foreach (Character c in ally.Characters) { c.stats.movement = (int)c.stats.traits.spd / 10; } if (cmap.isChar(p.X, p.Y)) { lbl_moved.Visible = false; lbl_move.Text = cmap.get(p.X, p.Y).stats.movement.ToString(); } endTurnP = p; lbl_armyTurn.Text = "ENEMY TURN"; lbl_armyTurn.Color = Color.Red; lbl_armyTurn.center(); lbl_armyTurn.visibleTemp(1000); MainWindow.InputEnabled = false; } } }
public override void resume() { base.resume(); GameState.CurrentState.mainArmy.undeployAll(); updateMap(); lbl_citiesNum.Text = GameState.CurrentState.getCaptureNum("main").ToString(); lbl_incomeNum.Text = (Content.Instance.money_info.perRegion * GameState.CurrentState.getCaptureNum("main")).ToString(); if (GameState.CurrentState.isCaptured("Silenda", "main")) { if (GameState.CurrentState.alignment > 0) { Story s = new Story("VetusBadEnding"); s.Done = ending; StateManager.Instance.goForward(s); } else { Story s = new Story("NovumBadEnding"); s.Done = ending; StateManager.Instance.goForward(s); } } else if (GameState.CurrentState.isCaptured("Pestis Woods", "main")) { if (GameState.CurrentState.alignment >= 0) { Story s = new Story("VetusGoodEnding"); s.Done = ending; StateManager.Instance.goForward(s); } else { Story s = new Story("NovumGoodEnding"); s.Done = ending; StateManager.Instance.goForward(s); } } if (MediaPlayer.State == MediaState.Stopped) { MediaPlayer.Play(Content.Instance.audio.songs.worldMap); MediaPlayer.IsRepeating = true; } }
private void cont(object sender, EventArgs e) { if (txt_name.Text != "") { genArmy(); GameState.CurrentState.gen = Content.Instance.gen.Fog; GameState.CurrentState.mainCharPos = new Point(Content.Instance.gen.StartingPosition.X, Content.Instance.gen.StartingPosition.Y); Story s = new Story("intro"); s.Done = cont_world; StateManager.Instance.reset(s); } else lbl_err.visibleTemp(2000); }