コード例 #1
0
        public GuiMap(int x, int y, MDRParty party = null)
            : base(x, y)
        {
            Util.Assert((CoM.Instance != null) && CoM.GraphicsLoaded, "GUI graphics must be loaded in order to create a GuiMap component.");
            MapIcons   = CoM.Instance.MapIconSprites.GetSprites().ToArray();
            this.Party = party;
            if (party != null)
            {
                this.Map = Party.ExploredMap;
            }

            Background.Color  = Color.white;
            Background.Sprite = ResourceManager.GetSprite("Backgrounds/DarkMap");
            if (!STATIC_BACKGROUND)
            {
                Background.Align  = GuiAlignment.None;
                Background.Width  = (32 + (BACKGROUND_BORDER * 2)) * TILE_SIZE;
                Background.Height = (32 + (BACKGROUND_BORDER * 2)) * TILE_SIZE;
            }
            else
            {
                Background.Align = GuiAlignment.Full;
            }

            Mode = MapMode.Full;
        }
コード例 #2
0
ファイル: MDRAction.cs プロジェクト: bsimser/CoM
 /**
  * Executes this action with given context.
  * Most spells and items can be executed, however some actions, such as fight or defend are handled by
  * the combat engine.
  */
 public void Execute(MDRCharacter character, MDRParty party)
 {
     Trace.LogDebug("EXECUTING {0} on {1}", this, character);
     switch (Type)
     {
     case ActionType.Spell:
         ExecuteSpell(character, party);
         break;
     }
 }
コード例 #3
0
ファイル: CoM.cs プロジェクト: bsimser/CoM
    /** Starts playing the game with given party.  Game will be initalized, and dungeon loaded as appropriate */
    public static void LoadParty(MDRParty newParty)
    {
        Util.Assert(AllDataLoaded, "Data must be loaded before a party can be run.");
        Util.Assert(newParty != null, "Can not start game with null party.");

        Trace.Log("Starting game with party " + newParty);

        Party = newParty;

        //2: work out which level we need to instantiate
        Instance.DungeonState = new DungeonState();
        PopAllStates();
        PushState(Instance.DungeonState);

        PartyController.Instance.Party = Party;
    }
コード例 #4
0
        /** Creates buttons for each party, allowing the user to select one of them. */
        private void updatePartyList()
        {
            CoM.CleanParties();
            partyList.Clear();
            int yPos = 0;

            foreach (MDRParty party in CoM.PartyList)
            {
                var partyButton = new GuiPartySpan(party)
                {
                    X = 0, Y = yPos
                };
                partyButton.OnMouseClicked += delegate {
                    selectParty(partyButton.Party);
                };
                partyList.Add(partyButton);
                yPos += partyButton.Height;
            }

            if (AllowCreateParty)
            {
                //var createButton = new GuiButton("Create New Party", GuiPartySpan.WIDTH, GuiPartySpan.HEIGHT) { X = 0, Y = yPos };
                var createButton = new GuiPartySpan(null)
                {
                    X = 0, Y = yPos
                };
                createButton.Editable        = false;
                createButton.Caption         = "Create New Party";
                createButton.Color           = Color.gray;
                createButton.OnMouseClicked += delegate {
                    var party = MDRParty.Create();
                    CoM.PartyList.Add(party);
                    var state = new EditPartyState(party, true);
                    Engine.PushState(state);
                };
                partyList.Add(createButton);
                yPos += createButton.Height;
            }

            partyList.FitToChildren();
        }
コード例 #5
0
ファイル: EditPartyState.cs プロジェクト: bsimser/CoM
        public EditPartyState(MDRParty party = null, bool createInsteadOfEdit = false)
            : base("Edit Party State")
        {
            var windowTitle = createInsteadOfEdit ? "Create Party" : "Edit Party";

            window = new GuiWindow(600, 520, windowTitle);

            window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow");
            window.Background.Color  = new Color(0.4f, 0.42f, 0.62f);

            characterSlotsPanel       = new GuiPanel(500, 110);
            characterSlotsPanel.Color = Color.clear;
            characterSlotsPanel.Align = GuiAlignment.Top;
            window.Add(characterSlotsPanel);

            characterSlot = new GuiCharacterSlot[4];

            for (int lp = 0; lp < 4; lp++)
            {
                var slot = new GuiCharacterSlot();
                slot.Tag          = lp + 1;
                characterSlot[lp] = slot;
                characterSlotsPanel.Add(slot, 0, 10);
                characterSlotsPanel.PositionComponentToColumns(slot, lp + 1, 4, 100);
                characterSlot[lp].OnDDContentChanged += delegate {
                    applyToParty(slot.Tag - 1);
                    refreshUnassignedCharacters();
                };
            }

            unassignedCharacters = new GuiCharacterGrid(true);
            unassignedCharacters.DragDropEnabled       = true;
            unassignedCharacters.OnCreateNewCharacter += delegate {
                refreshUI();
            };

            unassignedCharactersScrollArea = new GuiScrollableArea(550 + 21, 310, ScrollMode.VerticalOnly);
            unassignedCharactersScrollArea.Add(unassignedCharacters);

            var frame = GuiWindow.CreateFrame(unassignedCharactersScrollArea, "", GuiWindowStyle.ThinTransparent);

            frame.Color = new Color(0.1f, 0.1f, 0.1f);
            window.Add(frame, 0, -46, true);

            var unusedCaption = new GuiLabel("<B>Available Heroes</B>", (int)window.ContentsBounds.width + 10, 24);

            unusedCaption.EnableBackground = true;
            unusedCaption.TextAlign        = TextAnchor.MiddleCenter;
            unusedCaption.Color            = Color.Lerp(Colors.BackgroundRed, Color.black, 0.5f);
            unusedCaption.FauxEdge         = true;
            unusedCaption.FontColor        = new Color(1, 1, 1, 0.9f);
            unusedCaption.FontSize         = 18;
            window.Add(unusedCaption, 0, frame.Y - 15);

            doneButton = new GuiButton("Done");
            window.Add(doneButton, 0, -10);

            dispandButton = new GuiButton("Dispand");
            UIStyle.RedWarning(dispandButton);
            window.Add(dispandButton, 0, -10);

            window.PositionComponentToColumns(dispandButton, 1, 2, 100);
            window.PositionComponentToColumns(doneButton, 2, 2, 100);

            doneButton.OnMouseClicked += delegate {
                applyToParty();
                Engine.PopState();
            };

            dispandButton.OnMouseClicked += delegate {
                party.Dispand();
                Engine.PopState();
            };

            Party = party;

            Add(window, 0, 0);
        }
