예제 #1
0
        public static short _currMaxLv = GameConfigSet.CurrMaxLv.ToShort(); //玩家最大等级

        #endregion Fields

        #region Methods

        /// <summary>
        /// 创建佣兵或佣兵灵魂
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="general"></param>
        /// <param name="type"></param>
        /// <param name="num"></param>
        public static void CreateUserGeneral(string userID, GeneralInfo general, GeneralType type, int num)
        {
            var cacheSet = new GameDataCacheSet<UserGeneral>();
            int generalID = 0;
            CareerInfo careerInfo = null;
            if (type == GeneralType.YongBing)
            {
                generalID = general.GeneralID;
                careerInfo = new ConfigCacheSet<CareerInfo>().FindKey(general.CareerID);
            }
            else if (type == GeneralType.Soul)
            {
                generalID = general.SoulID;
            }
            if (generalID > 0)
            {
                UserGeneral userGeneral = new UserGeneral();
                userGeneral.UserID = userID;
                userGeneral.GeneralID = generalID;
                userGeneral.GeneralName = general.GeneralName;
                userGeneral.HeadID = general.HeadID;
                userGeneral.PicturesID = general.PicturesID;
                userGeneral.GeneralLv = 1;
                userGeneral.GeneralType = type;
                userGeneral.CareerID = general.CareerID;
                userGeneral.PowerNum = general.PowerNum;
                userGeneral.SoulNum = general.SoulNum;
                userGeneral.IntellectNum = general.IntellectNum;
                userGeneral.TrainingPower = 0;
                userGeneral.TrainingSoul = 0;
                userGeneral.TrainingIntellect = 0;
                userGeneral.AbilityID = general.AbilityID;
                userGeneral.Momentum = 0;
                userGeneral.Description = string.Empty;
                userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum");
                userGeneral.GeneralStatus = GeneralStatus.DuiWuZhong;
                userGeneral.CurrExperience = 0;
                userGeneral.Experience1 = 0;
                userGeneral.Experience2 = 0;
                if (careerInfo != null)
                {
                    userGeneral.LifeNum = MathUtils.Addition(general.LifeNum, careerInfo.LifeIncreaseNum * (MathUtils.Subtraction(careerInfo.Lv, (short)1, (short)0)), int.MaxValue);
                }
                if (type == GeneralType.Soul)
                {
                    userGeneral.AtmanNum = num;
                }
                userGeneral.HeritageType = HeritageType.Normal;
                userGeneral.AbilityNum = 3;
                cacheSet.Add(userGeneral, GameEnvironment.CacheUserPeriod);
            }
        }
