Esempio n. 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);
            }
        }
        public void SetTypeValue(Object sender, Object rowObject, Object newValue)
        {
            if (sender is OLVColumn)
            {
                int rowIndex = (int)rowObject;

                string columnName = ((OLVColumn)sender).Name;

                CategorySub sub = this.category.SubCategories[columnName];
                if (sub != null)
                {
                    if (sub.Types.Count > rowIndex)
                    {
                        string name = (string)newValue;
                        if (DomainModel.Types.Update(sub, sub.Types[rowIndex], name))
                        {
                            sub.Types[rowIndex].Name = name;
                        }
                        else
                        {
                            // Do nothing
                        }
                    }
                    else
                    {
                        int         typeId    = -1;
                        CategorySub neighbour = this.category.GetSubByTypesCount(rowIndex);
                        if (neighbour != null)
                        {
                            typeId = neighbour.Types[rowIndex].Id;
                        }

                        GeneralType type = new GeneralType();
                        type.Name = (string)newValue;
                        type.Id   = typeId;

                        if (DomainModel.Types.Insert(this.category, sub, type))
                        {
                            sub.Types.Add(type);
                        }
                    }
                }
            }
            else
            {
            }
        }
Esempio n. 3
0
        public static void Update(GeneralType general)
        {
            var document = XDocument.Load(Path);
            var element  = document.GetXElements("Generals", "rec").First(el => el.GetXElementValue("Id").ToGuid() == general.Id);

            GeneralType.SetXmlValues(element, general);
            File.WriteAllText(Path, document.ToString());

            if (SyncData.IsConnect)
            {
                using (var connection = ConnectionFactory.CreateConnection())
                    connection.Execute(UpdateQuery, general);
            }

            var idx = Generals.FindIndex(g => g.Id == general.Id);

            Generals[idx] = general;
        }
Esempio n. 4
0
        public static void Add(GeneralType general)
        {
            Generals.Add(general);

            if (!File.Exists(Path))
            {
                SaveFile();
            }

            var document = XDocument.Load(Path);

            document.GetXElement("Generals").Add(GeneralType.ToXElement(general));
            File.WriteAllText(Path, document.ToString());

            if (SyncData.IsConnect)
            {
                using (var connection = ConnectionFactory.CreateConnection())
                    connection.Execute(InsertQuery, general);
            }
        }
Esempio n. 5
0
        /// <summary>Sets values common to both media and written resources</summary>
        /// <param name="resource"></param>
        /// <param name="sessionDirectoryName"></param>
        private void SetResourceProperties(IIMDISessionFile resource, string sessionDirectoryName)
        {
            resource.ResourceLink = new ResourceLinkType {
                Value = ResourceLink(sessionDirectoryName, NormalizedName)
            };
            resource.OutputDirectory = sessionDirectoryName;

            if (IsMediaFile)
            {
                resource.Format = MimeType.ToVocabularyType(false, ListType.Link(ListType.MediaFileFormat));
                resource.Type   = GeneralType.ToVocabularyType(false, ListType.Link(ListType.MediaFileType));
            }
            else
            {
                resource.Format = MimeType.ToVocabularyType(false, ListType.Link(ListType.WrittenResourceFormat));
                resource.Type   = GeneralType.ToVocabularyType(false, ListType.Link(ListType.WrittenResourceType));
            }
            resource.Size = FileSize;

            foreach (var description in Descriptions)
            {
                resource.Description.Add(description.ToIMDIDescriptionType());
            }

            resource.FullPathAndFileName = FullName;

            // Description is required
            if (resource.Description.Count == 0)
            {
                resource.Description.Add(new LanguageString());
            }

            if (AccessCode != null)
            {
                resource.Access = new AccessType {
                    Availability = AccessCode
                }
            }
            ;
        }
    }
Esempio n. 6
0
        public static void Set()
        {
            Sync();

            var currentGeneral = Generals.FirstOrDefault(g => g.EstablishmentCustomerId == Config.IdEstablishment);

            if (currentGeneral == null)
            {
                IsOpen = false;
                var newGeneral = new GeneralType(Guid.NewGuid(), Guid.Empty, false, Config.NameTicket, Config.User, DateTime.Now, Config.IdEstablishment);

                GlobalVar.TicketWindowG = newGeneral.TicketWindowGeneral;

                Add(newGeneral);
            }
            else
            {
                IsOpen = currentGeneral.IsOpen ?? false;
                GlobalVar.TicketWindowG = currentGeneral.TicketWindowGeneral;
            }
        }