コード例 #6
0
ファイル: EditPartyState.cs プロジェクト: bsimser/CoM
 private void setParty(MDRParty value)
 {
     _party = value;
     refreshUI();
 }
コード例 #7
0
ファイル: GuiPartySpan.cs プロジェクト: bsimser/CoM
        public GuiPartySpan(MDRParty party)
            : base(WIDTH, HEIGHT)
        {
            DepressedOffset = 1;

            Style         = Engine.GetStyleCopy("SmallButton");
            Style.padding = new RectOffset(10, 12, 1, 3);

            portraits = new GuiImage[4];
            names     = new GuiLabel[4];

            TextAlign         = TextAnchor.MiddleCenter;
            FontSize          = 22;
            CaptionDropShadow = true;

            editButton = new GuiButton("Edit", 80, 30);
            editButton.ColorTransform = ColorTransform.Saturation(0.5f);
            Add(editButton, -5, 30, true);
            editButton.Visible = false;

            locationLabel                  = new GuiLabel("", Width, 23);
            locationLabel.FontSize         = 16;
            locationLabel.FontColor        = Color.yellow;
            locationLabel.Color            = Color.black.Faded(0.6f);
            locationLabel.EnableBackground = true;
            locationLabel.TextAlign        = TextAnchor.MiddleCenter;
            locationLabel.Align            = GuiAlignment.Bottom;

            Add(locationLabel);

            editButton.OnMouseClicked += delegate {
                if (Party != null)
                {
                    Engine.PushState(new EditPartyState(Party));
                }
            };

            this._party = party;

            for (int lp = 0; lp < 4; lp++)
            {
                portraits[lp]                   = new GuiImage(lp * BLOCK_WIDTH + ((BLOCK_WIDTH - PORTAIT_WIDTH) / 2), 7);
                portraits[lp].FrameStyle        = Engine.GetStyleCopy("Frame");
                portraits[lp].Framed            = true;
                portraits[lp].InnerShadow       = true;
                portraits[lp].OuterShadow       = true;
                portraits[lp].OuterShadowSprite = ResourceManager.GetSprite("Icons/OuterEdge");
                portraits[lp].OuterShadowColor  = Color.black.Faded(0.25f);
                Add(portraits[lp]);

                names[lp]                  = new GuiLabel("");
                names[lp].FontColor        = new Color(0.9f, 0.9f, 0.9f, 0.9f);
                names[lp].DropShadow       = true;
                names[lp].TextAlign        = TextAnchor.MiddleCenter;
                names[lp].X                = 15 + lp * 125;
                names[lp].Y                = 70;
                names[lp].Width            = BLOCK_WIDTH - 30;
                names[lp].EnableBackground = true;
                names[lp].Color            = new Color(0.2f, 0.2f, 0.2f);
                Add(names[lp]);
            }

            apply();
        }
コード例 #8
0
 private void setParty(MDRParty value)
 {
     _party = value;
     SyncCamera();
 }
コード例 #9
0
 /** Starts game with given party. */
 private void selectParty(MDRParty party)
 {
     CoM.LoadParty(party);
 }
