Beispiel #1
0
 void AttemptSpawn()
 {
     crystalref             = Instantiate(crystal, transform.position, Quaternion.identity).GetComponent <CrystalInfo>();
     crystalref.moduleType  = Moduletype;
     crystalref.moduleIndex = ModuleIndex;
     crystalref.module      = Module;
 }
Beispiel #2
0
        public override bool TakeAction()
        {
            string publicUserID = string.Empty;

            if (string.IsNullOrEmpty(toUserID))
            {
                publicUserID = ContextUser.UserID;
            }
            else
            {
                publicUserID = toUserID;
            }
            short crystalLv = 0;
            var   package   = UserCrystalPackage.Get(publicUserID);

            _userCrystal = package.CrystalPackage.Find(m => m.UserCrystalID.Equals(_userCrystalID));
            //_userCrystal = UserCrystal.FindKey(_userCrystalID);)
            if (_userCrystal != null)
            {
                _crystalInfo = new ShareCacheStruct <CrystalInfo>().FindKey(_userCrystal.CrystalID);
                crystalLv    = _userCrystal.CrystalLv;
            }
            else
            {
                var grayCrystal = ContextUser.GrayCrystalList.Find(m => m.UserCrystalID == _userCrystalID);
                if (grayCrystal != null)
                {
                    _crystalInfo = new ShareCacheStruct <CrystalInfo>().FindKey(grayCrystal.CrystalID);
                }
                else
                {
                    return(false);
                }
            }
            if (_crystalInfo == null)
            {
                return(false);
            }
            CrystalLvInfo currCrystal = new ShareCacheStruct <CrystalLvInfo>().FindKey(_crystalInfo.CrystalID, crystalLv);
            short         upLv        = MathUtils.Addition(crystalLv, (short)1, short.MaxValue);

            if (upLv >= 10)
            {
                upLv = 10;
            }
            _crystalLvInfo = new ShareCacheStruct <CrystalLvInfo>().FindKey(_crystalInfo.CrystalID, upLv);//下级经验
            if (currCrystal != null && currCrystal.AbilityNum > 1)
            {
                _attrNum = currCrystal.AbilityNum.ToString().Replace(".0000", "");
            }
            else if (currCrystal != null)
            {
                _attrNum = Math.Round((currCrystal.AbilityNum * 100), 1, MidpointRounding.AwayFromZero).ToString();
                _attrNum = _attrNum.Replace(".0", "") + "%";
            }

            return(true);
        }
    private void GrabObject()
    {
        objectInHand = collidingObject;

        HourglassControl hourglassRef = objectInHand.GetComponent <HourglassControl>();
        SpellModuleList  scrollRef    = objectInHand.GetComponent <SpellModuleList>();
        CrystalInfo      crystalRef   = objectInHand.GetComponent <CrystalInfo>();


        if (hourglassRef != null)
        {
            if (!hourglassRef.interactable)
            {
                return;
            }
        }

        collidingObject = null;

        var joint = AddFixedJoint();

        joint.connectedBody = objectInHand.GetComponent <Rigidbody>();

        if (objectInHand.GetComponent <VRSlider>() || crystalRef != null || scrollRef != null || hourglassRef != null)
        {
            objectInHand.GetComponent <Rigidbody>().isKinematic = false;
        }

        if (crystalRef != null)
        {
            AudioSource.PlayClipAtPoint(crystalPickup, transform.position, Info.optionsData.sfxLevel);
            foreach (Animator anim in slotAnimators)
            {
                anim.enabled = true;
            }
        }

        if (scrollRef != null)
        {
            AudioSource.PlayClipAtPoint(scrollPickup, transform.position, Info.optionsData.sfxLevel);
            if (scrollRef.transform.parent == null)
            {
                creationArea.isSpellCollected = true;
            }
        }

        for (int i = 0; i < beltObjects.Length; i++) // check all slots to see if any are suitable
        {
            if (objectInHand.transform.parent == beltObjects[i].transform)
            {
                objectInHand.transform.SetParent(null);
                beltSlots[i] = false;
            }
        }
    }