Esempio n. 7
0
        public static bool Open()
        {
            RepositoryGeneral.Set();

            if (!RepositoryGeneral.IsOpen)
            {
                var ticketWindowGeneral = RepositoryCloseTicketG.Create();

                var general = RepositoryGeneral.Generals.FirstOrDefault(g => g.EstablishmentCustomerId == Config.IdEstablishment);

                if (general != null)
                {
                    general.Name   = Config.NameTicket;
                    general.IsOpen = true;
                    general.TicketWindowGeneral = ticketWindowGeneral;
                    general.User = Config.User;
                    general.Date = DateTime.Now;
                    general.EstablishmentCustomerId = Config.IdEstablishment;
                    RepositoryGeneral.Update(general);
                }
                else
                {
                    general = new GeneralType(Guid.NewGuid(), ticketWindowGeneral, true, Config.NameTicket, Config.User, DateTime.Now, Config.IdEstablishment);
                    RepositoryGeneral.Add(general);
                }

                GlobalVar.TicketWindowG = ticketWindowGeneral;

                foreach (var rec in RepositoryOpenTicketWindow.OpenTicketWindows.FindAll(l => l.EstablishmentCustomerId == Config.IdEstablishment))
                {
                    rec.IdTicketWindowG = GlobalVar.TicketWindowG;
                    RepositoryOpenTicketWindow.Update(rec);
                }
                return(true);
            }
            FunctionsService.ShowMessageTime("Уже открыта просто продолжите работать");
            return(false);
        }
Esempio n. 8
0
        public static GeneralType GetNextState(GeneralType currentState)
        {
            if (currentState == null)
            {
                return(GetByIndex(0));
            }

            bool found = false;

            foreach (GeneralType type in cache)
            {
                if (found)
                {
                    return(type);
                }
                else if (type.Id == currentState.Id)
                {
                    found = true;
                }
            }

            return(currentState);
        }
Esempio n. 9
0
 protected override object this[string index]
 {
     get
     {
         #region
         switch (index)
         {
             case "GeneralID": return GeneralID;
             case "HeadID": return HeadID;
             case "PicturesID": return PicturesID;
             case "GeneralName": return GeneralName;
             case "GeneralLv": return GeneralLv;
             case "LifeNum": return LifeNum;
             case "CareerID": return CareerID;
             case "PowerNum": return PowerNum;
             case "SoulNum": return SoulNum;
             case "IntellectNum": return IntellectNum;
             case "HitProbability": return HitProbability;
             case "AbilityID": return AbilityID;
             case "IsRecruit": return IsRecruit;
             case "ShowFilter": return ShowFilter;
             case "RecruitFilter": return RecruitFilter;
             case "GiftType": return GiftType;
             case "Description": return Description;
             case "ReplaceSkills": return ReplaceSkills;
             case "GeneralType": return GeneralType;
             case "SoulID": return SoulID;
             case "DemandNum": return DemandNum;
             case "Mature": return Mature;
             case "GeneralQuality": return GeneralQuality;
             case "ItemID": return ItemID;
             case "BattleHeadID": return BattleHeadID;
             case "IsConscribe": return IsConscribe;
             default: throw new ArgumentException(string.Format("GeneralInfo index[{0}] isn't exist.", index));
         }
         #endregion
     }
     set
     {
         #region
         switch (index)
         {
             case "GeneralID":
                 _GeneralID = value.ToInt();
                 break;
             case "HeadID":
                 _HeadID = value.ToNotNullString();
                 break;
             case "PicturesID":
                 _PicturesID = value.ToNotNullString();
                 break;
             case "GeneralName":
                 _GeneralName = value.ToNotNullString();
                 break;
             case "GeneralLv":
                 _GeneralLv = value.ToShort();
                 break;
             case "LifeNum":
                 _LifeNum = value.ToInt();
                 break;
             case "CareerID":
                 _CareerID = value.ToShort();
                 break;
             case "PowerNum":
                 _PowerNum = value.ToShort();
                 break;
             case "SoulNum":
                 _SoulNum = value.ToShort();
                 break;
             case "IntellectNum":
                 _IntellectNum = value.ToShort();
                 break;
             case "HitProbability":
                 _HitProbability = value.ToDecimal();
                 break;
             case "AbilityID":
                 _AbilityID = value.ToInt();
                 break;
             case "IsRecruit":
                 _IsRecruit = value.ToBool();
                 break;
             case "ShowFilter":
                 _ShowFilter = ConvertCustomField<CacheList<ShowFilterInfo>>(value, index);
                 break;
             case "RecruitFilter":
                 _RecruitFilter = ConvertCustomField<CacheList<RecruitFilter>>(value, index);
                 break;
             case "Description":
                 _Description = value.ToNotNullString();
                 break;
             case "GiftType":
                 _GiftType = value.ToEnum<GiftType>();
                 break;
             case "ReplaceSkills":
                 _ReplaceSkills = ConvertCustomField<SkillInfo>(value, index);
                 break;
             case "GeneralType":
                 _GeneralType = value.ToEnum<GeneralType>();
                 break;
             case "SoulID":
                 _SoulID = value.ToInt();
                 break;
             case "DemandNum":
                 _DemandNum = value.ToInt();
                 break;
             case "Mature":
                 _Mature = ConvertCustomField<CacheList<GeneralProperty>>(value, index);
                 break;
             case "GeneralQuality":
                 _GeneralQuality = value.ToEnum<GeneralQuality>();
                 break;
             case "ItemID":
                 _ItemID = value.ToInt();
                 break;
             case "BattleHeadID":
                 _BattleHeadID = value.ToNotNullString();
                 break;
             case "IsConscribe":
                 _IsConscribe = value.ToBool();
                 break;
             default: throw new ArgumentException(string.Format("GeneralInfo index[{0}] isn't exist.", index));
         }
         #endregion
     }
 }
