Ejemplo n.º 1
0
        private int GiveRoleAwards(GameClient client, int success, int score, KingOfBattleSceneInfo sceneInfo)
        {
            long addExp       = 0;
            int  addBindJinBi = 0;
            List <AwardsItemData> awardsItemDataList = null;

            if (score >= RuntimeData.KingOfBattleLowestJiFen)
            {
                //最终经验(取整万舍去尾数) = 经验系数 * (0.2 + Min(0.8, (积分 ^ 0.5) / 100)
                //最终金币(取整万舍去尾数) = 金币系数 * Min(100, (积分 ^ 0.5))
                addExp       = (long)(sceneInfo.Exp * (0.2 + Math.Min(0.8, Math.Pow(score, 0.5) / 100)));
                addBindJinBi = (int)(sceneInfo.BandJinBi * Math.Min(100, Math.Pow(score, 0.5)));
                if (success > 0)
                {
                    awardsItemDataList = sceneInfo.WinAwardsItemList.Items;
                }
                else
                {
                    addExp             = (long)(addExp * 0.8);
                    addBindJinBi       = (int)(addBindJinBi * 0.8);
                    awardsItemDataList = sceneInfo.LoseAwardsItemList.Items;
                }

                addExp       = addExp - (addExp % 10000);
                addBindJinBi = addBindJinBi - (addBindJinBi % 10000);
            }

            if (awardsItemDataList != null && !Global.CanAddGoodsNum(client, awardsItemDataList.Count))
            {
                // 背包不足
                return(StdErrorCode.Error_BagNum_Not_Enough);
            }

            if (addExp > 0)
            {
                GameManager.ClientMgr.ProcessRoleExperience(client, addExp);
            }

            if (addBindJinBi > 0)
            {
                GameManager.ClientMgr.AddMoney1(client, addBindJinBi, "王者战场奖励");
            }

            if (awardsItemDataList != null)
            {
                foreach (var item in awardsItemDataList)
                {
                    Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, item.GoodsNum, 0, "", item.Level, item.Binding, 0, "", true, 1, "王者战场奖励", Global.ConstGoodsEndTime, 0, 0, item.IsHaveLuckyProp, 0, item.ExcellencePorpValue, item.AppendLev);
                }
            }

            return(StdErrorCode.Error_Success);
        }