コード例 #10
0
ファイル: MDRAction.cs プロジェクト: bsimser/CoM
 /**
  * Executes a spell action.
  */
 private void ExecuteSpell(MDRCharacter character, MDRParty party)
 {
     /*
      * if (Spell == null)
      *      return;
      * var area = (party == null) ? null : party.Area;
      * var defaultTarget = (area == null) ? null : area.Stack[character.target];
      *
      * int spellCost = Spell.CostFor(character);
      *
      * // Cheat.
      * if (Settings.Advanced.WhiteWizard)
      *      spellCost = 1;
      *
      * if (party.CurrentTile.Antimagic) {
      *      CombatEngine.PostPlayerMessage("{0} is unable to cast {1}, anti-magic square.", CoM.Format(character), CoM.Format(Spell));
      *      return;
      * }
      *
      * if (!character.CanCast(Spell)) {
      *      CombatEngine.PostPlayerMessage("{0} is not able to cast {1}.", CoM.Format(character), CoM.Format(Spell));
      *      return;
      * }
      *
      * if (character.Spells < spellCost) {
      *      CombatEngine.PostPlayerMessage("{0} does not have enough spells to cast {1}.", CoM.Format(character), CoM.Format(Spell));
      *      return;
      * }
      *
      * if (Spell.NeedsTargetSelection && SpecifiedTarget == null) {
      *      Trace.LogDebug("No target selected in time to cast {0}, will try again next round.", Spell);
      *      return;
      * }
      *
      * var results = new List<SpellResult>();
      *
      * switch (Spell.SpellTarget) {
      *      case SpellTarget.Area:
      *              results = Spell.CastArea(character, area);
      *              break;
      *      case SpellTarget.Party:
      *              results = Spell.CastParty(character, party);
      *              break;
      *      default:
      *              var info = Spell.CastTargeted(character, SpecifiedTarget ?? defaultTarget);
      *              if (info != null && info.DidCast)
      *                      results.Add(info);
      *              break;
      * }
      *
      * if (results.Count >= 1) {
      *      character.Spells -= spellCost;
      *      SoundManager.Play(Spell.SpellClass.SFXName);
      * }
      *
      * // reset action after targeted spell
      * if (Spell.NeedsTargetSelection) {
      *      character.DefaultAction();
      * }
      *
      * //for (int lp = 0; lp < results.Count; lp++)
      * //	CombatEngine.PostPlayerMessage(results[lp].ToString());
      */
 }
コード例 #11
0
        public AllPartyMembersDeadState(MDRParty party) : base("Party has Died")
        {
            Party = party;

            Window.Width  = 500;
            Window.Height = 300;

            costToHire = GameRules.CostToHireRescue(party.Depth);

            var label = new GuiLabel("", 450, 200);

            label.Color     = Colors.FourNines;
            label.TextAlign = TextAnchor.UpperCenter;
            label.WordWrap  = true;
            Window.Add(label, 0, 0, true);

            var okButton = new GuiButton("Ok");

            okButton.Visible = false;
            Window.Add(okButton, 0, -20, true);

            var returnButton = new GuiButton("Return to Menu", 160, 24);

            returnButton.Visible = false;
            Window.Add(returnButton, 0, 20, true);

            var hireButton = new GuiButton("Hire", 140, 30);

            hireButton.Visible     = false;
            hireButton.SelfEnabled = Party.Gold >= costToHire;
            Window.Add(hireButton, 0, -25, true);

            var hireCost = new GuiCoinAmount();

            Window.Add(hireCost, (int)hireButton.Bounds.xMax + 20, -31, true);
            hireCost.Value   = costToHire;
            hireCost.Visible = false;

            var retrieveButton = new GuiButton("Retrieve");

            retrieveButton.Visible = false;
            Window.Add(retrieveButton, 0, 0);

            string message = "All party members have died.\n";

            if (party.Depth == 1)
            {
                message         += "\nThankfuly some friendly adventures have found you and brought you back to the town temple.";
                okButton.Visible = true;
            }
            else if (party.Depth < 10)
            {
                message += "\nIt might take a while for anyone to find you down here.";

                if (Party.Gold >= costToHire)
                {
                    message += "\n\nYou'll need to either hire some adventurers or organise your own rescue party.";
                }
                else
                {
                    message += "\n\nLooks like you don't have enough to hire a rescue party.";
                    message += "\nTogether you have only {0}.";
                    message += "\n\nYou'll need to either form your own rescue party or have another character pay to send rescuers out.";

                    Window.Height += 60;
                }

                returnButton.Visible = true;
                hireCost.Visible     = true;
                hireButton.Visible   = true;
            }
            else
            {
                message += "\nVery few venture this deep.  You won't be able to hire any adventures this time.";
                message += "\nYou need to either organise your own rescue party or pay at the temple for them to retrieve your soul.";
                returnButton.Visible   = true;
                retrieveButton.Visible = true;
            }

            label.Caption = string.Format(message, CoM.CoinsAmount(Party.Gold));

            okButton.OnMouseClicked += delegate {
                CoM.AutoGotoTemple = true;
                CoM.Party.ReturnToTown();
                Engine.PopState();
            };

            hireButton.OnMouseClicked += delegate {
                CoM.AutoGotoTemple = true;
                CoM.Party.DebitGold(costToHire);
                CoM.Party.ReturnToTown();
                Engine.PopState();
            };

            returnButton.OnMouseClicked += CoM.ReturnToMainMenu;
        }