예제 #1
0
        private bool CheckSceneCenterState(KarenBattleScene karenBattleScene, KarenCenterConfig center, long nowTicks)
        {
            List <object> enemiesObjList = new List <object>();

            GameManager.ClientMgr.LookupEnemiesInCircle(karenBattleScene.m_nMapCode, karenBattleScene.CopyMapId, center.PosX, center.PosY, center.Radius, enemiesObjList);
            Dictionary <int, GameClient> OwnerSideDict = new Dictionary <int, GameClient>();
            int newBattleSide = 0;

            foreach (object item in enemiesObjList)
            {
                GameClient client = item as GameClient;
                if (client.ClientData.CurrentLifeV > 0)
                {
                    OwnerSideDict[client.ClientData.BattleWhichSide] = client;
                }
            }
            if (OwnerSideDict.Count == 1)
            {
                newBattleSide = OwnerSideDict.Keys.FirstOrDefault <int>();
            }
            bool result;

            if (newBattleSide == 0 || newBattleSide == center.BattleWhichSide)
            {
                center.OwnCalculateSide  = 0L;
                center.OwnCalculateTicks = 0L;
                result = false;
            }
            else if (center.OwnCalculateSide != (long)newBattleSide)
            {
                center.OwnCalculateSide  = (long)newBattleSide;
                center.OwnCalculateTicks = nowTicks;
                result = false;
            }
            else if (nowTicks - center.OwnCalculateTicks >= (long)(center.OccupyTime * 1000))
            {
                if (center.BattleWhichSide != 0)
                {
                    karenBattleScene.ScoreData[center.BattleWhichSide - 1].ResourceList.Remove(center.ID);
                }
                center.OwnTicksDelta   = 0L;
                center.OwnTicks        = nowTicks;
                center.BattleWhichSide = newBattleSide;
                karenBattleScene.ScoreData[center.BattleWhichSide - 1].ResourceList.Add(center.ID);
                GameClient    client    = OwnerSideDict.Values.FirstOrDefault <GameClient>();
                SystemXmlItem systemNPC = null;
                if (GameManager.SystemNPCsMgr.SystemXmlItemDict.TryGetValue(center.NPCID, out systemNPC))
                {
                    string param  = systemNPC.GetStringValue("SName");
                    string param2 = client.ClientData.JunTuanName;
                    KarenBattleManager.getInstance().NtfKarenNotifyMsg(karenBattleScene, KarenNotifyMsgType.Own, client.ClientData.JunTuanId, param, param2);
                }
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
예제 #2
0
 private void CheckSceneScoreTime(KarenBattleScene karenBattleScene, long nowTicks)
 {
     lock (this.RuntimeData.Mutex)
     {
         bool NotifyScoreData = false;
         foreach (KeyValuePair <int, KarenCenterConfig> item in karenBattleScene.KarenCenterConfigDict)
         {
             KarenCenterConfig center = item.Value;
             NotifyScoreData |= this.CheckSceneCenterState(karenBattleScene, center, nowTicks);
             if (center.BattleWhichSide != 0)
             {
                 center.OwnTicksDelta += nowTicks - center.OwnTicks;
                 center.OwnTicks       = nowTicks;
                 if (center.OwnTicksDelta >= (long)(center.ProduceTime * 1000) && center.ProduceTime > 0)
                 {
                     int calRate = (int)(center.OwnTicksDelta / (long)(center.ProduceTime * 1000));
                     center.OwnTicksDelta -= (long)(calRate * center.ProduceTime * 1000);
                     karenBattleScene.ScoreData[center.BattleWhichSide - 1].Score += calRate * center.ProduceNum;
                     karenBattleScene.ScoreData[center.BattleWhichSide - 1].ticks  = nowTicks;
                     NotifyScoreData = true;
                 }
             }
         }
         if (NotifyScoreData)
         {
             this.BroadcastSceneScoreInfo(karenBattleScene);
         }
     }
 }
예제 #3
0
        public void SubmitCrystalBuff(GameClient client, int areaLuaID)
        {
            KarenBattleQiZhiConfig_East crystalItem = client.SceneContextData as KarenBattleQiZhiConfig_East;

            if (null != crystalItem)
            {
                lock (this.RuntimeData.Mutex)
                {
                    KarenBattleScene scene;
                    if (this.SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene))
                    {
                        KarenCenterConfig center = null;
                        if (scene.KarenCenterConfigDict.TryGetValue(areaLuaID, out center))
                        {
                            if (center.BattleWhichSide == client.ClientData.BattleWhichSide)
                            {
                                KarenBattleClientContextData contextData = client.SceneContextData2 as KarenBattleClientContextData;
                                if (contextData != null && scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                                {
                                    int addScore = crystalItem.HandInNum;
                                    scene.ScoreData[client.ClientData.BattleWhichSide - 1].Score += addScore;
                                    scene.ScoreData[client.ClientData.BattleWhichSide - 1].ticks  = TimeUtil.NOW();
                                    if (addScore > 0)
                                    {
                                        this.NotifyTimeStateInfoAndScoreInfo(client, false, true);
                                    }
                                }
                                SystemXmlItem systemNPC = null;
                                if (GameManager.SystemNPCsMgr.SystemXmlItemDict.TryGetValue(center.NPCID, out systemNPC))
                                {
                                    string param  = client.ClientData.JunTuanName;
                                    string param2 = systemNPC.GetStringValue("SName");
                                    KarenBattleManager.getInstance().NtfKarenNotifyMsg(scene, KarenNotifyMsgType.Submit, client.ClientData.JunTuanId, param, param2);
                                }
                                this.UpdateBuff4GameClient(client, crystalItem.BuffGoodsID, crystalItem, false);
                                this.AddDelayCreateMonster(scene, TimeUtil.NOW() + (long)(crystalItem.RefreshCD * 1000), crystalItem);
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
        public bool InitConfig()
        {
            bool   success  = true;
            string fileName = "";

            lock (this.RuntimeData.Mutex)
            {
                try
                {
                    this.RuntimeData.MapBirthPointDict.Clear();
                    fileName = "Config/LegionsEastBirthPoint.xml";
                    string   fullPathFileName = Global.GameResPath(fileName);
                    XElement xml = XElement.Load(fullPathFileName);
                    IEnumerable <XElement> nodes = xml.Elements();
                    foreach (XElement node in nodes)
                    {
                        KarenBattleBirthPoint item = new KarenBattleBirthPoint();
                        item.ID          = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.PosX        = (int)Global.GetSafeAttributeLong(node, "PosX");
                        item.PosY        = (int)Global.GetSafeAttributeLong(node, "PosY");
                        item.BirthRadius = (int)Global.GetSafeAttributeLong(node, "BirthRadius");
                        this.RuntimeData.MapBirthPointDict[item.ID] = item;
                    }
                    this.RuntimeData.KarenCenterConfigDict.Clear();
                    fileName         = "Config/LegionsEast.xml";
                    fullPathFileName = Global.GameResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (XElement node in nodes)
                    {
                        KarenCenterConfig item2 = new KarenCenterConfig();
                        item2.ID    = (int)Global.GetSafeAttributeLong(node, "ID");
                        item2.NPCID = (int)Global.GetSafeAttributeLong(node, "NPCID");
                        string   SiteString = Global.GetSafeAttributeStr(node, "NPCSite");
                        string[] SiteFields = SiteString.Split(new char[]
                        {
                            '|'
                        });
                        if (3 == SiteFields.Length)
                        {
                            item2.PosX   = Global.SafeConvertToInt32(SiteFields[0]);
                            item2.PosY   = Global.SafeConvertToInt32(SiteFields[1]);
                            item2.Radius = Global.SafeConvertToInt32(SiteFields[2]);
                        }
                        item2.ProduceTime = (int)Global.GetSafeAttributeLong(node, "ProduceTime");
                        item2.ProduceNum  = (int)Global.GetSafeAttributeLong(node, "ProduceNum");
                        item2.OccupyTime  = (int)Global.GetSafeAttributeLong(node, "OccupyTime");
                        this.RuntimeData.KarenCenterConfigDict[item2.ID] = item2;
                    }
                    this.RuntimeData.NPCID2QiZhiConfigDict.Clear();
                    fileName         = "Config/LegionsEastFlag.xml";
                    fullPathFileName = Global.GameResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (XElement node in nodes)
                    {
                        KarenBattleQiZhiConfig_East item3 = new KarenBattleQiZhiConfig_East();
                        item3.ID        = (int)Global.GetSafeAttributeLong(node, "ID");
                        item3.MonsterID = (int)Global.GetSafeAttributeLong(node, "MonsterID");
                        string   SiteString = Global.GetSafeAttributeStr(node, "Site");
                        string[] SiteFields = SiteString.Split(new char[]
                        {
                            '|'
                        });
                        if (2 == SiteFields.Length)
                        {
                            item3.PosX = Global.SafeConvertToInt32(SiteFields[0]);
                            item3.PosY = Global.SafeConvertToInt32(SiteFields[1]);
                        }
                        item3.BeginTime   = (int)Global.GetSafeAttributeLong(node, "BeginTime");
                        item3.RefreshCD   = (int)Global.GetSafeAttributeLong(node, "RefreshCD");
                        item3.CollectTime = (int)Global.GetSafeAttributeLong(node, "CollectTime");
                        item3.HandInNum   = (int)Global.GetSafeAttributeLong(node, "HandInNum");
                        item3.HoldTme     = (int)Global.GetSafeAttributeLong(node, "HoldTme");
                        item3.BuffGoodsID = (int)Global.GetSafeAttributeLong(node, "Icon");
                        this.RuntimeData.NPCID2QiZhiConfigDict[item3.MonsterID] = item3;
                    }
                }
                catch (Exception ex)
                {
                    success = false;
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex, true);
                }
            }
            return(success);
        }