コード例 #1
0
ファイル: Action6102.cs プロジェクト: dongliang/Scut
        public override bool TakeAction()
        {
            if (!string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                if (CombatHelper.GuildBossKill(ContextUser.MercenariesID))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St5405_BossKilled;
                    return(false);
                }
                GuildBossCombat bossCombat = new GuildBossCombat(ContextUser.MercenariesID);
                UserGuild       guild      = bossCombat.UserGuild;
                if (guild != null)
                {
                    CombatStatus combatStatus = guild.CombatStatus;
                    if (combatStatus != CombatStatus.Wait && combatStatus != CombatStatus.Combat)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St5402_CombatNoStart;
                        return(false);
                    }
                    ErrorCode = ops;
                    if (ops == 1)
                    {
                        ErrorInfo = string.Format(LanguageManager.GetLang().St5202_InspireTip, ExpNum);
                    }
                    else if (ops == 2)
                    {
                        if (ContextUser.ExpNum < ExpNum)
                        {
                            ErrorCode = LanguageManager.GetLang().ErrorCode;
                            ErrorInfo = LanguageManager.GetLang().St_ExpNumNotEnough;
                            return(false);
                        }
                        if (!bossCombat.Inspire(Uid, false, out inspirePercent))
                        {
                            ErrorCode = LanguageManager.GetLang().ErrorCode;
                            ErrorInfo = LanguageManager.GetLang().St_InspireFailed;
                        }

                        if (ContextUser.ExpNum >= ExpNum)
                        {
                            ContextUser.ExpNum = MathUtils.Subtraction(ContextUser.ExpNum, ExpNum, 0);
                            //ContextUser.Update();
                        }
                    }
                    else if (ops == 3)
                    {
                        ErrorInfo = string.Format(LanguageManager.GetLang().St5202_InspireGoldTip, GlodNum);
                    }
                    else if (ops == 4)
                    {
                        if (ContextUser.GoldNum < GlodNum)
                        {
                            ErrorCode = LanguageManager.GetLang().ErrorCode;
                            ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                            return(false);
                        }
                        if (!bossCombat.Inspire(Uid, true, out inspirePercent))
                        {
                            ErrorCode = LanguageManager.GetLang().ErrorCode;
                            ErrorInfo = LanguageManager.GetLang().St_InspireFailed;
                        }

                        if (ContextUser.GoldNum >= GlodNum)
                        {
                            ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, GlodNum, int.MaxValue);
                            //ContextUser.Update();
                        }
                    }
                }
            }
            return(true);
        }