Exemplo n.º 1
0
 /**
  * Creates a new guild membership record.
  * @param guild The guild to record membership information for
  */
 public MDRGuildMembership(MDRGuild guild)
 {
     this.Guild   = guild;
     XP           = 0;
     CurrentLevel = 0;
     HasQuest     = false;
 }
Exemplo n.º 2
0
        public override void ReadNode(XElement node)
        {
            foreach (MDRGuild guild in CoM.Guilds)
            {
                Membership[guild].Reset();
            }

            string guildName = ReadValue(node, "CurrentGuild");

            CurrentGuild = CoM.Guilds.ByName(guildName);
            if (CurrentGuild == null)
            {
                Trace.LogWarning("Could not find guild with name '" + guildName + "' for current guild membership.");
            }

            foreach (XElement subNode in node.Elements("Guild"))
            {
                guildName = subNode.Attribute("GuildName").Value;
                MDRGuild guild = CoM.Guilds.ByName(guildName);
                if (guild != null)
                {
                    Membership[guild].ReadNode(subNode);
                }
                else
                {
                    Trace.LogWarning("Could not find guild with name '" + guildName + "' for membership.");
                }
            }
        }
Exemplo n.º 3
0
 public override void ReadNode(XElement node)
 {
     Guild        = CoM.Guilds[ReadAttribute(node, "GuildName")];
     CurrentLevel = ReadAttributeInt(node, "CurrentLevel");
     XP           = ReadAttributeInt(node, "XP");
     HasQuest     = (ReadAttributeInt(node, "HasQuest") == 1);
 }
Exemplo n.º 4
0
 protected string formatGuild(MDRGuild guild)
 {
     if (guild == null)
     {
         return("");
     }
     return(Util.Colorise("<Size=10>[" + guild.Name + "]</size>", Color.gray));
 }
Exemplo n.º 5
0
        /** Trys to let the current character join the currently selected guild */
        private void JoinGuild()
        {
            MDRGuild guild = SelectedGuild;

            if (guild == null)
            {
                return;
            }
            if (Character == null)
            {
                return;
            }

            if (Character.CurrentGuild == guild)
            {
                Engine.ShowModal("Can not join guild", "This is already your current guild.");
                return;
            }

            if (Character.Membership[guild].IsMember)
            {
                Character.Membership.CurrentGuild = guild;
                RefreshUI();
                Engine.ShowModal("Welcome", "Welcome back to the " + guild.Name + " guild.");
                return;
            }

            if (guild.CanAccept(Character))
            {
                if (Character.Membership.JoinedGuilds >= 2)
                {
                    if (CoM.Party.TotalHP >= SelectedGuild.JoinCost)
                    {
                        CoM.Party.DebitGold(SelectedGuild.JoinCost, Character);
                    }
                    else
                    {
                        Engine.ShowModal("Can not join guild", "Not enough gold.");
                        return;
                    }
                }

                Character.JoinGuild(guild);
                RefreshUI();
                Engine.ShowModal("Guild Joined", "Welcome to the " + guild.Name + " guild!");
            }
            else
            {
                Engine.ShowModal("Can not join guild", "");
            }
        }
Exemplo n.º 6
0
        /**
         * Calculates the cost for given character to cast given spell.
         * Returns 0 if spell can not be cast.
         */
        public int CostFor(MDRCharacter character)
        {
            MDRGuild spellGuild          = null;
            var      characterSpellLevel = GameRules.CharacterGeneralAbility(character, SpellClass.Skill, out spellGuild);

            if (spellGuild == null)
            {
                return(0);
            }

            float factor = Util.Clamp(SpellLevel / characterSpellLevel, 0.1f, 1f);

            return((int)(SpellCost * factor));
        }
Exemplo n.º 7
0
    /** Used for all skills */
    private static float CharacterGeneralAbilityFromGuild(MDRCharacter character, MDRGuild guild, float guildSkillRate, float skillDifficulty)
    {
        if (!character.Membership[guild].IsMember)
        {
            return(0);
        }

        if (guildSkillRate == 0)
        {
            return(0);
        }

        float guildLevel = character.Membership[guild].CurrentLevel;

        return(Mathf.Floor(Mathf.Sqrt((guildLevel - 1) * guildSkillRate) / skillDifficulty * 10f + 10f));
    }
Exemplo n.º 8
0
 /** Indexer to guild membership by guild */
 public MDRGuildMembership this [MDRGuild guild] {
     get { return(Membership[guild]); }
 }
Exemplo n.º 9
0
 /**
  * Returns if a guild is able to use this item or not
  */
 public bool GuildCanUseItem(MDRGuild guild)
 {
     return(guildsMask[guild.ID]);
 }
Exemplo n.º 10
0
    /**
     * Returns the characters highest skill level from any guild.
     * FromGuild will be set to the guild with the highest fighting value.
     */
    public static float CharacterGeneralAbility(MDRCharacter character, MDRSkill skill, out MDRGuild fromGuild)
    {
        fromGuild = null;
        float bestSkill = 0;

        foreach (MDRGuild guild in CoM.Guilds)
        {
            float skillLevel = CharacterGeneralAbilityFromGuild(character, guild, guild.SkillRate[skill.ID], skill.LearningDifficulty);
            if (skillLevel > bestSkill)
            {
                fromGuild = guild;
                bestSkill = skillLevel;
            }
        }
        return(bestSkill);
    }