Ejemplo n.º 2
0
        // 通知客户端有奖励可以领取
        private void NtfCanGetAward(GameClient client, int success, int score, KingOfBattleSceneInfo sceneInfo, int sideScore1, int sideScore2)
        {
            long addExp       = 0;
            int  addBindJinBi = 0;
            List <AwardsItemData> awardsItemDataList = null;

            if (score >= RuntimeData.KingOfBattleLowestJiFen)
            {
                //最终经验(取整万舍去尾数) = 经验系数 * (0.2 + Min(0.8, (积分 ^ 0.5) / 100)
                //最终金币(取整万舍去尾数) = 金币系数 * Min(100, (积分 ^ 0.5))
                addExp       = (long)(sceneInfo.Exp * (0.2 + Math.Min(0.8, Math.Pow(score, 0.5) / 100)));
                addBindJinBi = (int)(sceneInfo.BandJinBi * Math.Min(100, Math.Pow(score, 0.5)));
                if (success > 0)
                {
                    awardsItemDataList = sceneInfo.WinAwardsItemList.Items;
                }
                else
                {
                    addExp             = (long)(addExp * 0.8);
                    addBindJinBi       = (int)(addBindJinBi * 0.8);
                    awardsItemDataList = sceneInfo.LoseAwardsItemList.Items;
                }

                addExp       = addExp - (addExp % 10000);
                addBindJinBi = addBindJinBi - (addBindJinBi % 10000);
            }

            KingOfBattleAwardsData awardsData = new KingOfBattleAwardsData();

            awardsData.Exp                = addExp;
            awardsData.BindJinBi          = addBindJinBi;
            awardsData.Success            = success;
            awardsData.AwardsItemDataList = awardsItemDataList;
            awardsData.SideScore1         = sideScore1;
            awardsData.SideScore2         = sideScore2;
            awardsData.SelfScore          = score;

            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_KINGOFBATTLE_AWARD, awardsData);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加一个场景
        /// </summary>
        public bool AddCopyScenes(GameClient client, CopyMap copyMap, SceneUIClasses sceneType)
        {
            if (sceneType == SceneUIClasses.KingOfBattle)
            {
                GameMap gameMap = null;
                if (!GameManager.MapMgr.DictMaps.TryGetValue(client.ClientData.MapCode, out gameMap))
                {
                    return(false);
                }

                int      fuBenSeqId = copyMap.FuBenSeqID;
                int      mapCode    = copyMap.MapCode;
                int      roleId     = client.ClientData.RoleID;
                int      gameId     = (int)Global.GetClientKuaFuServerLoginData(client).GameId;
                DateTime now        = TimeUtil.NowDateTime();
                lock (RuntimeData.Mutex)
                {
                    KingOfBattleScene scene = null;
                    if (!SceneDict.TryGetValue(fuBenSeqId, out scene))
                    {
                        KingOfBattleSceneInfo     sceneInfo = null;
                        YongZheZhanChangFuBenData fuBenData;
                        if (!RuntimeData.FuBenItemData.TryGetValue(gameId, out fuBenData))
                        {
                            LogManager.WriteLog(LogTypes.Error, "王者战场没有为副本找到对应的跨服副本数据,GameID:" + gameId);
                        }

                        if (!RuntimeData.SceneDataDict.TryGetValue(fuBenData.GroupIndex, out sceneInfo))
                        {
                            LogManager.WriteLog(LogTypes.Error, "王者战场没有为副本找到对应的档位数据,ID:" + fuBenData.GroupIndex);
                        }

                        scene         = new KingOfBattleScene();
                        scene.CopyMap = copyMap;
                        scene.CleanAllInfo();
                        scene.GameId         = gameId;
                        scene.m_nMapCode     = mapCode;
                        scene.CopyMapId      = copyMap.CopyMapID;
                        scene.FuBenSeqId     = fuBenSeqId;
                        scene.m_nPlarerCount = 1;
                        scene.SceneInfo      = sceneInfo;
                        scene.MapGridWidth   = gameMap.MapGridWidth;
                        scene.MapGridHeight  = gameMap.MapGridHeight;
                        DateTime startTime = now.Date.Add(GetStartTime(sceneInfo.Id));
                        scene.StartTimeTicks = startTime.Ticks / 10000;
                        InitScene(scene, client);
                        scene.GameStatisticalData.GameId = gameId;

                        SceneDict[fuBenSeqId] = scene;
                    }
                    else
                    {
                        scene.m_nPlarerCount++;
                    }

                    KingOfBattleClientContextData clientContextData;
                    if (!scene.ClientContextDataDict.TryGetValue(roleId, out clientContextData))
                    {
                        clientContextData = new KingOfBattleClientContextData()
                        {
                            RoleId = roleId, ServerId = client.ServerId, BattleWhichSide = client.ClientData.BattleWhichSide
                        };
                        scene.ClientContextDataDict[roleId] = clientContextData;
                    }
                    else
                    {
                        clientContextData.KillNum = 0;
                    }

                    client.SceneObject       = scene;
                    client.SceneGameId       = scene.GameId;
                    client.SceneContextData2 = clientContextData;

                    copyMap.IsKuaFuCopy = true;
                    copyMap.SetRemoveTicks(TimeUtil.NOW() + scene.SceneInfo.TotalSecs * TimeUtil.SECOND);
                }

                //更新状态
                YongZheZhanChangClient.getInstance().GameFuBenRoleChangeState(roleId, (int)KuaFuRoleStates.StartGame);
                return(true);
            }
            return(false);
        }