示例#1
0
        /**
         * Updates the infomation panel descripting the raising details for the selected character
         */
        private void doUpdateRaiseInfo()
        {
            MDRCharacter character = deadCharactersList.Selected;

            raiseCost = GameRules.CostToRaise(character);

            if (character == null)
            {
                raiseInfo.Caption = "";
                costLabel.Visible = false;
                return;
            }

            string notice = "{0} has died.";

            if (raiseCost == 0)
            {
                notice += "\n\nBecause {0} is less than level 10 the temple has agreed to raise him for free.";
            }
            else
            {
                notice += "\n\nThe cost to raise {0} is {1}";
                if (raiseCost > CoM.Party.Gold)
                {
                    notice += "\nHowever you only have {2}.";
                }
            }

            raiseInfo.Caption = string.Format(notice, CoM.Format(character), CoM.CoinsAmount(raiseCost), CoM.CoinsAmount(CoM.Party.Gold));

            costLabel.Visible = true;
            costLabel.Value   = raiseCost;
        }
示例#2
0
        /**
         * Causes detials in the perceived tile to be copied across from the actual tile, will also log messages
         * decribing the new features discovered.  Returns true if any update occured
         *
         * @returns if any changes where made.
         */
        private bool detectSquare(FieldRecord perceivedTile, FieldRecord actualTile, string message, MDRCharacter character)
        {
            string detailName = "";

            if (perceivedTile.FaceNorth != actualTile.FaceNorth)
            {
                detailName += "a face north, ";
            }
            if (perceivedTile.FaceEast != actualTile.FaceEast)
            {
                detailName += "a face east, ";
            }
            if (perceivedTile.FaceWest != actualTile.FaceWest)
            {
                detailName += "a face west, ";
            }
            if (perceivedTile.FaceSouth != actualTile.FaceSouth)
            {
                detailName += "a face south, ";
            }

            if (perceivedTile.Antimagic != actualTile.Antimagic)
            {
                detailName += "an anti-magic, ";
            }
            if (perceivedTile.Rotator != actualTile.Rotator)
            {
                detailName += "a rotator, ";
            }
            if (perceivedTile.Extinguisher != actualTile.Extinguisher)
            {
                detailName += "an extinguisher, ";
            }
            if (perceivedTile.Stud != actualTile.Stud)
            {
                detailName += "a stud, ";
            }

            if (detailName != "")
            {
                CoM.PostMessage(message, CoM.Format(character), detailName.TrimEnd(new char[] { ' ', ',' }));
            }

            perceivedTile.FaceNorth    = actualTile.FaceNorth;
            perceivedTile.FaceEast     = actualTile.FaceEast;
            perceivedTile.FaceWest     = actualTile.FaceWest;
            perceivedTile.FaceSouth    = actualTile.FaceSouth;
            perceivedTile.Antimagic    = actualTile.Antimagic;
            perceivedTile.Rotator      = actualTile.Rotator;
            perceivedTile.Extinguisher = actualTile.Extinguisher;
            perceivedTile.Stud         = actualTile.Stud;

            return(detailName != "");
        }
示例#3
0
        /** Checks if given value execeeds the current record for given stat.  If it does it sets the new value */
        private void CheckCharacterRecord(string recordName, int value, MDRCharacter character, string objectName = "", string notificationMessage = "{0} has set a new record for being the {1} with a value of {2}.")
        {
            if (Records.ByName(recordName) == null)
            {
                return;
            }

            var record = Records[recordName];

            if (value > record.RecordValue)
            {
                if (record.RecordHolder != character.Name)
                {
                    PostNotification(string.Format(notificationMessage, CoM.Format(character), recordName, CoM.Format(value)), character.Portrait);
                }
                record.Set(character.Name, value, objectName);
            }
        }
示例#4
0
        /**
         * Raises the given character
         */
        private void doRaiseCharacter(MDRCharacter character)
        {
            if (character == null)
            {
                throw new ArgumentNullException("character", "[character] is null.");
            }
            if (!character.IsDead)
            {
                throw new Exception("Character is not dead.");
            }

            if (CoM.Party.Gold < raiseCost)
            {
                Engine.ShowLargeModal("Not Enough Coin",
                                      string.Format(
                                          "The party does not have enough coin to raise {0}.\nYou need {1} but together only have {2}",
                                          CoM.Format(character), CoM.CoinsAmount(raiseCost), CoM.CoinsAmount(CoM.Party.Gold)
                                          ));
                return;
            }

            CoM.Party.DebitGold(raiseCost, character);



            string complicationsMessage = GameRules.RaiseCharacterFromDead(character);

            if (complicationsMessage == "")
            {
                SoundManager.Play("OLDFX_RAISE");
                Engine.ShowModal("Success", string.Format("{0} was successfully raised back to life.", CoM.Format(character)));
            }
            else
            {
                SoundManager.Play("OLDFX_PARAL");
                Engine.ShowModal("Complications", string.Format("\nThere where problems while raising {0}.\n{0} {1}\n", CoM.Format(character), complicationsMessage));
            }

            PopulateDeadCharacterList();
        }