Esempio n. 10
0
 protected override object this[string index]
 {
     get
     {
         #region
         switch (index)
         {
             case "GeneralLv": return GeneralLv;
             case "UpExperience": return UpExperience;
             case "GeneralType": return GeneralType;
             case "FunctionEnum": return FunctionEnum;
             case "Leadership": return Leadership;
             case "Award": return Award;
             default: throw new ArgumentException(string.Format("GeneralEscalateInfo index[{0}] isn't exist.", index));
         }
         #endregion
     }
     set
     {
         #region
         switch (index)
         {
             case "GeneralLv":
                 _GeneralLv = value.ToShort();
                 break;
             case "UpExperience":
                 _UpExperience = value.ToInt();
                 break;
             case "GeneralType":
                 _GeneralType = value.ToEnum<GeneralType>();
                 break;
             case "FunctionEnum":
                 _FunctionEnum = value.ToNotNullString();
                 break;
             case "Leadership":
                 _Leadership = value.ToInt();
                 break;
             case "Award":
                 _Award = ConvertCustomField<CacheList<PrizeInfo>>(value, index); 
                 break;
             default: throw new ArgumentException(string.Format("GeneralEscalateInfo index[{0}] isn't exist.", index));
         }
         #endregion
     }
 }
Esempio n. 11
0
 public static bool Update(CategorySub sub, GeneralType type, string name)
 {
     return(repo.Update(sub.Language.Id, type.Id, name));
 }
Esempio n. 12
0
        public override bool TakeAction()
        {
            var cacheSet = new PersonalCacheStruct <UserGeneral>();

            if (recruitType == RecruitType.SoulRecruit)
            {
                general = new ShareCacheStruct <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);
                    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 ShareCacheStruct <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 ShareCacheStruct <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);
                            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);
                        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);
        }