Beispiel #4
0
        /// <summary>
        /// format cryst1 information into PDB format string
        /// </summary>
        /// <param name="crystal1"></param>
        /// <returns></returns>
        private string FormatCrystString(CrystalInfo crystal1)
        {
            string crystString = "CRYST1";

            crystString += FormatDoubleString(crystal1.length_a, 5, 3);
            crystString += FormatDoubleString(crystal1.length_b, 5, 3);
            crystString += FormatDoubleString(crystal1.length_c, 5, 3);
            crystString += FormatDoubleString(crystal1.angle_alpha, 4, 2);
            crystString += FormatDoubleString(crystal1.angle_beta, 4, 2);
            crystString += FormatDoubleString(crystal1.angle_gamma, 4, 2);
            crystString += " ";
            crystString += crystal1.spaceGroup.PadRight(11, ' ');
            crystString += crystal1.zpdb.ToString().PadLeft(4, ' ');
            return(crystString);
        }
Beispiel #5
0
        //public MainWindow m_MainForms { get; set; }

        public void ReadCrystalInfo(string path)
        {
            var crystStream = new System.IO.StreamReader(path);

            CrystalProps = new CrystalInfo();

            while (!crystStream.EndOfStream)
            {
                var lines = crystStream.ReadLine();
                if (!lines.Contains("#") && !lines.Contains("*"))
                {
                    try
                    {
                        var rline = lines.Trim();
                        rline = System.Text.RegularExpressions.Regex.Replace(rline, @"\s+", " ");

                        var sline = rline.Split(" \t".ToArray());
                        var order = uint.Parse(sline[0]);
                        var c2d   = double.Parse(sline[1]);
                        var dpath = sline[2];

                        var info = GetCrystalInfo(dpath);
                        if (info != null)
                        {
                            CrystalProps.Add(order, c2d, dpath, info.Item1, info.Item2, info.Item3);
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Warning(e.Message);
                        continue;
                    }
                }
            }
            crystStream.Close();
            onChange?.Invoke(this, new EventArgs());
        }
Beispiel #6
0
        /// <summary>
        /// Detect all interfaces in a crystal
        /// built from XML coordinates file
        /// </summary>
        /// <param name="xmlFile"></param>
        /// <param name="paramFile"></param>
        public int FindInteractChains(string xmlFile)
        {
            interChainId = 0;
            asymChainTreesHash.Clear();
            interfaceChainsList.Clear();
            pdbId = xmlFile.Substring(xmlFile.LastIndexOf("\\") + 1, 4);
            CrystalBuilder crystalBuilder = new CrystalBuilder(AppSettings.parameters.contactParams.atomType);
            Dictionary <string, AtomInfo[]> unitCellChainsHash = null;

            int[] maxSteps = null;
            // build crystal based on all symmetry operations
            try
            {
                maxSteps = crystalBuilder.BuildCrystal(xmlFile, ref unitCellChainsHash);
                if (unitCellChainsHash == null)
                {
                    throw new Exception("Cannot build unit cell.");
                }
                // if there are too many chains in a unit cell
                // only compute the interfaces between original ASU chains
                // and other chains
                if (unitCellChainsHash.Count > unitCellSize)
                {
                    //	throw new Exception ("Unit cell too large. Skip processing " + pdbId + ".");
                    // if there are too many chains in the unit cell,
                    // only check the interfaces within the unit cell.
                    for (int i = 0; i < maxSteps.Length; i++)
                    {
                        maxSteps[i] = 0;
                    }
                }
                // if there are too many chains, only use chains in the asymmetric unit
                if (unitCellChainsHash.Count >= maxUnitCellSize)
                {
                    Dictionary <string, AtomInfo[]> asuChainHash = GetAsymUnitHash(unitCellChainsHash);
                    unitCellChainsHash = asuChainHash;
                    // if it is still too big due to Non-symmetry operators,
                    // only use chains in the original asu in the PDB file, may not be the real Asu
                    if (asuChainHash.Count >= unitCellSize)
                    {
                        Dictionary <string, AtomInfo[]> origAsuChainHash = GetOrigAsymUnitHash(asuChainHash);
                        unitCellChainsHash = origAsuChainHash;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Building Crystal Errors: " + xmlFile + " " + ex.Message);
            }

            /*
             * build BVTree for original asymmetric chains +
             * their chains after applied symmetry operations
             * without translations
             */
            try
            {
                // for each chain in a cell including original and symmetric chains
                foreach (string chainAndSymOp in unitCellChainsHash.Keys)
                {
                    BVTree chainTree = new BVTree();
                    chainTree.BuildBVTree(unitCellChainsHash[chainAndSymOp], AppSettings.parameters.kDopsParam.bvTreeMethod, true);
                    asymChainTreesHash.Add(chainAndSymOp, chainTree);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Building Bounding Volumn Tree Errors: " + xmlFile + ". " + ex.Message);
            }

            /*
             * the critical step for the computation time
             * check all pairs of chains including translated chains
             * return a list of atompairs if exists
             */
            cryst1            = crystalBuilder.Crystal1;
            fract2CartnMatrix = crystalBuilder.fract2cartnMatrix;

            List <string> chainAndSymOps        = new List <string> (asymChainTreesHash.Keys);
            List <string> orderedChainAndSymOps = SortChainsInUnitCell(chainAndSymOps);

            // check interactions between 2 different chains and their translated chains
            // chainAndSymOps: chainId_symmetry operator_full symmetry operations
            // e.g. A_1_545
            try
            {
                ComputeUniqueInterfacesFromCryst(orderedChainAndSymOps, maxSteps);
            }
            catch (Exception ex)
            {
                /*	ProtCidSettings.progressInfo.progStrQueue.Enqueue
                 *              ("Retrieving unique interfaces of " + pdbId + " errors: " + ex.Message);*/
                throw new Exception("Retrieving unique interfaces of " + pdbId + " errors: " + ex.Message);
            }
            return(unitCellChainsHash.Count);
        }
Beispiel #7
0
        /// <summary>
        /// 玩家获得奖励
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="prizeList"></param>
        /// <returns></returns>
        public static string GetPrizeUserTake(GameUser userInfo, List <PrizeInfo> prizeList)
        {
            string prizeContent = string.Empty;

            foreach (var prize in prizeList)
            {
                switch (prize.Type)
                {
                case RewardType.GameGoin:
                    userInfo.GameCoin = MathUtils.Addition(userInfo.GameCoin, prize.Num);
                    prizeContent     += string.Format(LanguageManager.GetLang().St_GameCoin, prize.Num) + ",";
                    break;

                case RewardType.ExpNum:
                    userInfo.ExpNum = MathUtils.Addition(userInfo.ExpNum, prize.Num);
                    prizeContent   += string.Format(LanguageManager.GetLang().St_ExpNum, prize.Num) + ",";
                    break;

                case RewardType.EnergyNum:
                    userInfo.EnergyNum = MathUtils.Addition(userInfo.EnergyNum, prize.Num.ToShort());
                    prizeContent      += string.Format(LanguageManager.GetLang().St_EnergyNum, prize.Num) + ",";
                    break;

                case RewardType.HonourNum:
                    GeneralEscalateHelper.AddUserLv(userInfo, prize.Num);
                    prizeContent += string.Format(LanguageManager.GetLang().St_HonourNum, prize.Num) + ",";
                    break;

                case RewardType.Experience:
                    UserHelper.UserGeneralExp(userInfo.UserID, prize.Num);
                    prizeContent += string.Format(LanguageManager.GetLang().St_Experience, prize.Num) + ",";
                    break;

                case RewardType.Gold:
                    userInfo.GiftGold = MathUtils.Addition(userInfo.GiftGold, prize.Num);
                    prizeContent     += string.Format(LanguageManager.GetLang().St_GiftGoldNum, prize.Num) + ",";
                    break;

                case RewardType.Item:
                    short        itemLv   = prize.UserLv > 0 ? prize.UserLv : 1.ToShort();
                    int          priNum   = prize.Num > 0 ? prize.Num : 1;
                    ItemBaseInfo itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(prize.ItemID);
                    if (itemInfo != null)
                    {
                        UserItemHelper.AddUserItem(userInfo.UserID, itemInfo.ItemID, priNum, itemLv);
                        prizeContent += string.Format("{0}*{1}", itemInfo.ItemName, priNum) + ",";
                    }
                    break;

                case RewardType.CrystalType:
                    List <CrystalInfo> crystalArray = new ShareCacheStruct <CrystalInfo>().FindAll(s => s.CrystalQuality == prize.CrystalType);
                    if (crystalArray.Count > 0)
                    {
                        int         index1      = RandomUtils.GetRandom(0, crystalArray.Count);
                        CrystalInfo crystalInfo = crystalArray[index1];
                        short       crystalLv   = prize.UserLv > 0 ? prize.UserLv : 1.ToShort();
                        CrystalHelper.AppendCrystal(userInfo.UserID, crystalInfo.CrystalID, crystalLv);
                    }
                    break;

                case RewardType.CrystalId:
                    short       cLv     = prize.UserLv > 0 ? prize.UserLv : 1.ToShort();
                    CrystalInfo crystal = new ShareCacheStruct <CrystalInfo>().FindKey(prize.ItemID);
                    if (crystal != null)
                    {
                        CrystalHelper.AppendCrystal(userInfo.UserID, crystal.CrystalID, cLv);
                        prizeContent += string.Format("{0}*{1}", crystal.CrystalName, prize.Num) + ",";
                    }
                    break;

                case RewardType.Spare:
                    break;

                case RewardType.Enchant:
                    break;

                case RewardType.PayGold:
                    userInfo.PayGold = MathUtils.Addition(userInfo.PayGold, prize.Num);
                    prizeContent    += string.Format(LanguageManager.GetLang().St_PayGoldNum, prize.Num) + ",";
                    break;

                default:
                    break;
                }
            }
            return(prizeContent);
        }
Beispiel #8
0
        /// <summary>
        /// 获得物品
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="prize"></param>
        /// <returns></returns>
        public bool DoPrize(GameUser userInfo, List <PrizeInfo> prizeList)
        {
            try
            {
                bool        isDeduct = false;
                CrystalInfo crystal  = new CrystalInfo();
                content = LanguageManager.GetLang().St_SummerThreeGameCoinNotice.Substring(0, 5);
                foreach (PrizeInfo prize in prizeList)
                {
                    int num = prize.Num;
                    switch (prize.Type)
                    {
                    case RewardType.GameGoin:
                        userInfo.GameCoin = MathUtils.Addition(userInfo.GameCoin, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeGameCoinNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_GameCoin, num) + ",";
                        }
                        break;

                    case RewardType.Obtion:
                        userInfo.ObtainNum = MathUtils.Addition(userInfo.ObtainNum, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeObtionNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_ObtionNum, num) + ",";
                        }
                        break;

                    case RewardType.ExpNum:
                        userInfo.ExpNum = MathUtils.Addition(userInfo.ExpNum, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeExpNumNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_ExpNum, num) + ",";
                        }
                        break;

                    case RewardType.EnergyNum:
                        userInfo.EnergyNum = MathUtils.Addition(userInfo.EnergyNum, (short)num, short.MaxValue);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeEnergyNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_EnergyNum, num) + ",";
                        }
                        break;

                    case RewardType.Experience:
                        UserHelper.UserGeneralExp(userInfo.UserID, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeExperienceNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_Experience, num) + ",";
                        }
                        break;

                    case RewardType.Gold:
                        userInfo.ItemGold = MathUtils.Addition(userInfo.ItemGold, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeGoldNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_GiftGoldNum, num) + ",";
                        }
                        break;

                    case RewardType.Item:
                        if (UserHelper.IsBeiBaoFull(userInfo))
                        {
                            content = LanguageManager.GetLang().St1107_GridNumFull;
                            return(false);
                        }
                        UserItemHelper.AddUserItem(userInfo.UserID, prize.ItemID, num);
                        ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(prize.ItemID);
                        if (itemInfo != null)
                        {
                            if (content.Length == 0)
                            {
                                content = string.Format(LanguageManager.GetLang().St_SummerThreeItemNotice, num);
                            }
                            else
                            {
                                content += string.Format("{0}*{1}", itemInfo.ItemName, num) + ",";
                            }
                        }
                        break;

                    case RewardType.CrystalType:
                        if (!UserCrystalInfo.CheckFull(userInfo.UserID, 0))
                        {
                            content = LanguageManager.GetLang().St1307_FateBackpackFull;
                            return(false);
                        }
                        List <CrystalInfo> crystalArray2 = new ConfigCacheSet <CrystalInfo>().FindAll(m => m.CrystalQuality == prize.CrystalType);
                        if (crystalArray2.Count > 0)
                        {
                            int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count);
                            int crystalID = crystalArray2[randomNum].CrystalID;
                            UserHelper.CrystalAppend(userInfo.UserID, crystalID, 2);
                            CrystalHelper.SendChat(crystalArray2[randomNum].CrystalID, userInfo);
                            crystal = new ConfigCacheSet <CrystalInfo>().FindKey(crystalID);
                            if (crystal != null)
                            {
                                content += string.Format(LanguageManager.GetLang().St_Crystal, CrystalHelper.GetQualityName(crystal.CrystalQuality), crystal.CrystalName) + ",";
                            }
                        }
                        else
                        {
                            TraceLog.WriteError("配置出错");
                            return(false);
                        }
                        break;

                    case RewardType.CrystalId:
                        if (!UserCrystalInfo.CheckFull(userInfo.UserID, 0))
                        {
                            content = LanguageManager.GetLang().St1307_FateBackpackFull;
                            return(false);
                        }
                        UserHelper.CrystalAppend(userInfo.UserID, prize.ItemID, 2);
                        CrystalHelper.SendChat(prize.ItemID, userInfo);
                        crystal = new ConfigCacheSet <CrystalInfo>().FindKey(prize.ItemID);
                        if (crystal != null)
                        {
                            content += string.Format(LanguageManager.GetLang().St_Crystal, CrystalHelper.GetQualityName(crystal.CrystalQuality), crystal.CrystalName) + ",";
                        }
                        break;

                    case RewardType.Spare:
                        int currNum = userInfo.SparePartList.FindAll(m => string.IsNullOrEmpty(m.UserItemID)).Count;
                        if (currNum >= userInfo.UserExtend.SparePartGridNum)
                        {
                            content = LanguageManager.GetLang().St1213_GridNumFull;
                            return(false);
                        }
                        UserSparePart sparePart = UserSparePart.GetRandom(prize.ItemID);
                        SparePartInfo partInfo  = new ConfigCacheSet <SparePartInfo>().FindKey(prize.ItemID);
                        if (partInfo != null && sparePart != null && UserHelper.AddSparePart(userInfo, sparePart))
                        {
                            SendChat(prize, userInfo.NickName, partInfo.Name);
                        }
                        content = string.Empty;
                        break;

                    default:
                        break;
                    }
                    if (prize.Reward == 3 && !string.IsNullOrEmpty(prize.Desc))
                    {
                        content = prize.Desc;
                    }
                    //原因:开启礼包消耗的物品
                    if (prize.DemandItem > 0 && !isDeduct)
                    {
                        UserItemHelper.UseUserItem(userInfo.UserID, prize.DemandItem, prize.DemandNum);
                        isDeduct = true;
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                content = "使用礼包出错!";
                TraceLog.WriteError("使用礼包出错!", ex);
            }
            return(false);
        }