예제 #2
0
파일: Action1404.cs 프로젝트: 0jpq0/Scut
        public override bool TakeAction()
        {
            var cacheSet = new GameDataCacheSet<UserGeneral>();
            if (recruitType == RecruitType.SoulRecruit)
            {
                general = new ConfigCacheSet<GeneralInfo>().FindKey(soulID);
                if (general == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return false;
                }
                UserGeneral userGeneral = cacheSet.FindKey(ContextUser.UserID, soulID);
                if (soulID == 0 || userGeneral != null)
                {
                    UserItemHelper.AddUserItem(ContextUser.UserID, general.ItemID, 1);
                }
                else
                {
                    userGeneral = new UserGeneral();
                    userGeneral.UserID = ContextUser.UserID;
                    cacheSet.Add(userGeneral, GameEnvironment.CacheUserPeriod);
                    userGeneral.GeneralID = general.GeneralID;
                    userGeneral.GeneralName = general.GeneralName;
                    userGeneral.HeadID = general.HeadID;
                    userGeneral.PicturesID = general.PicturesID;
                    userGeneral.GeneralLv = (short)general.GeneralLv;
                    userGeneral.LifeNum = general.LifeNum;
                    userGeneral.GeneralType = GeneralType.YongBing;
                    userGeneral.CareerID = general.CareerID;
                    userGeneral.PowerNum = general.PowerNum;
                    userGeneral.SoulNum = general.SoulNum;
                    userGeneral.IntellectNum = general.IntellectNum;
                    userGeneral.TrainingPower = 0;
                    userGeneral.TrainingSoul = 0;
                    userGeneral.TrainingIntellect = 0;
                    userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum");
                    userGeneral.AbilityID = general.AbilityID;
                    userGeneral.Momentum = 0;
                    userGeneral.Description = general.Description;
                    userGeneral.GeneralStatus = GeneralStatus.DuiWuZhong;
                    userGeneral.CurrExperience = 0;
                    userGeneral.Experience1 = 0;
                    userGeneral.Experience2 = 0;
                }
            }
            else
            {
                RecruitRule recruitRule = new ConfigCacheSet<RecruitRule>().FindKey(recruitType);
                if (recruitRule == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return false;
                }
                int surplusNum = GeneralHelper.SurplusNum(ContextUser.UserID, recruitRule.FreeNum,
                                                          recruitRule.RecruitType.ToEnum<RecruitType>());
                if (surplusNum > 0 && !GeneralHelper.GeneralRecruitColdTime(ContextUser.UserID, recruitType))
                {
                    GeneralHelper.UpdateDailyRecruitNum(ContextUser.UserID, recruitType);
                    GeneralHelper.UpdateRecruitColdTime(ContextUser.UserID, recruitRule);
                }
                else
                {
                    if (ContextUser.GoldNum < recruitRule.GoldNum)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return false;
                    }
                    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, recruitRule.GoldNum);
                }

                CacheList<RecruitInfo> recruitInfos = recruitRule.GeneralQuality;
                double[] probability = new double[recruitInfos.Count];
                for (int i = 0; i < recruitInfos.Count; i++)
                {
                    probability[i] = (double)recruitInfos[i].Probability;
                }
                int index2 = RandomUtils.GetHitIndex(probability);
                GeneralQuality quality = recruitInfos[index2].Quality;
                var generalList = new ConfigCacheSet<GeneralInfo>().FindAll(s => s.GeneralQuality == quality);
                if (generalList.Count > 0)
                {
                    int indexradom = RandomUtils.GetRandom(0, generalList.Count);
                    if (indexradom < 0 || indexradom >= generalList.Count)
                    {
                        return false;
                    }
                    general = generalList[indexradom];

                    UserGeneral userGeneral = cacheSet.FindKey(ContextUser.UserID, general.GeneralID);

                    if (userGeneral != null && userGeneral.GeneralStatus != GeneralStatus.YinCang)
                    {
                        currSoulID = general.SoulID;
                        gainNum = general.DemandNum;
                        userGeneral = cacheSet.FindKey(ContextUser.UserID, currSoulID);
                        if (userGeneral != null)
                        {
                            userGeneral.AtmanNum = MathUtils.Addition(userGeneral.AtmanNum, gainNum);
                            generalType = GeneralType.Soul;
                        }
                        else
                        {
                            userGeneral = new UserGeneral();
                            userGeneral.UserID = ContextUser.UserID;
                            userGeneral.GeneralID = currSoulID;
                            generalType = GeneralType.Soul;
                            cacheSet.Add(userGeneral, GameEnvironment.CacheUserPeriod);
                            UserAbilityHelper.AddUserAbility(general.AbilityID, ContextUser.UserID.ToInt(), general.GeneralID,1);
                        }
                    }
                    else if (userGeneral == null)
                    {
                        userGeneral = new UserGeneral();
                        userGeneral.UserID = ContextUser.UserID;
                        userGeneral.GeneralID = general.GeneralID;
                        generalType = GeneralType.YongBing;
                        cacheSet.Add(userGeneral, GameEnvironment.CacheUserPeriod);
                        UserAbilityHelper.AddUserAbility(general.AbilityID, ContextUser.UserID.ToInt(), general.GeneralID,1);
                    }
                    userGeneral.GeneralName = general.GeneralName;
                    userGeneral.HeadID = general.HeadID;
                    userGeneral.PicturesID = general.PicturesID;
                    userGeneral.GeneralLv = (short)general.GeneralLv;
                    userGeneral.LifeNum = general.LifeNum;
                    userGeneral.GeneralType = generalType;
                    userGeneral.CareerID = general.CareerID;
                    userGeneral.PowerNum = general.PowerNum;
                    userGeneral.SoulNum = general.SoulNum;
                    userGeneral.IntellectNum = general.IntellectNum;
                    userGeneral.TrainingPower = 0;
                    userGeneral.TrainingSoul = 0;
                    userGeneral.TrainingIntellect = 0;
                    userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum");
                    userGeneral.AbilityID = general.AbilityID;
                    userGeneral.Momentum = 0;
                    userGeneral.Description = general.Description;
                    userGeneral.GeneralStatus = GeneralStatus.DuiWuZhong;
                    userGeneral.CurrExperience = 0;
                    userGeneral.Experience1 = 0;
                    userGeneral.Experience2 = 0;

                    //玩家抽取到蓝色和紫色佣兵时,给予系统频道提示
                    //if (recruitType != RecruitType.SoulRecruit)
                    //{
                    //    if (general.GeneralQuality.ToEnum<GeneralQuality>() == GeneralQuality.Blue || general.GeneralQuality.ToEnum<GeneralQuality>() == GeneralQuality.Purple)
                    //    {
                    //        string content = string.Empty;
                    //        content = string.Format(LanguageManager.GetLang().St_UserGetGeneralQuality, ContextUser.NickName,recruitType,
                    //                            general.GeneralQuality.ToEnum<GeneralQuality>(), general.GeneralName);
                    //        new TjxChatService().SystemSend(ChatType.System, content);
                    //    }
                    //}
                }
            }
            return true;
        }
