Exemplo n.º 1
0
        private HuanYingSiYuanShengBeiContextData LostShengBei(GameClient client)
        {
            ShengBeiData shengBeiData = null;
            HuanYingSiYuanShengBeiContextData contextData = null;

            if (null != client.SceneContextData)
            {
                contextData = client.SceneContextData as HuanYingSiYuanShengBeiContextData;
                if (null != contextData)
                {
                    lock (Mutex)
                    {
                        //清除拥有者的buffer
                        client.ClientData.PropsCacheManager.SetExtProps(PropsSystemTypes.HysyShengBei, null);
                        double[] actionParams = new double[2] {
                            0, 0
                        };
                        Global.UpdateBufferData(client, BufferItemTypes.HysyShengBei, actionParams);
                        client.SceneContextData = null;
                    }
                }
            }

            return(contextData);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <param name="monster"></param>
        /// <returns></returns>
        public int GetCaiJiMonsterTime(GameClient client, Monster monster)
        {
            HuanYingSiYuanShengBeiContextData contextData = client.SceneContextData as HuanYingSiYuanShengBeiContextData;

            if (null != contextData)
            {
                lock (Mutex)
                {
                    HuanYingSiYuanScene huanYingSiYuanScene;
                    if (HuanYingSiYuanSceneDict.TryGetValue(contextData.FuBenSeqId, out huanYingSiYuanScene))
                    {
                        if (huanYingSiYuanScene.ShengBeiContextDict.ContainsKey(contextData.UniqueId))
                        {
                            return(StdErrorCode.Error_Has_Ownen_ShengBei);
                        }
                    }
                }
            }

            contextData = monster.Tag as HuanYingSiYuanShengBeiContextData;
            if (contextData != null)
            {
                return(contextData.Time);
            }

            return(StdErrorCode.Error_Other_Has_Get);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 刷怪
        /// </summary>
        public void CreateMonster(HuanYingSiYuanScene scene, HuanYingSiYuanShengBeiContextData contextData = null)
        {
            int gridX = contextData.PosX / RuntimeData.MapGridWidth;
            int gridY = contextData.PosY / RuntimeData.MapGridHeight;

            GameManager.MonsterZoneMgr.AddDynamicMonsters(RuntimeData.MapCode, contextData.MonsterId, contextData.CopyMapID, 1, gridX, gridY, 0, 0, SceneUIClasses.HuanYingSiYuan, contextData);
        }
Exemplo n.º 4
0
 private void TryLostShengBei(GameClient client)
 {
     lock (Mutex)
     {
         HuanYingSiYuanScene huanYingSiYuanScene = null;
         if (HuanYingSiYuanSceneDict.TryGetValue(client.ClientData.FuBenSeqID, out huanYingSiYuanScene))
         {
             HuanYingSiYuanShengBeiContextData contextData = LostShengBei(client);
             if (null != contextData)
             {
                 contextData.OwnerRoleId = 0;
                 huanYingSiYuanScene.ShengBeiContextDict.Remove(contextData.UniqueId);
                 CreateMonster(huanYingSiYuanScene, contextData);
             }
         }
     }
 }
Exemplo n.º 5
0
        public void OnCaiJiFinish(GameClient client, Monster monster)
        {
            HuanYingSiYuanShengBeiContextData contextData = monster.Tag as HuanYingSiYuanShengBeiContextData;
            HuanYingSiYuanScene huanYingSiYuanScene       = null;
            CopyMap             copyMap = null;

            if (null != contextData)
            {
                long endTicks = TimeUtil.NOW() + RuntimeData.HoldShengBeiSecs * TimeUtil.SECOND;
                lock (Mutex)
                {
                    contextData.OwnerRoleId = client.ClientData.RoleID;
                    contextData.EndTicks    = endTicks;
                    if (HuanYingSiYuanSceneDict.TryGetValue(contextData.FuBenSeqId, out huanYingSiYuanScene))
                    {
                        if (huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                        {
                            GetShengBei(huanYingSiYuanScene, client, contextData);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void SubmitShengBei(GameClient client)
        {
            if (null == client.SceneContextData)
            {
                return;
            }

            HuanYingSiYuanShengBeiContextData contextData = client.SceneContextData as HuanYingSiYuanShengBeiContextData;

            if (null == contextData)
            {
                return;
            }

            //为了放止外挂加速移动导致游戏不平衡并影响产出量,这里限制提交时间不能少于13秒(正常采集后提交大约需要15秒)
            long nowTicks = TimeUtil.NOW();

            if (contextData.EndTicks - nowTicks > (RuntimeData.HoldShengBeiSecs - RuntimeData.MinSubmitShengBeiSecs) * TimeUtil.SECOND)
            {
                return;
            }

            Point clientPoint = new Point(client.ClientData.PosX, client.ClientData.PosY);

            lock (RuntimeData.Mutex)
            {
                HuanYingSiYuanBirthPoint huanYingSiYuanBirthPoint;
                if (!RuntimeData.MapBirthPointDict.TryGetValue(client.ClientData.BattleWhichSide, out huanYingSiYuanBirthPoint))
                {
                    return;
                }

                Point targetPoint = new Point(huanYingSiYuanBirthPoint.PosX, huanYingSiYuanBirthPoint.PosY);
                if (Global.GetTwoPointDistance(clientPoint, targetPoint) > 1000)
                {
                    return;
                }
            }

            CopyMap copyMap = null;

            lock (Mutex)
            {
                HuanYingSiYuanScene huanYingSiYuanScene;
                if (HuanYingSiYuanSceneDict.TryGetValue(client.ClientData.FuBenSeqID, out huanYingSiYuanScene) && huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                {
                    if (huanYingSiYuanScene.ShengBeiContextDict.Remove(contextData.UniqueId))
                    {
                        LostShengBei(client);
                        CreateMonster(huanYingSiYuanScene, contextData);
                        contextData.OwnerRoleId = 0;

                        if (client.ClientData.BattleWhichSide == 1)
                        {
                            huanYingSiYuanScene.ScoreInfoData.Score1 += contextData.Score;
                            if (huanYingSiYuanScene.ScoreInfoData.Score1 >= RuntimeData.TempleMirageWin)
                            {
                                CompleteHuanYingSiYuanScene(huanYingSiYuanScene, 1);
                            }
                        }
                        else
                        {
                            huanYingSiYuanScene.ScoreInfoData.Score2 += contextData.Score;
                            if (huanYingSiYuanScene.ScoreInfoData.Score2 >= RuntimeData.TempleMirageWin)
                            {
                                CompleteHuanYingSiYuanScene(huanYingSiYuanScene, 2);
                            }
                        }

                        HuanYingSiYuanLianShaContextData clientLianShaContextData = client.SceneContextData2 as HuanYingSiYuanLianShaContextData;
                        if (null != clientLianShaContextData)
                        {
                            clientLianShaContextData.TotalScore += contextData.Score;
                        }

                        HuanYingSiYuanAddScore huanYingSiYuanAddScore = new HuanYingSiYuanAddScore();
                        huanYingSiYuanAddScore.Name       = Global.FormatRoleName4(client);
                        huanYingSiYuanAddScore.ZoneID     = client.ClientData.ZoneID;
                        huanYingSiYuanAddScore.Side       = client.ClientData.BattleWhichSide;
                        huanYingSiYuanAddScore.Score      = contextData.Score;
                        huanYingSiYuanAddScore.RoleId     = client.ClientData.RoleID;
                        huanYingSiYuanAddScore.Occupation = client.ClientData.Occupation;
                        copyMap = huanYingSiYuanScene.CopyMap;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_HYSY_ADD_SCORE, huanYingSiYuanAddScore, copyMap);
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_HYSY_SCORE_INFO, huanYingSiYuanScene.ScoreInfoData, copyMap);
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void GetShengBei(HuanYingSiYuanScene huanYingSiYuanScene, GameClient client, HuanYingSiYuanShengBeiContextData contextData)
        {
            if (null != contextData)
            {
                lock (Mutex)
                {
                    client.SceneContextData = contextData;
                    huanYingSiYuanScene.ShengBeiContextDict[contextData.UniqueId] = contextData;

                    //设置拥有者的buffer
                    client.ClientData.PropsCacheManager.SetExtProps(PropsSystemTypes.HysyShengBei, contextData.BufferProps);
                    double[] actionParams = new double[2] {
                        contextData.BufferGoodsId, RuntimeData.HoldShengBeiSecs
                    };
                    Global.UpdateBufferData(client, BufferItemTypes.HysyShengBei, actionParams);
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 心跳处理
        /// </summary>
        public void TimerProc()
        {
            long nowTicks = TimeUtil.NOW();

            if (nowTicks < NextHeartBeatTicks)
            {
                return;
            }

            NextHeartBeatTicks = nowTicks + 1020; //1020毫秒执行一次

            foreach (var huanYingSiYuanScene in HuanYingSiYuanSceneDict.Values)
            {
                lock (Mutex)
                {
                    int nID = -1;
                    nID = huanYingSiYuanScene.FuBenSeqId;

                    int nCopyID = -1;
                    nCopyID = huanYingSiYuanScene.CopyMapId;

                    int nMapCodeID = -1;
                    nMapCodeID = huanYingSiYuanScene.m_nMapCode;

                    if (nID < 0 || nCopyID < 0 || nMapCodeID < 0)
                    {
                        continue;
                    }

                    CopyMap copyMap = huanYingSiYuanScene.CopyMap;

                    // 当前tick
                    DateTime now   = TimeUtil.NowDateTime();
                    long     ticks = TimeUtil.NOW();

                    if (huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_NULL)             // 如果处于空状态 -- 是否要切换到准备状态
                    {
                        huanYingSiYuanScene.m_lPrepareTime = ticks;
                        huanYingSiYuanScene.m_lBeginTime   = ticks + RuntimeData.PrepareSecs * TimeUtil.SECOND;
                        huanYingSiYuanScene.m_eStatus      = GameSceneStatuses.STATUS_PREPARE;

                        huanYingSiYuanScene.StateTimeData.GameType = (int)GameTypes.HuanYingSiYuan;
                        huanYingSiYuanScene.StateTimeData.State    = (int)huanYingSiYuanScene.m_eStatus;
                        huanYingSiYuanScene.StateTimeData.EndTicks = huanYingSiYuanScene.m_lBeginTime;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, huanYingSiYuanScene.StateTimeData, huanYingSiYuanScene.CopyMap);
                    }
                    else if (huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_PREPARE)     // 场景战斗状态切换
                    {
                        if (ticks >= (huanYingSiYuanScene.m_lBeginTime))
                        {
                            huanYingSiYuanScene.m_eStatus  = GameSceneStatuses.STATUS_BEGIN;
                            huanYingSiYuanScene.m_lEndTime = ticks + RuntimeData.FightingSecs * TimeUtil.SECOND;

                            huanYingSiYuanScene.StateTimeData.GameType = (int)GameTypes.HuanYingSiYuan;
                            huanYingSiYuanScene.StateTimeData.State    = (int)huanYingSiYuanScene.m_eStatus;
                            huanYingSiYuanScene.StateTimeData.EndTicks = huanYingSiYuanScene.m_lEndTime;
                            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, huanYingSiYuanScene.StateTimeData, huanYingSiYuanScene.CopyMap);

                            //刷圣杯
                            foreach (var shengBeiData in RuntimeData.ShengBeiDataDict.Values)
                            {
                                HuanYingSiYuanShengBeiContextData contextData = new HuanYingSiYuanShengBeiContextData()
                                {
                                    UniqueId      = GetInternalId(),
                                    FuBenSeqId    = huanYingSiYuanScene.FuBenSeqId,
                                    ShengBeiId    = shengBeiData.ID,
                                    BufferGoodsId = shengBeiData.GoodsID,
                                    MonsterId     = shengBeiData.MonsterID,
                                    PosX          = shengBeiData.PosX,
                                    PosY          = shengBeiData.PosY,
                                    CopyMapID     = huanYingSiYuanScene.CopyMapId,
                                    Score         = shengBeiData.Score,
                                    Time          = shengBeiData.Time,
                                    BufferProps   = shengBeiData.BufferProps,
                                };

                                CreateMonster(huanYingSiYuanScene, contextData);
                            }

                            //放开光幕
                            copyMap.AddGuangMuEvent(1, 0);
                            GameManager.ClientMgr.BroadSpecialMapAIEvent(copyMap.MapCode, copyMap.CopyMapID, 1, 0);
                        }
                    }
                    else if (huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)       // 战斗开始
                    {
                        if (ticks >= huanYingSiYuanScene.m_lEndTime)
                        {
                            int successSide = 0;
                            if (huanYingSiYuanScene.ScoreInfoData.Score1 > huanYingSiYuanScene.ScoreInfoData.Score2)
                            {
                                successSide = 1;
                            }
                            else if (huanYingSiYuanScene.ScoreInfoData.Score2 > huanYingSiYuanScene.ScoreInfoData.Score1)
                            {
                                successSide = 2;
                            }

                            CompleteHuanYingSiYuanScene(huanYingSiYuanScene, successSide);
                        }
                        else
                        {
                            CheckShengBeiBufferTime(huanYingSiYuanScene, nowTicks);
                        }
                    }
                    else if (huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_END)
                    {
                        //结算奖励
                        huanYingSiYuanScene.m_eStatus    = GameSceneStatuses.STATUS_AWARD;
                        huanYingSiYuanScene.m_lEndTime   = nowTicks;
                        huanYingSiYuanScene.m_lLeaveTime = huanYingSiYuanScene.m_lEndTime + RuntimeData.ClearRolesSecs * TimeUtil.SECOND;

                        HuanYingSiYuanClient.getInstance().GameFuBenChangeState(huanYingSiYuanScene.GameId, GameFuBenState.End, now);

                        huanYingSiYuanScene.StateTimeData.GameType = (int)GameTypes.HuanYingSiYuan;
                        huanYingSiYuanScene.StateTimeData.State    = (int)GameSceneStatuses.STATUS_END;
                        huanYingSiYuanScene.StateTimeData.EndTicks = huanYingSiYuanScene.m_lLeaveTime;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, huanYingSiYuanScene.StateTimeData, huanYingSiYuanScene.CopyMap);

                        GiveAwards(huanYingSiYuanScene);
                    }
                    else if (huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_AWARD)         // 战斗结束
                    {
                        if (ticks >= huanYingSiYuanScene.m_lLeaveTime)
                        {
                            copyMap.SetRemoveTicks(huanYingSiYuanScene.m_lLeaveTime);
                            huanYingSiYuanScene.m_eStatus = GameSceneStatuses.STATUS_CLEAR;

                            try
                            {
                                List <GameClient> objsList = copyMap.GetClientsList();
                                if (objsList != null && objsList.Count > 0)
                                {
                                    for (int n = 0; n < objsList.Count; ++n)
                                    {
                                        GameClient c = objsList[n];
                                        if (c != null)
                                        {
                                            KuaFuManager.getInstance().GotoLastMap(c);
                                        }
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                DataHelper.WriteExceptionLogEx(ex, "幻影寺院清场调度异常");
                            }
                        }
                    }
                }
            }

            return;
        }