Beispiel #9
0
        public override bool TakeAction()
        {
            UserHelper.GetUserLightOpen(ContextUser.UserID);
            short opType     = 0;
            int   huntingID2 = 0;

            if (huntingID < 1005)
            {
                huntingID2 = MathUtils.Addition(huntingID, 1, int.MaxValue);
            }
            else
            {
                huntingID2 = 1001; //huntingID;
            }
            UserHelper.ChechDailyRestrain(ContextUser.UserID);

            if (!CrystalHelper.CheckAllowCrystall(ContextUser))
            {
                ErrorCode = 1000;
                ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull;
                return(false);
            }
            else
            {
                if (!CrystalHelper.CheckAllowCrystall(ContextUser))
                {
                    ErrorCode = errorNum;
                    ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull;
                    return(false);
                }
            }

            ProbabilityInfo probabilityInfo = null;

            if (ops == 1)
            {
                #region
                opType = 1;
                UserDailyRestrain userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(ContextUser.UserID);
                probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率
                if (probabilityInfo == null)
                {
                    return(false);
                }
                ProbabilityInfo probability1 = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID2);
                if (userRestrain != null && userRestrain.Funtion2 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date)
                {
                    if (probabilityInfo.Price > ContextUser.GameCoin)
                    {
                        ErrorCode = errorNum;
                        ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                        return(false);
                    }
                }
                //暑期第三弹
                if (huntingID2 == 1001 && !NoviceHelper.IsGianCrystalPack(ContextUser))
                {
                    ErrorCode = errorNum;
                    ErrorInfo = LanguageManager.GetLang().St1305_BeiBaoBackpackFull;
                    return(false);
                }
                var lightCacheSet = new PersonalCacheStruct <UserLight>();
                if (huntingID != 1001)
                {
                    UserLight userLight1 = lightCacheSet.FindKey(ContextUser.UserID, huntingID);
                    if (userLight1.IsLight == 2)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        return(false);
                    }

                    if (userLight1.IsLight == 1)
                    {
                        userLight1.IsLight = 2;
                        //userLight1.Update();
                    }
                }
                UserLight userLight = new PersonalCacheStruct <UserLight>().FindKey(ContextUser.UserID, huntingID2);
                if (RandomUtils.IsHit(probability1.Light))
                {
                    ErrorCode = ErrorCode;
                    ErrorInfo = probability1.HuntingName;

                    if (userLight != null)
                    {
                        userLight.IsLight = 1;
                        //userLight.Update();
                    }
                    else
                    {
                        userLight = new UserLight()
                        {
                            UserID    = ContextUser.UserID,
                            HuntingID = huntingID2,
                            IsLight   = 1
                        };
                        lightCacheSet.Add(userLight);
                    }
                }

                if (userRestrain != null)
                {
                    if (userRestrain.Funtion2 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date)
                    {
                        ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, probabilityInfo.Price, 0);
                        //ContextUser.Update();
                    }
                    else
                    {
                        userRestrain.Funtion2 = MathUtils.Addition(userRestrain.Funtion2, 1, int.MaxValue);
                        //userRestrain.Update();
                    }
                }
                else
                {
                    ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, probabilityInfo.Price, 0);
                    //ContextUser.Update();
                }

                lightArray = new PersonalCacheStruct <UserLight>().FindAll(ContextUser.UserID);
                #endregion
            }
            else if (ops == 2)
            {
                #region
                opType = 2;
                if (ContextUser.VipLv < 5)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_VipNotEnough;
                    return(false);
                }

                probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率
                if (probabilityInfo == null)
                {
                    return(false);
                }

                if (ContextUser.GoldNum < probabilityInfo.Price)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                UserLight uLightInfo = new PersonalCacheStruct <UserLight>().FindKey(ContextUser.UserID, probabilityInfo.GoldHunting);
                if (uLightInfo != null && uLightInfo.IsLight == 1)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1305_HuntingIDLight;
                    return(false);
                }
                else if (uLightInfo != null && (uLightInfo.IsLight == 2 || uLightInfo.IsLight == 0))
                {
                    uLightInfo.IsLight = 1;
                }
                else
                {
                    uLightInfo = new UserLight()
                    {
                        UserID    = ContextUser.UserID,
                        HuntingID = probabilityInfo.GoldHunting,
                        IsLight   = 1
                    };
                    new PersonalCacheStruct <UserLight>().Add(uLightInfo);
                }

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, probabilityInfo.Price, int.MaxValue);
                lightArray          = new PersonalCacheStruct <UserLight>().FindAll(ContextUser.UserID);
                #endregion
            }

            //每种品质的概率
            double[]           probabilityArray2 = { (double)probabilityInfo.Gray, (double)probabilityInfo.Green, (double)probabilityInfo.Blue, (double)probabilityInfo.Purple, (double)probabilityInfo.Yellow, (double)probabilityInfo.Red };
            int                index2            = RandomUtils.GetHitIndex(probabilityArray2);
            CrystalQualityType qualityType       = (CrystalQualityType)Enum.Parse(typeof(CrystalQualityType), (index2 + 1).ToString());
            List <CrystalInfo> crystalArray2     = new ShareCacheStruct <CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= ContextUser.UserLv);
            if (crystalArray2.Count > 0)
            {
                int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count);
                crystal = new ShareCacheStruct <CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID);
                if (crystal != null && crystal.CrystalQuality == CrystalQualityType.Gray)
                {
                    //wuzf修改 8-15 灰色放在临时背包不存DB
                    CrystalHelper.AppendGrayCrystal(ContextUser, crystal.CrystalID);
                }
                else if (crystal != null)
                {
                    var package = UserCrystalPackage.Get(Uid);

                    UserCrystalInfo userCrystal = new UserCrystalInfo()
                    {
                        UserCrystalID = Guid.NewGuid().ToString(),
                        CrystalID     = crystal.CrystalID,
                        CrystalLv     = 1,
                        CurrExprience = 0,
                        GeneralID     = 0,
                        IsSale        = 1,
                        CreateDate    = DateTime.Now
                    };
                    package.SaveCrystal(userCrystal);
                    UserLogHelper.AppenCtystalLog(ContextUser.UserID, opType, crystal.CrystalID, probabilityInfo.Price, probabilityInfo.Price, null, 1, 0);
                    //高品质聊天通知);
                    if (crystal.CrystalQuality >= CrystalQualityType.Yellow)
                    {
                        var    cacheChat = new TjxChatService();
                        string content   = string.Format(LanguageManager.GetLang().St1305_HighQualityNotice,
                                                         ContextUser.NickName,
                                                         CrystalHelper.GetQualityName(crystal.CrystalQuality),
                                                         crystal.CrystalName
                                                         );
                        cacheChat.SystemSend(ChatType.World, content);
                    }
                }
            }

            //日常任务-猎命
            TaskHelper.TriggerDailyTask(Uid, 4009);
            return(true);
        }