Esempio n. 13
0
        protected override object this[string index]
        {
            get
            {
                #region
                switch (index)
                {
                case "UserID": return(UserID);

                case "GeneralID": return(GeneralID);

                case "GeneralName": return(GeneralName);

                case "HeadID": return(HeadID);

                case "PicturesID": return(PicturesID);

                case "GeneralLv": return(GeneralLv);

                case "LifeNum": return(LifeNum);

                case "GeneralType": return(GeneralType);

                case "CareerID": return(CareerID);

                case "PowerNum": return(PowerNum);

                case "SoulNum": return(SoulNum);

                case "IntellectNum": return(IntellectNum);

                case "TrainingPower": return(TrainingPower);

                case "TrainingSoul": return(TrainingSoul);

                case "TrainingIntellect": return(TrainingIntellect);

                case "HitProbability": return(HitProbability);

                case "AbilityID": return(AbilityID);

                case "Momentum": return(Momentum);

                case "Description": return(Description);

                case "GeneralStatus": return(GeneralStatus);

                case "CurrExperience": return(CurrExperience);

                case "Experience1": return(Experience1);

                case "Experience2": return(Experience2);

                case "HeritageType": return(HeritageType);

                case "FeelLv": return(FeelLv);

                case "FeelExperience": return(FeelExperience);

                case "SaturationNum": return(SaturationNum);

                case "HungerDate": return(HungerDate);

                case "AtmanNum": return(AtmanNum);

                case "Potential": return(Potential);

                case "Attribute": return(Attribute);

                case "AbilityNum": return(AbilityNum);

                default: throw new ArgumentException(string.Format("UserGeneral index[{0}] isn't exist.", index));
                }
                #endregion
            }
            set
            {
                #region
                switch (index)
                {
                case "UserID":
                    _UserID = value.ToNotNullString();
                    break;

                case "GeneralID":
                    _GeneralID = value.ToInt();
                    break;

                case "GeneralName":
                    _GeneralName = value.ToNotNullString();
                    break;

                case "HeadID":
                    _HeadID = value.ToNotNullString();
                    break;

                case "PicturesID":
                    _PicturesID = value.ToNotNullString();
                    break;

                case "GeneralLv":
                    _GeneralLv = value.ToShort();
                    break;

                case "LifeNum":
                    _LifeNum = value.ToInt();
                    break;

                case "GeneralType":
                    _GeneralType = value.ToEnum <GeneralType>();
                    break;

                case "CareerID":
                    _CareerID = value.ToShort();
                    break;

                case "PowerNum":
                    _PowerNum = value.ToShort();
                    break;

                case "SoulNum":
                    _SoulNum = value.ToShort();
                    break;

                case "IntellectNum":
                    _IntellectNum = value.ToShort();
                    break;

                case "TrainingPower":
                    _TrainingPower = value.ToShort();
                    break;

                case "TrainingSoul":
                    _TrainingSoul = value.ToShort();
                    break;

                case "TrainingIntellect":
                    _TrainingIntellect = value.ToShort();
                    break;

                case "HitProbability":
                    _HitProbability = value.ToDecimal();
                    break;

                case "AbilityID":
                    _AbilityID = value.ToInt();
                    break;

                case "Momentum":
                    _Momentum = value.ToShort();
                    break;

                case "Description":
                    _Description = value.ToNotNullString();
                    break;

                case "GeneralStatus":
                    _GeneralStatus = value.ToEnum <GeneralStatus>();
                    break;

                case "CurrExperience":
                    _CurrExperience = value.ToInt();
                    break;

                case "Experience1":
                    _Experience1 = value.ToInt();
                    break;

                case "Experience2":
                    _Experience2 = value.ToInt();
                    break;

                case "HeritageType":
                    _HeritageType = value.ToEnum <HeritageType>();
                    break;

                case "FeelLv":
                    _FeelLv = value.ToShort();
                    break;

                case "FeelExperience":
                    _FeelExperience = value.ToInt();
                    break;

                case "SaturationNum":
                    _SaturationNum = value.ToShort();
                    break;

                case "HungerDate":
                    _HungerDate = value.ToDateTime();
                    break;

                case "AtmanNum":
                    _AtmanNum = value.ToInt();
                    break;

                case "Potential":
                    _Potential = value.ToInt();
                    break;

                case "Attribute":
                    _Attribute = ConvertCustomField <CacheList <GeneralProperty> >(value, index);
                    break;

                case "AbilityNum":
                    _AbilityNum = value.ToInt();
                    break;

                default: throw new ArgumentException(string.Format("UserGeneral index[{0}] isn't exist.", index));
                }
                #endregion
            }
        }