示例#5
0
文件: CoM.cs 项目: bsimser/CoM
    /** Processes a list of objects, finding any that can be formated, and replacing them with their string formatted
     * representation.  I.e. if the list contains a spell the spell will be replaced with the colorised name of the spell */
    public static object[] FormatParameters(object[] args)
    {
        var list = new List <object>();

        foreach (var obj in args)
        {
            object formattedObject = null;
            if (obj is MDRCharacter)
            {
                formattedObject = CoM.Format(obj as MDRCharacter);
            }
            if (obj is MDRSpell)
            {
                formattedObject = CoM.Format(obj as MDRSpell);
            }
            if (obj is MDRItemInstance)
            {
                formattedObject = CoM.Format(obj as MDRItemInstance);
            }
            list.Add(formattedObject ?? obj);
        }
        return(list.ToArray());
    }
示例#6
0
        /** Checks if party is standing on any traps and applied changes. */
        private void checkTraps()
        {
            if (CurrentTile.Pit)
            {
                int numberOfCharactersWhoFell = 0;
                foreach (MDRCharacter character in this)
                {
                    if (character.IsDead)
                    {
                        continue;
                    }
                    if (GameRules.FallRoll(character))
                    {
                        int damage = GameRules.CalculatePitDamage(character);

                        character.ReceiveDamage(damage);

                        string message = character.IsDead ? "{0} fell down a pit, receiving {1} damage, and died." : "{0} fell down a pit receiving {1} damage.";
                        CoM.PostMessage(message, CoM.Format(character), CoM.Format(damage));
                        numberOfCharactersWhoFell++;
                    }
                    else
                    {
                        CoM.PostMessage("{0} avoided the pit.", CoM.Format(character));
                    }
                }
                if (numberOfCharactersWhoFell > 0)
                {
                    SoundManager.Play("OLDFX_FALL");
                }
            }

            if (CurrentTile.Rotator)
            {
                int turns = Util.Roll(4) + 4;

                DelayedDelegates.Add(delegate {
                    for (int lp = 0; lp < turns; lp++)
                    {
                        TurnLeft();
                    }
                    CoM.PostMessage("Party hit a rotator.");
                }, 0.1f);
            }

            if (CurrentTile.Water)
            {
                SoundManager.Play("OLDFX_WADE");
            }
            else
            {
                foreach (MDRCharacter character in this)
                {
                    character.TimeInWater = 0;
                }
            }

            if (CurrentTile.FaceEast)
            {
                Facing = Direction.EAST;
            }
            if (CurrentTile.FaceWest)
            {
                Facing = Direction.WEST;
            }
            if (CurrentTile.FaceSouth)
            {
                Facing = Direction.SOUTH;
            }
            if (CurrentTile.FaceNorth)
            {
                Facing = Direction.NORTH;
            }

            if (CurrentTile.Chute)
            {
                ChuteTrapInfo chute = Map.GetChutAt(LocationX, LocationY);
                if (chute == null)
                {
                    Trace.LogWarning("No chute found at party's current location.");
                }
                else
                {
                    if ((Depth + chute.DropDepth) > Dungeon.Floors)
                    {
                        CoM.PostMessage("This chute doesn't seem to go anywhere.  You can't help but feel fortunate.");
                    }
                    else
                    {
                        int numberOfCharactersWhoFell = 0;
                        foreach (MDRCharacter character in this)
                        {
                            if (character.IsDead)
                            {
                                continue;
                            }
                            if (GameRules.FallRoll(character))
                            {
                                numberOfCharactersWhoFell++;
                            }
                        }

                        if (numberOfCharactersWhoFell == LivingMembers)
                        {
                            Depth += chute.DropDepth;
                            CoM.PostMessage("Party fell down a chute");
                            SoundManager.Play("OLDFX_FALL");
                        }
                        else
                        {
                            CoM.PostMessage("Party avoided falling down a chute");
                        }
                    }
                }
            }

            if (CurrentTile.Teleporter)
            {
                TeleportTrapInfo teleport = Map.GetTeleportAt(LocationX, LocationY);
                if (teleport == null)
                {
                    Trace.LogWarning("No teleport found at party's current location.");
                }
                else
                {
                    if (teleport.DestFloor > Dungeon.Floors)
                    {
                        CoM.PostMessage("The teleport trap fizzes, but doesn't seem to do anything.");
                        return;
                    }

                    int destinationX     = teleport.DestX;
                    int destinationY     = teleport.DestY;
                    int destinationFloor = teleport.DestFloor == 0 ? Depth : teleport.DestFloor;

                    if (teleport.IsRandom())
                    {
                        int trys = 0;
                        while (true)
                        {
                            destinationX = Util.Roll(30);
                            destinationY = Util.Roll(30);
                            if (!Map.GetField(destinationX, destinationY).Rock)
                            {
                                break;
                            }
                            trys++;
                            if (trys > 999)
                            {
                                Trace.LogWarning("Could not find safe place to teleport character to.");
                                return;
                            }
                        }
                    }

                    SoundManager.Play("OLDFX_TELEPORT");

                    SetLocation(destinationX, destinationY, destinationFloor, Facing);

                    Trace.Log("Teleporting characters to " + destinationX + "," + destinationY);
                    CoM.PostMessage("Party hit a teleporter");
                }
            }
        }