Beispiel #10
0
        /// <summary>
        /// write the interactive chains into a pdb formated text file
        /// </summary>
        /// <param name="pdbId"></param>
        /// <param name="interChains"></param>
        public string WriteBiolUnitFile(string pdbId, string buId, Dictionary <string, AtomInfo[]> buChains, string destDir,
                                        CrystalInfo cryst1, Matrix fractMatrix)
        {
            string       fileName   = Path.Combine(destDir, pdbId + "_" + buId.ToString() + ".pdb");
            FileStream   fileStream = new FileStream(Path.Combine(filePath, fileName), FileMode.Create, FileAccess.Write);
            StreamWriter fileWriter = new StreamWriter(fileStream);
            string       header     = "HEADER    " + pdbId + "                    " + DateTime.Today;

            fileWriter.WriteLine(header);
            string        remark         = "REMARK 290 ";
            int           count          = 0;
            List <string> chainSymOpList = new List <string> (buChains.Keys);

            string[] chainSymOpStrs = SortChainSymOpList(chainSymOpList);
            foreach (string chainAndSymOpStr in chainSymOpStrs)
            {
                string thisRemark = remark + letters[count].ToString() + ": ";
                // format of chainAndSymOpStr: chain_symOpNum_fullsymString
                string[] fields = chainAndSymOpStr.Split('_');
                thisRemark += fields[0].PadRight(3, ' ');
                thisRemark += fields[1].PadRight(3, ' ');
                thisRemark += fields[2].PadRight(30, ' ');
                fileWriter.WriteLine(thisRemark);
                count++;
            }
            string crystString = FormatCrystString(cryst1);
            string fractString = FormatFractString(fractMatrix);

            fileWriter.WriteLine(crystString);
            fileWriter.WriteLine(fractString);


            int atomId = 0;

            count = 0;
            try
            {
                string preSymOpNum = "0";
                foreach (string chain in chainSymOpStrs)
                {
                    string[] fields   = chain.Split('_');
                    string   symOpNum = fields[1];
                    if (preSymOpNum != symOpNum)
                    {
                        atomId = 0;
                    }
                    ChainAtoms buChain = new ChainAtoms();
                    buChain.CartnAtoms = (AtomInfo[])buChains[chain];
                    buChain.SortByAtomId();
                    string chainId = letters[count % letters.Length].ToString();
                    WriteOneChain(buChain.CartnAtoms, chainId, ref atomId, fileWriter);
                    count++;
                    preSymOpNum = symOpNum;
                }
                fileWriter.WriteLine("END");
            }
            catch (Exception ex)
            {
                string errorMsg = ex.Message;
                throw ex;
            }
            finally
            {
                fileWriter.Close();
            }
            return(fileName);
        }