예제 #3
0
 /// <summary>
 /// 招募佣兵或招募灵魂
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="generalInfo"></param>
 /// <param name="type"></param>
 public static void UpdateUserGeneral(string userID, GeneralInfo generalInfo, GeneralType type, int num)
 {
     var cacheSet = new PersonalCacheStruct<UserGeneral>();
     UserGeneral userGeneral = null;
     if (type == GeneralType.YongBing)
     {
         userGeneral = cacheSet.FindKey(userID, generalInfo.GeneralID);
         if (userGeneral == null)
         {
             CreateUserGeneral(userID, generalInfo, type, num);
         }
         else
         {
             UpdateUserGeneral(userID, generalInfo, GeneralType.Soul, num);
         }
     }
     else if (type == GeneralType.Soul)
     {
         userGeneral = cacheSet.FindKey(userID, generalInfo.SoulID);
         if (userGeneral == null)
         {
             CreateUserGeneral(userID, generalInfo, type, num);
         }
         else
         {
             userGeneral.AtmanNum = MathUtils.Addition(userGeneral.AtmanNum, num);
         }
     }
 }
예제 #4
0
        public override bool TakeAction()
        {
            UserHelper.GetFeelHunger(ContextUser.UserID, generalID);
            UserHelper.ChechDailyRestrain(ContextUser.UserID);
            generalInfo = new ConfigCacheSet<GeneralInfo>().FindKey(generalID);
            if (generalInfo != null)
            {
                giftName = GiftHelper.GetGiftTypeName(generalInfo.GiftType);
                if (generalInfo.ReplaceSkills != null)
                {
                    demandLv = generalInfo.ReplaceSkills.FeelLv;
                    AbilityInfo abilityInfo =
                        new ConfigCacheSet<AbilityInfo>().FindKey(generalInfo.ReplaceSkills.AbilityID);
                    if (abilityInfo != null)
                    {
                        skillName = abilityInfo.AbilityName;
                        skillDesc = abilityInfo.AbilityDesc;
                    }
                }
            }
            userGeneral = new GameDataCacheSet<UserGeneral>().FindKey(ContextUser.UserID, generalID);
            if (userGeneral != null)
            {
                FeelLvInfo feelLvInfo = new ConfigCacheSet<FeelLvInfo>().FindKey(userGeneral.FeelLv);
                if (feelLvInfo != null)
                {
                    propertyList = feelLvInfo.Property.ToList();
                }
                short feelLv = MathUtils.Addition(userGeneral.FeelLv, (short)1, GiftHelper.maxFeelLv);
                FeelLvInfo upfeelLvInfo = new ConfigCacheSet<FeelLvInfo>().FindKey(feelLv);
                if (upfeelLvInfo != null)
                {
                    upExperience = upfeelLvInfo.Experience;
                }
                if (demandLv > 0 && userGeneral.FeelLv >= demandLv)
                {
                    isLearn = 1;
                }
                else
                {
                    isLearn = 0;
                }
            }

            goldNum = GiftHelper.SurplusGoldNum(ContextUser.UserID);
            int _itemid = 5050; //消除饱食度物品ID
            var package = UserItemPackage.Get(ContextUser.UserID);
            var itemArray =
                package.ItemPackage.FindAll(
                    m => m.ItemStatus.Equals(ItemStatus.BeiBao) && m.ItemID.Equals(_itemid));
            if (itemArray.Count > 0)
            {
                isSaturation = 1;
            }
            else
            {
                isSaturation = 0;
            }

            return true;
        }