Esempio n. 14
0
        protected override object this[string index]
        {
            get
            {
                #region
                switch (index)
                {
                case "GeneralID": return(GeneralID);

                case "HeadID": return(HeadID);

                case "PicturesID": return(PicturesID);

                case "GeneralName": return(GeneralName);

                case "GeneralLv": return(GeneralLv);

                case "LifeNum": return(LifeNum);

                case "CareerID": return(CareerID);

                case "PowerNum": return(PowerNum);

                case "SoulNum": return(SoulNum);

                case "IntellectNum": return(IntellectNum);

                case "HitProbability": return(HitProbability);

                case "AbilityID": return(AbilityID);

                case "IsRecruit": return(IsRecruit);

                case "ShowFilter": return(ShowFilter);

                case "RecruitFilter": return(RecruitFilter);

                case "GiftType": return(GiftType);

                case "Description": return(Description);

                case "ReplaceSkills": return(ReplaceSkills);

                case "GeneralType": return(GeneralType);

                case "SoulID": return(SoulID);

                case "DemandNum": return(DemandNum);

                case "Mature": return(Mature);

                case "GeneralQuality": return(GeneralQuality);

                case "ItemID": return(ItemID);

                case "BattleHeadID": return(BattleHeadID);

                case "IsConscribe": return(IsConscribe);

                default: throw new ArgumentException(string.Format("GeneralInfo index[{0}] isn't exist.", index));
                }
                #endregion
            }
            set
            {
                #region
                switch (index)
                {
                case "GeneralID":
                    _GeneralID = value.ToInt();
                    break;

                case "HeadID":
                    _HeadID = value.ToNotNullString();
                    break;

                case "PicturesID":
                    _PicturesID = value.ToNotNullString();
                    break;

                case "GeneralName":
                    _GeneralName = value.ToNotNullString();
                    break;

                case "GeneralLv":
                    _GeneralLv = value.ToShort();
                    break;

                case "LifeNum":
                    _LifeNum = value.ToInt();
                    break;

                case "CareerID":
                    _CareerID = value.ToShort();
                    break;

                case "PowerNum":
                    _PowerNum = value.ToShort();
                    break;

                case "SoulNum":
                    _SoulNum = value.ToShort();
                    break;

                case "IntellectNum":
                    _IntellectNum = value.ToShort();
                    break;

                case "HitProbability":
                    _HitProbability = value.ToDecimal();
                    break;

                case "AbilityID":
                    _AbilityID = value.ToInt();
                    break;

                case "IsRecruit":
                    _IsRecruit = value.ToBool();
                    break;

                case "ShowFilter":
                    _ShowFilter = ConvertCustomField <CacheList <ShowFilterInfo> >(value, index);
                    break;

                case "RecruitFilter":
                    _RecruitFilter = ConvertCustomField <CacheList <RecruitFilter> >(value, index);
                    break;

                case "Description":
                    _Description = value.ToNotNullString();
                    break;

                case "GiftType":
                    _GiftType = value.ToEnum <GiftType>();
                    break;

                case "ReplaceSkills":
                    _ReplaceSkills = ConvertCustomField <SkillInfo>(value, index);
                    break;

                case "GeneralType":
                    _GeneralType = value.ToEnum <GeneralType>();
                    break;

                case "SoulID":
                    _SoulID = value.ToInt();
                    break;

                case "DemandNum":
                    _DemandNum = value.ToInt();
                    break;

                case "Mature":
                    _Mature = ConvertCustomField <CacheList <GeneralProperty> >(value, index);
                    break;

                case "GeneralQuality":
                    _GeneralQuality = value.ToEnum <GeneralQuality>();
                    break;

                case "ItemID":
                    _ItemID = value.ToInt();
                    break;

                case "BattleHeadID":
                    _BattleHeadID = value.ToNotNullString();
                    break;

                case "IsConscribe":
                    _IsConscribe = value.ToBool();
                    break;

                default: throw new ArgumentException(string.Format("GeneralInfo index[{0}] isn't exist.", index));
                }
                #endregion
            }
        }
Esempio n. 15
0
 public static bool Insert(CategoryClass category, CategorySub sub, GeneralType type)
 {
     return(repo.Insert(category.Id, sub.Language.Id, type));
 }