示例#7
0
        /** Updates the explored map to reveal the tile the party is standing on. */
        private void updateExploredMap()
        {
            var origionalValue = PerceivedTile.Value;

            bool secretDiscovered = false;

            if (PerceivedTile != null)
            {
                var character = PerceptionCharacter;

                PerceivedTile.Explored   = true;
                PerceivedTile.Water      = CurrentTile.Water;
                PerceivedTile.Pit        = CurrentTile.Pit;
                PerceivedTile.StairsUp   = CurrentTile.StairsUp;
                PerceivedTile.StairsDown = CurrentTile.StairsDown;
                PerceivedTile.Teleporter = CurrentTile.Teleporter;
                PerceivedTile.Dirt       = CurrentTile.Dirt;
                PerceivedTile.Rock       = CurrentTile.Rock;
                PerceivedTile.Chute      = CurrentTile.Chute;
                PerceivedTile.Grass      = CurrentTile.Grass;

                bool blind = false;
                if (!blind)
                {
                    // copy walls, but leave secrets alone
                    for (int lp = 0; lp < 4; lp++)
                    {
                        WallRecord wall                = new WallRecord();
                        var        actualWallRecord    = CurrentTile.getWallRecord(lp);
                        var        perceivedWallRecord = PerceivedTile.getWallRecord(lp);

                        if (actualWallRecord.Secret)
                        {
                            wall.Type = perceivedWallRecord.Secret ? WallType.Secret : WallType.Wall;
                        }
                        else
                        {
                            wall.Type = actualWallRecord.Type;
                        }

                        if (actualWallRecord.Secret && !perceivedWallRecord.Secret)
                        {
                            if (GameRules.PerceptionRoll(character, 15 + (Depth * 5)))
                            {
                                CoM.PostMessage("{0} discovered a secret door.", CoM.Format(character));
                                SoundManager.Play("OLDFX_FOUND");
                                wall.Type        = WallType.Secret;
                                secretDiscovered = true;
                            }
                        }

                        PerceivedTile.setWallRecord(lp, wall);
                    }
                }

                if (PerceivedTile.GroundValue != CurrentTile.GroundValue)
                {
                    // roll to see if we detect the difference or not
                    if (GameRules.PerceptionRoll(character, 10 + (Depth * 2)))
                    {
                        detectSquare(PerceivedTile, CurrentTile, "{0} detected that the party is standing on {1} square.", character);
                    }
                    else
                    {
                        if (GameRules.PerceptionRoll(character, (Depth)))
                        {
                            CoM.PostMessage("{0} detects something strange about this place.", CoM.Format(character));
                        }
                    }
                }
            }

            bool tileChanged = origionalValue != PerceivedTile.Value || secretDiscovered;

            if (CoM.GraphicsLoaded && tileChanged)
            {
                CoM.Instance.RefreshMapTile(LocationX, LocationY);
            }
        }
示例#8
0
        /**
         * Attempts to use or equip the item stored in this container.
         * Equipable items will be equiped.  Usable items will be used
         */
        protected void UseOrEquipItem()
        {
            if (DataLink.IsEmpty)
            {
                return;
            }

            MDRItemInstance itemInstance = DataLink.ItemInstance;

            //stub: slots should know the character they're associated with */
            MDRCharacter character = CoM.Party.Selected;

            if (!itemInstance.IDLevel.CanUse)
            {
                CoM.PostMessage("{0} must be more identified before it can be used.", CoM.Format(itemInstance));
                return;
            }

            if (itemInstance.Item.Usable)
            {
                // first can this item be activated?
                string reason = itemInstance.GetCanNotUseReason(character);
                if (reason == "")
                {
                    if (itemInstance.RemainingCharges <= 0)
                    {
                        CoM.PostMessage("Item is out of charges.");
                    }
                    else
                    {
                        itemInstance.Use(character);
                    }
                }
                else
                {
                    CoM.PostMessage(reason);
                }
            }
            else
            {
                // otherwise try equiping it
                string reason = itemInstance.GetCanNotEquipReason(character);
                if (reason == "")
                {
                    character.EquipItem(DataLink);
                }
                else
                {
                    CoM.PostMessage(reason);
                }
            }
        }