Exemplo n.º 1
0
        public static bool GetRandom(float probability)
        {
            bool result = false;

            switch (Fight.Controller.FightController.instance.fightType)
            {
            case Logic.Enums.FightType.PVE:
            case Logic.Enums.FightType.Arena:
            case Logic.Enums.FightType.DailyPVE:
            case Logic.Enums.FightType.Expedition:
            case Logic.Enums.FightType.WorldTree:
            case Logic.Enums.FightType.WorldBoss:
            case Logic.Enums.FightType.FirstFight:
            case Logic.Enums.FightType.SkillDisplay:
            case Logic.Enums.FightType.PVP:
            case Logic.Enums.FightType.FriendFight:
            case Logic.Enums.FightType.MineFight:
#if UNITY_EDITOR
            case Logic.Enums.FightType.Imitate:
#endif
                result = RandomUtil.GetRandom(probability);
                break;

            case Logic.Enums.FightType.ConsortiaFight:
                result = RandomUtil.GetRandom(Fight.Model.FightProxy.instance.randomSeed, probability, RATIO);
                break;
            }
            return(result);
        }
Exemplo n.º 2
0
        public static BatchGetContact GetContactList()
        {
            var reqCookies = new CookieContainer();

            CookieContainer resCookies = null;

            reqCookies = new CookieContainer();
            reqCookies.Add(new Cookie("MM_WX_NOTIFY_STATE", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("MM_WX_SOUND_STATE", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("last_wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("login_frequency", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("mm_lang", "zh_CN", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("pgv_pvi", LoginHelper.pgv_pvi, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("pgv_si", LoginHelper.pgv_si, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwx_auth_ticket", LoginHelper.LoginPageCookie.webwx_auth_ticket, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwx_data_ticket", LoginHelper.LoginPageCookie.webwx_data_ticket, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwxuvid", LoginHelper.LoginPageCookie.webwxuvid, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxloadtime", CalcTimeUtil.GetUnixDateTime(new TimeSpan(365, 0, 0, 0)), "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxsid", LoginHelper.LoginPageCookie.wxsid, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));

            var webwxgetcontactUrl = string.Format(webwxgetcontactUrlTemple, RandomUtil.GetRandom(10), LoginHelper.LoginPageXml.skey);

            string json = WebClientUtil.GetResponseOnCookie(webwxgetcontactUrl, "get", reqCookies, out resCookies);

            InitHelper.BatchGetContact = SerializeUtil.Deserialize <BatchGetContact>(json);

            return(InitHelper.BatchGetContact);
        }
Exemplo n.º 3
0
        public static float GetRandom()
        {
            float result = 0f;

            switch (Fight.Controller.FightController.instance.fightType)
            {
            case Logic.Enums.FightType.PVE:
            case Logic.Enums.FightType.Arena:
            case Logic.Enums.FightType.DailyPVE:
            case Logic.Enums.FightType.Expedition:
            case Logic.Enums.FightType.WorldTree:
            case Logic.Enums.FightType.WorldBoss:
            case Logic.Enums.FightType.FirstFight:
            case Logic.Enums.FightType.SkillDisplay:
            case Logic.Enums.FightType.PVP:
            case Logic.Enums.FightType.FriendFight:
            case Logic.Enums.FightType.MineFight:
#if UNITY_EDITOR
            case Logic.Enums.FightType.Imitate:
#endif
                result = RandomUtil.GetRandom();
                break;

            case Logic.Enums.FightType.ConsortiaFight:
                result = RandomUtil.GetRandom();    //没有处理概率为0则为1
                break;
            }
            return(result);
        }
        /// <summary>
        /// 获得序列
        /// </summary>
        /// <param name="name">序列名</param>
        /// <param name="defaultSequence">默认序列</param>
        /// <returns>序列实体</returns>
        protected BaseSequenceEntity GetSequenceByLock(string name, int defaultSequence)
        {
            var sequenceEntity = GetEntityByAdd(name);

            if (sequenceEntity == null)
            {
                // 这里添加记录时加锁机制。
                // 是否已经被锁住
                StatusCode = Status.CanNotLock.ToString();
                for (var i = 0; i < BaseSystemInfo.LockNoWaitCount; i++)
                {
                    // 被锁定的记录数
                    var lockCount = DbUtil.LockNoWait(DbHelper, BaseSequenceEntity.CurrentTableName, new KeyValuePair <string, object>(BaseSequenceEntity.FieldName, BaseSequenceEntity.CurrentTableName));
                    if (lockCount > 0)
                    {
                        sequenceEntity.Name      = name;
                        sequenceEntity.Reduction = defaultSequence - 1;
                        sequenceEntity.Sequence  = defaultSequence;
                        sequenceEntity.Step      = DefaultStep;
                        AddEntity(sequenceEntity);

                        StatusCode = Status.LockOk.ToString();
                        break;
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(RandomUtil.GetRandom(1, BaseSystemInfo.LockNoWaitTickMilliSeconds));
                    }
                }
                if (StatusCode == Status.LockOk.ToString())
                {
                    // JiRiGaLa 这个是否能省略
                    sequenceEntity = GetEntityByAdd(name);
                }
            }
            else
            {
                // 若记录已经存在,加锁,然后读取记录。
                // 是否已经被锁住
                StatusCode = Status.CanNotLock.ToString();
                for (var i = 0; i < BaseSystemInfo.LockNoWaitCount; i++)
                {
                    // 被锁定的记录数
                    var lockCount = DbUtil.LockNoWait(DbHelper, BaseSequenceEntity.CurrentTableName, new KeyValuePair <string, object>(BaseSequenceEntity.FieldName, name));
                    if (lockCount > 0)
                    {
                        sequenceEntity = GetEntityByAdd(name);
                        StatusCode     = Status.LockOk.ToString();
                        break;
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(RandomUtil.GetRandom(1, BaseSystemInfo.LockNoWaitTickMilliSeconds));
                    }
                }
            }
            return(sequenceEntity);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 用户忘记密码,发送密码
        /// </summary>
        /// <param name="email">邮箱地址</param>
        /// <param name="status">状态</param>
        /// <param name="statusMessage">状态信息</param>
        /// <param name="newPassword">新密码</param>
        /// <returns>成功发送密码</returns>
        public static bool ResetPassword(string email, out Status status, out string statusMessage, out string newPassword)
        {
            var result = false;

            // 1.用户是否找到?默认是未找到用户状态
            status        = Status.UserNotFound;
            statusMessage = "未找到对应的用户";
            newPassword   = RandomUtil.GetRandom(100000, 999999).ToString();

            var userContactManager = new BaseUserContactManager();
            var parameters         = new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>(BaseUserContactEntity.FieldEmail, email)
            };
            var userContactEntity = BaseEntity.Create <BaseUserContactEntity>(userContactManager.GetDataTable(parameters));

            if (userContactEntity != null && userContactEntity.UserId > 0)
            {
                var userManager = new BaseUserManager();
                // 2.用户是否已被删除?
                parameters = new List <KeyValuePair <string, object> >
                {
                    new KeyValuePair <string, object>(BaseUserEntity.FieldId, userContactEntity.UserId),
                    new KeyValuePair <string, object>(BaseUserEntity.FieldDeleted, 0)
                };
                var userEntity = BaseEntity.Create <BaseUserEntity>(userManager.GetDataTable(parameters));
                // 是否已找到了此用户
                if (userEntity != null && userEntity.Id > 0)
                {
                    // 3.用户是否有效的?
                    if (userEntity.Enabled == 1)
                    {
                        if (userManager.SetPassword(userEntity.Id, newPassword) > 0)
                        {
                            result        = true;
                            status        = Status.Ok;
                            statusMessage = "新密码已发送到您的注册邮箱" + email + ",请注意查收。";
                        }
                        else
                        {
                            status        = Status.ErrorUpdate;
                            statusMessage = "更新数据库失败,请重试!";
                        }
                    }
                    else
                    {
                        if (userEntity.Enabled == 0)
                        {
                            status        = Status.UserLocked;
                            statusMessage = "用户被锁定,不允许重置密码。";
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 用户忘记密码,发送密码
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="status">状态</param>
        /// <param name="statusMessage">状态信息</param>
        /// <param name="newPassword">新密码</param>
        /// <returns>成功发送密码</returns>
        public static bool SendPassword(string userName, out Status status, out string statusMessage, out string newPassword)
        {
            var result = false;

            // 1.用户是否找到?默认是未找到用户状态
            status        = Status.UserNotFound;
            statusMessage = "用户未找到,请重新输入用户名。";
            newPassword   = RandomUtil.GetRandom(100000, 999999).ToString();

            var userManager = new BaseUserManager();
            // 2.用户是否已被删除?
            var parameters = new List <KeyValuePair <string, object> >();

            parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldUserName, userName));
            parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDeleted, 0));
            var userEntity = BaseEntity.Create <BaseUserEntity>(userManager.GetDataTable(parameters));

            // 是否已找到了此用户
            if (userEntity != null && userEntity.Id > 0)
            {
                // 3.用户是否有效的?
                if (userEntity.Enabled == 1)
                {
                    //if (!string.IsNullOrEmpty(userEntity.Email))
                    //{
                    //    // 5.重新产生随机密码?
                    //    // 6.发送邮件给用户?
                    //    // 7.重新设置用户密码?
                    //    result = SendPassword(userEntity);
                    //    status = Status.Ok.ToString();
                    //    statusMessage = "新密码已发送到您的注册邮箱" + userEntity.Email + "。";
                    //}
                    //else
                    //{
                    //    // 4.用户是否有邮件账户?
                    //    status = Status.UserNotEmail.ToString();
                    //    statusMessage = "用户没有电子邮件地址,无法从新设置密码,请您及时联系系统管理员。";
                    //}
                }
                else
                {
                    if (userEntity.Enabled == 0)
                    {
                        status        = Status.UserLocked;
                        statusMessage = "用户被锁定,不允许设置密码。";
                    }
                    else
                    {
                        status        = Status.UserNotActive;
                        statusMessage = "用户还未被激活,不允许设置密码。";
                    }
                }
            }

            return(result);
        }
Exemplo n.º 7
0
        //获取N张随机牌池的牌
        public List <CardEntry> GetSameCardEntry(int num)
        {
            if (num > cardDbItem.cardEntryPool.Count)
            {
                UtilityLog.LogError("need card number too much");
                return(null);
            }
            List <int>       randomList  = RandomUtil.GetRandom(0, cardDbItem.cardEntryPool.Count - 1, num, false);
            List <CardEntry> cardEntries = new List <CardEntry>();

            foreach (int i in randomList)
            {
                cardEntries.Add(cardDbItem.cardEntryPool[i]);
            }
            return(cardEntries);
        }
Exemplo n.º 8
0
    /// <summary>
    /// 增加建筑
    /// </summary>
    /// <param name="addRate"></param>
    /// <param name="randomData"></param>
    /// <param name="startPosition"></param>
    /// <param name="buildingType"></param>
    public static bool AddBuilding(float addRate, uint randomData, Vector3Int startPosition, BuildingTypeEnum buildingType)
    {
        float randomRate;

        if (addRate < 0.00001f)
        {
            //概率小于万分之一的用RandomTools
            int         seed        = WorldCreateHandler.Instance.manager.GetWorldSeed();
            RandomTools randomTools = RandomUtil.GetRandom(seed, startPosition.x, startPosition.y, startPosition.z);
            //生成概率
            randomRate = randomTools.NextFloat();
        }
        else
        {
            randomRate = WorldRandTools.GetValue(startPosition, randomData);
        }
        if (randomRate < addRate)
        {
            BuildingInfoBean buildingInfo = BiomeHandler.Instance.manager.GetBuildingInfo(buildingType);

            List <BuildingBean> listBuildingData = buildingInfo.listBuildingData;

            int randomAngle = WorldRandTools.Range(0, 4, startPosition) * 90;

            for (int i = 0; i < listBuildingData.Count; i++)
            {
                BuildingBean buildingData   = listBuildingData[i];
                Vector3Int   targetPosition = startPosition + buildingData.GetPosition();
                float        createRate     = WorldRandTools.GetValue(targetPosition);

                if (buildingData.randomRate == 0 || createRate < buildingData.randomRate)
                {
                    VectorUtil.GetRotatedPosition(startPosition, targetPosition, new Vector3(0, randomAngle, 0));
                    WorldCreateHandler.Instance.manager.AddUpdateBlock(targetPosition, buildingData.blockId, (BlockDirectionEnum)buildingData.direction);
                }
            }
            return(true);
        }
        return(false);
    }
Exemplo n.º 9
0
        private List <CharacterEntity> SortedCross(List <CharacterEntity> list)
        {
            bool player = RandomUtil.GetRandom(0.5f);
            List <CharacterEntity>  result     = new List <CharacterEntity>();
            Queue <CharacterEntity> heroQueue  = new Queue <CharacterEntity>();
            Queue <CharacterEntity> enemyQueue = new Queue <CharacterEntity>();

            for (int i = 0, count = list.Count; i < count; i++)
            {
                CharacterEntity c = list[i];
                if (c.isPlayer)
                {
                    heroQueue.Enqueue(c);
                }
                else
                {
                    enemyQueue.Enqueue(c);
                }
            }
            while (heroQueue.Count > 0 || enemyQueue.Count > 0)
            {
                if (player)
                {
                    if (heroQueue.Count > 0)
                    {
                        result.Add(heroQueue.Dequeue());
                    }
                }
                else
                {
                    if (enemyQueue.Count > 0)
                    {
                        result.Add(enemyQueue.Dequeue());
                    }
                }
                player = !player;
            }
            return(result);
        }
Exemplo n.º 10
0
    /// <summary>
    /// 增加世界之树
    /// </summary>
    /// <param name="startPosition"></param>
    /// <param name="treeData"></param>
    public static void AddTreeForWorld(Vector3Int startPosition, BiomeForTreeData treeData)
    {
        //概率小于万分之一的用RandomTools
        int         seed        = WorldCreateHandler.Instance.manager.GetWorldSeed();
        RandomTools randomTools = RandomUtil.GetRandom(seed, startPosition.x, startPosition.y, startPosition.z);
        //生成概率
        float addRate = randomTools.NextFloat();
        //高度
        int treeHeight = WorldRandTools.Range(treeData.minHeight, treeData.maxHeight);

        if (addRate < treeData.addRate)
        {
            for (int y = 0; y < treeHeight; y++)
            {
                Vector3Int treeTrunkPosition = startPosition + Vector3Int.up * (y + 1);
                int        trunkRange        = treeData.trunkRange;
                for (int x = -trunkRange; x <= trunkRange; x++)
                {
                    for (int z = -trunkRange; z <= trunkRange; z++)
                    {
                        if ((x == -trunkRange || x == trunkRange) && (z == -trunkRange || z == trunkRange))
                        {
                            continue;
                        }
                        else if ((x == -trunkRange + 1 || x == trunkRange - 1) && (z == -trunkRange || z == trunkRange))
                        {
                            continue;
                        }
                        else if ((z == -trunkRange + 1 || z == trunkRange - 1) && (x == -trunkRange || x == trunkRange))
                        {
                            continue;
                        }
                        else
                        {
                            Vector3Int tempTrunkPosition = new(treeTrunkPosition.x + x, treeTrunkPosition.y, treeTrunkPosition.z + z);
                            //生成树干
                            WorldCreateHandler.Instance.manager.AddUpdateBlock(tempTrunkPosition, treeData.treeTrunk);
                        }

                        if ((x == -trunkRange || x == trunkRange || z == -trunkRange || z == trunkRange) ||
                            ((x == -trunkRange + 1 || x == trunkRange - 1) && (z == -trunkRange || z == trunkRange)) ||
                            ((z == -trunkRange + 1 || z == trunkRange - 1) && (x == -trunkRange || x == trunkRange)) ||
                            ((x == -trunkRange + 2 || x == trunkRange - 2) && (z == -trunkRange || z == trunkRange)) ||
                            ((z == -trunkRange + 2 || z == trunkRange - 2) && (x == -trunkRange || x == trunkRange)))
                        {
                            //树盘
                            if (y == 0 || y == 1)
                            {
                                Vector3Int baseStartPosition = treeTrunkPosition + new Vector3Int(x, -1, z);
                                int        baseWith          = WorldRandTools.Range(3, 6);
                                for (int b = 0; b < baseWith; b++)
                                {
                                    BlockDirectionEnum baseDirection =
                                        (x == -trunkRange ? BlockDirectionEnum.LeftForward
                                        : x == trunkRange ? BlockDirectionEnum.RightForward
                                        : z == -trunkRange ? BlockDirectionEnum.ForwardForward
                                        : z == trunkRange ? BlockDirectionEnum.BackForward
                                        : BlockDirectionEnum.LeftForward);

                                    int branchDirectionX = WorldRandTools.Range(0, 2);
                                    int branchDirectionY = WorldRandTools.Range(0, 2);
                                    int branchDirectionZ = WorldRandTools.Range(0, 2);

                                    int addPositionX;
                                    if (x == -trunkRange || x == trunkRange)
                                    {
                                        addPositionX = x > 0 ? 1 : -1;
                                    }
                                    else if (x == -trunkRange + 1 || x == trunkRange - 1 || x == -trunkRange + 2 || x == trunkRange - 2)
                                    {
                                        int tempRandom = WorldRandTools.Range(0, 2);
                                        if (tempRandom == 0)
                                        {
                                            addPositionX = x > 0 ? 1 : -1;
                                        }
                                        else
                                        {
                                            addPositionX = (branchDirectionX == 0 ? -1 : 1);
                                        }
                                    }
                                    else
                                    {
                                        addPositionX = (branchDirectionX == 0 ? -1 : 1);
                                    }

                                    int addPositionZ;
                                    if (z == -trunkRange || z == trunkRange)
                                    {
                                        addPositionZ = z > 0 ? 1 : -1;
                                    }
                                    else if (z == -trunkRange + 1 || z == trunkRange - 1 || z == -trunkRange + 2 || z == trunkRange - 2)
                                    {
                                        int tempRandom = WorldRandTools.Range(0, 2);
                                        if (tempRandom == 0)
                                        {
                                            addPositionZ = z > 0 ? 1 : -1;
                                        }
                                        else
                                        {
                                            addPositionZ = (branchDirectionZ == 0 ? -1 : 1);
                                        }
                                    }
                                    else
                                    {
                                        addPositionZ = (branchDirectionZ == 0 ? -1 : 1);
                                    }

                                    int addPositionY = (branchDirectionY == 0 ? -1 : 0);
                                    if (addPositionY == -1)
                                    {
                                        addPositionX  = 0;
                                        addPositionZ  = 0;
                                        baseDirection = BlockDirectionEnum.UpForward;
                                    }

                                    Vector3Int addPosition = new(addPositionX, addPositionY, addPositionZ);
                                    baseStartPosition += addPosition;
                                    //干
                                    WorldCreateHandler.Instance.manager.AddUpdateBlock(baseStartPosition, treeData.treeTrunk, baseDirection);
                                }
                            }

                            //枝
                            if (y > treeHeight / 2)
                            {
                                int addBranchRate = WorldRandTools.Range(0, 3);
                                if (addBranchRate == 0)
                                {
                                    int        branchWith          = WorldRandTools.Range(0, treeHeight / 2) + treeHeight / 4;
                                    Vector3Int branchStartPosition = treeTrunkPosition + new Vector3Int(x, 0, z);

                                    for (int b = 0; b < branchWith; b++)
                                    {
                                        BlockDirectionEnum branchDirection =
                                            (x == -trunkRange ? BlockDirectionEnum.LeftForward
                                            : x == trunkRange ? BlockDirectionEnum.RightForward
                                            : z == -trunkRange ? BlockDirectionEnum.ForwardForward
                                            : z == trunkRange ? BlockDirectionEnum.BackForward
                                            : BlockDirectionEnum.LeftForward);

                                        int branchDirectionX = WorldRandTools.Range(0, 2);
                                        int branchDirectionY = WorldRandTools.Range(0, 4);
                                        int branchDirectionZ = WorldRandTools.Range(0, 2);

                                        int addPositionX;
                                        if (x == -trunkRange || x == trunkRange)
                                        {
                                            addPositionX = x > 0 ? 1 : -1;
                                        }
                                        else if (x == -trunkRange + 1 || x == trunkRange - 1 || x == -trunkRange + 2 || x == trunkRange - 2)
                                        {
                                            int tempRandom = WorldRandTools.Range(0, 2);
                                            if (tempRandom == 0)
                                            {
                                                addPositionX = x > 0 ? 1 : -1;
                                            }
                                            else
                                            {
                                                addPositionX = (branchDirectionX == 0 ? -1 : 1);
                                            }
                                        }
                                        else
                                        {
                                            addPositionX = (branchDirectionX == 0 ? -1 : 1);
                                        }

                                        int addPositionZ;
                                        if (z == -trunkRange || z == trunkRange)
                                        {
                                            addPositionZ = z > 0 ? 1 : -1;
                                        }
                                        else if (z == -trunkRange + 1 || z == trunkRange - 1 || z == -trunkRange + 2 || z == trunkRange - 2)
                                        {
                                            int tempRandom = WorldRandTools.Range(0, 2);
                                            if (tempRandom == 0)
                                            {
                                                addPositionZ = z > 0 ? 1 : -1;
                                            }
                                            else
                                            {
                                                addPositionZ = (branchDirectionZ == 0 ? -1 : 1);
                                            }
                                        }
                                        else
                                        {
                                            addPositionZ = (branchDirectionZ == 0 ? -1 : 1);
                                        }

                                        int addPositionY = (branchDirectionY == 0 ? 1 : 0);

                                        Vector3Int addPosition = new(addPositionX, addPositionY, addPositionZ);
                                        branchStartPosition += addPosition;
                                        //干
                                        WorldCreateHandler.Instance.manager.AddUpdateBlock(branchStartPosition, treeData.treeTrunk, branchDirection);
                                        //叶
                                        if (b % 4 == 0)
                                        {
                                            int leavesRange = 2;
                                            for (int leavesX = -leavesRange; leavesX <= leavesRange; leavesX++)
                                            {
                                                for (int leavesY = -leavesRange; leavesY <= leavesRange; leavesY++)
                                                {
                                                    for (int leavesZ = -leavesRange; leavesZ <= leavesRange; leavesZ++)
                                                    {
                                                        if (((leavesX == leavesRange || leavesX == -leavesRange) && (leavesY == leavesRange || leavesY == -leavesRange)) ||
                                                            ((leavesY == leavesRange || leavesY == -leavesRange) && (leavesZ == leavesRange || leavesZ == -leavesRange)) ||
                                                            ((leavesX == leavesRange || leavesX == -leavesRange) && (leavesZ == leavesRange || leavesZ == -leavesRange)))
                                                        {
                                                            continue;
                                                        }
                                                        Vector3Int leavesPosition = branchStartPosition + new Vector3Int(leavesX, leavesY, leavesZ);
                                                        WorldCreateHandler.Instance.manager.AddUpdateBlock(leavesPosition, treeData.treeLeaves);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 11
0
        public const int RATIO = 1000;//概率比
        public static int GetJudgeResult(CharacterEntity character, CharacterEntity target1, CharacterEntity target2, int skillId)
        {
            int judgeType = 0;

            switch (Fight.Controller.FightController.instance.fightType)
            {
            case Logic.Enums.FightType.PVE:
            case Logic.Enums.FightType.Arena:
            case Logic.Enums.FightType.DailyPVE:
            case Logic.Enums.FightType.Expedition:
            case Logic.Enums.FightType.WorldTree:
            case Logic.Enums.FightType.WorldBoss:
            case Logic.Enums.FightType.FirstFight:
            case Logic.Enums.FightType.SkillDisplay:
            case Logic.Enums.FightType.PVP:
            case Logic.Enums.FightType.FriendFight:
            case Logic.Enums.FightType.MineFight:
#if UNITY_EDITOR
            case Logic.Enums.FightType.Imitate:
#endif
                #region calc
                //判断是否命中→是否暴击→是否产生格挡→普通命中
                float hitProbability = 0;
                if (Fight.Controller.FightController.instance.isComboing)
                {
                    hitProbability = 1;
                }
                else
                {
                    hitProbability = character.hit - target1.dodge;    //命中几率=攻击方命中-受击方闪避
                }
                if (hitProbability > 0)
                {
                    if (RandomUtil.GetRandom(hitProbability))
                    {
                        judgeType = 1 << 0;
                        //Debugger.Log(judgeType);
                        float critProbability = character.crit - target2.antiCrit;    //暴击几率=攻击方暴击-受击方抗暴击
                        if (RandomUtil.GetRandom(critProbability))
                        {
                            judgeType |= 1 << 1;
                            //Debugger.Log(judgeType);
                        }
                        else
                        {
                            float blockProbability = target2.block - character.antiBlock;    //格挡几率=受击方格挡-攻击方破击
                            if (RandomUtil.GetRandom(blockProbability))
                            {
                                judgeType |= 1 << 2;
                                //Debugger.Log(judgeType);
                            }
                        }
                    }
                }
                #endregion
                break;

            case Logic.Enums.FightType.ConsortiaFight:
                judgeType = Fight.Model.FightProxy.instance.GetConsortiaJudgeType((int)character.characterInfo.instanceID, skillId, (int)target2.characterInfo.instanceID);
                break;
            }
            return(judgeType);
        }
Exemplo n.º 12
0
        public static void UploadMedia(string fromUserName, string toUserName, string mediaName)
        {
            var len = DataUtil.GetLength(mediaName);

            var md5 = DataUtil.GetMD5(mediaName);

            string uploadmediarequest = "{\"UploadType\":2,\"BaseRequest\":{\"Uin\":" + LoginHelper.LoginPageCookie.wxuin + ",\"Sid\":\"" + LoginHelper.LoginPageCookie.wxsid + "\",\"Skey\":\"" + LoginHelper.LoginPageXml.skey + "\",\"DeviceID\":\"e828447528404774\"},\"ClientMediaId\":" + RandomUtil.GetRandom(13) + ",\"TotalLen\":" + len + ",\"StartPos\":0,\"DataLen\":" + len + ",\"MediaType\":4,\"FromUserName\":\"" + fromUserName + "\",\"ToUserName\":\"" + toUserName + "\",\"FileMd5\":\"" + md5 + "\"}";

            var wxUploadMedia = SerializeUtil.Deserialize <WXUploadMedia>(WebClientUtil.UploadMediaOnCookie(UploadMediaUrl, mediaName, uploadmediarequest, LoginHelper.LoginPageCookie.webwx_data_ticket, LoginHelper.LoginPageXml.pass_ticket));

            if (wxUploadMedia != null && !string.IsNullOrEmpty(wxUploadMedia.MediaId))
            {
                SendImage(fromUserName, toUserName, wxUploadMedia.MediaId);
            }
        }
Exemplo n.º 13
0
        public override void Execute(INotification notification)
        {
            PlayerGroupProxy        playerGroupProxy        = Facade.RetrieveProxy(PlayerGroupProxy.NAME) as PlayerGroupProxy;
            ChooseStageCircuitProxy chooseStageCircuitProxy = Facade.RetrieveProxy(ChooseStageCircuitProxy.NAME) as ChooseStageCircuitProxy;
            CardDbProxy             cardDbProxy             = Facade.RetrieveProxy(CardDbProxy.NAME) as CardDbProxy;
            //当前回合玩家
            string     playerCodeChoose = chooseStageCircuitProxy.GetNowPlayerCode();
            PlayerItem playerItemNow    = playerGroupProxy.getPlayerByPlayerCode(playerCodeChoose);

            switch (notification.Type)
            {
            case UIViewSystemEvent.UI_CHOOSE_STAGE_START:

                List <CardInfo> shipCardList = cardDbProxy.GetCardInfoByType(CardMetrics.CARD_TYPE_SHIP);
                //随机序列
                List <int>    randomList     = RandomUtil.GetRandom(0, 5, 6, false);
                List <string> playerCodeList = new List <string>();
                foreach (string playerCode in playerGroupProxy.playerGroup.playerItems.Keys)
                {
                    playerCodeList.Add(playerCode);
                }
                //为每个玩家分配不同的船
                for (int rnum = 0; rnum < randomList.Count; rnum++)
                {
                    string    playerCode = playerCodeList[rnum % playerCodeList.Count];
                    CardEntry fpCardShip = cardDbProxy.GetCardEntryBCardInfo(shipCardList[randomList[rnum]]);
                    chooseStageCircuitProxy.chooseStageCircuitItem.playerShipCardMap[playerCode].Add(fpCardShip);
                }
                string playerCodeNow = chooseStageCircuitProxy.GetNowPlayerCode();
                SendNotification(UIViewSystemEvent.UI_VIEW_CURRENT, null, StringUtil.GetNTByNotificationTypeAndUIViewName(UIViewSystemEvent.UI_VIEW_CURRENT_OPEN_ONE_VIEW, UIViewConfig.getNameStrByUIViewName(UIViewName.ChooseStage)));
                SendNotification(LogicalSysEvent.LOGICAL_SYS, playerCodeNow, LogicalSysEvent.LOGICAL_SYS_CHOOSE_SHIP_CARD);
                break;

            case UIViewSystemEvent.UI_CHOOSE_STAGE_ONE_CARD:
                CardEntry card = notification.Body as CardEntry;

                if (card.WhichCard == CardType.ShipCard)
                {
                    //确认选择,然后返回选择动画
                    playerItemNow.shipCard = card;
                    SendNotification(UIViewSystemEvent.UI_CHOOSE_STAGE, card, StringUtil.GetNTByNotificationTypeAndPlayerCode(UIViewSystemEvent.UI_CHOOSE_STAGE_ONE_SHIP_CARD_ANIMATION, playerItemNow.playerCode));
                    SendNotification(UIViewSystemEvent.UI_CARD_DECK_LIST, playerItemNow, UIViewSystemEvent.UI_CARD_DECK_LIST_LOAD);

                    chooseStageCircuitProxy.IntoNextTurn();
                    playerCodeChoose = chooseStageCircuitProxy.GetNowPlayerCode();

                    //查看是否所有玩家都选择了船
                    if (playerGroupProxy.checkAllPlayerHasShip())
                    {
                        //渲染卡池
                        // List<CardEntry> cardEntries = cardDbProxy.GetSameCardEntry(3);
                        SendNotification(UIViewSystemEvent.UI_VIEW_CURRENT, UIViewConfig.getNameStrByUIViewName(UIViewName.ChooseStage), UIViewSystemEvent.UI_VIEW_CURRENT_CLOSE_ONE_VIEW);
                        //第一次发牌,发三组
                        List <List <CardEntry> > cardEntries = new List <List <CardEntry> >();
                        cardEntries.Add(cardDbProxy.GetOneCardListForPool());
                        cardEntries.Add(cardDbProxy.GetOneCardListForPool());
                        cardEntries.Add(cardDbProxy.GetOneCardListForPool());

                        SendNotification(UIViewSystemEvent.UI_VIEW_CURRENT, cardEntries, StringUtil.GetNTByNotificationTypeAndUIViewName(UIViewSystemEvent.UI_VIEW_CURRENT_OPEN_ONE_VIEW, UIViewConfig.getNameStrByUIViewName(UIViewName.ViewChooseMakeStage)));
                        //SendNotification(UIViewSystemEvent.UI_CHOOSE_STAGE, cardEntries, UIViewSystemEvent.UI_CHOOSE_STAGE_LOAD_CARD_ENTRY);
                    }
                    else
                    {
                        //渲染下一位玩家的船只选择
                        SendNotification(LogicalSysEvent.LOGICAL_SYS, playerCodeChoose, LogicalSysEvent.LOGICAL_SYS_CHOOSE_SHIP_CARD);
                    }
                }
                else
                {
                    //添加到卡组
                    //playerItemNow.cardDeck.PutOneCard(card);
                    cardDbProxy.RemoveOneCardEntry(card);
                    //该玩家的购买费用减少
                    playerItemNow.shipCard.cost -= card.cost;
                    SendNotification(UIViewSystemEvent.UI_CARD_DECK_LIST, playerItemNow, UIViewSystemEvent.UI_CARD_DECK_LIST_LOAD);
                    //下一回合
                    chooseStageCircuitProxy.IntoNextTurn();
                    List <CardEntry> cardEntries = cardDbProxy.GetSameCardEntry(3);
                    SendNotification(UIViewSystemEvent.UI_CHOOSE_STAGE, cardEntries, UIViewSystemEvent.UI_CHOOSE_STAGE_LOAD_CARD_ENTRY);
                }

                break;
            }
        }