Esempio n. 16
0
 protected override object this[string index]
 {
     get
     {
         #region
         switch (index)
         {
             case "UserID": return UserID;
             case "GeneralID": return GeneralID;
             case "GeneralName": return GeneralName;
             case "HeadID": return HeadID;
             case "PicturesID": return PicturesID;
             case "GeneralLv": return GeneralLv;
             case "LifeNum": return LifeNum;
             case "GeneralType": return GeneralType;
             case "CareerID": return CareerID;
             case "PowerNum": return PowerNum;
             case "SoulNum": return SoulNum;
             case "IntellectNum": return IntellectNum;
             case "TrainingPower": return TrainingPower;
             case "TrainingSoul": return TrainingSoul;
             case "TrainingIntellect": return TrainingIntellect;
             case "HitProbability": return HitProbability;
             case "AbilityID": return AbilityID;
             case "Momentum": return Momentum;
             case "Description": return Description;
             case "GeneralStatus": return GeneralStatus;
             case "CurrExperience": return CurrExperience;
             case "Experience1": return Experience1;
             case "Experience2": return Experience2;
             case "HeritageType": return HeritageType;
             case "FeelLv": return FeelLv;
             case "FeelExperience": return FeelExperience;
             case "SaturationNum": return SaturationNum;
             case "HungerDate": return HungerDate;
             case "AtmanNum": return AtmanNum;
             case "Potential": return Potential;
             case "Attribute": return Attribute;
             case "AbilityNum": return AbilityNum;
             default: throw new ArgumentException(string.Format("UserGeneral index[{0}] isn't exist.", index));
         }
         #endregion
     }
     set
     {
         #region
         switch (index)
         {
             case "UserID":
                 _UserID = value.ToNotNullString();
                 break;
             case "GeneralID":
                 _GeneralID = value.ToInt();
                 break;
             case "GeneralName":
                 _GeneralName = value.ToNotNullString();
                 break;
             case "HeadID":
                 _HeadID = value.ToNotNullString();
                 break;
             case "PicturesID":
                 _PicturesID = value.ToNotNullString();
                 break;
             case "GeneralLv":
                 _GeneralLv = value.ToShort();
                 break;
             case "LifeNum":
                 _LifeNum = value.ToInt();
                 break;
             case "GeneralType":
                 _GeneralType = value.ToEnum<GeneralType>();
                 break;
             case "CareerID":
                 _CareerID = value.ToShort();
                 break;
             case "PowerNum":
                 _PowerNum = value.ToShort();
                 break;
             case "SoulNum":
                 _SoulNum = value.ToShort();
                 break;
             case "IntellectNum":
                 _IntellectNum = value.ToShort();
                 break;
             case "TrainingPower":
                 _TrainingPower = value.ToShort();
                 break;
             case "TrainingSoul":
                 _TrainingSoul = value.ToShort();
                 break;
             case "TrainingIntellect":
                 _TrainingIntellect = value.ToShort();
                 break;
             case "HitProbability":
                 _HitProbability = value.ToDecimal();
                 break;
             case "AbilityID":
                 _AbilityID = value.ToInt();
                 break;
             case "Momentum":
                 _Momentum = value.ToShort();
                 break;
             case "Description":
                 _Description = value.ToNotNullString();
                 break;
             case "GeneralStatus":
                 _GeneralStatus = value.ToEnum<GeneralStatus>();
                 break;
             case "CurrExperience":
                 _CurrExperience = value.ToInt();
                 break;
             case "Experience1":
                 _Experience1 = value.ToInt();
                 break;
             case "Experience2":
                 _Experience2 = value.ToInt();
                 break;
             case "HeritageType":
                 _HeritageType = value.ToEnum<HeritageType>();
                 break;
             case "FeelLv":
                 _FeelLv = value.ToShort();
                 break;
             case "FeelExperience":
                 _FeelExperience = value.ToInt();
                 break;
             case "SaturationNum":
                 _SaturationNum = value.ToShort();
                 break;
             case "HungerDate":
                 _HungerDate = value.ToDateTime();
                 break;
             case "AtmanNum":
                 _AtmanNum = value.ToInt();
                 break;
             case "Potential":
                 _Potential = value.ToInt();
                 break;
             case "Attribute":
                 _Attribute = ConvertCustomField<CacheList<GeneralProperty>>(value, index);
                 break;
             case "AbilityNum":
                 _AbilityNum = value.ToInt();
                 break;
             default: throw new ArgumentException(string.Format("UserGeneral index[{0}] isn't exist.", index));
         }
         #endregion
     }
 }
Esempio n. 17
0
        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;
        }
Esempio n. 18
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);
         }
     }
 }