コード例 #1
0
        public void processEvent(EventObjectEx eventObject)
        {
            int eventType = eventObject.EventType;
            int num       = eventType;

            if (num != 27)
            {
                if (num != 30)
                {
                    if (num == 33)
                    {
                        PreMonsterInjureEventObject obj = eventObject as PreMonsterInjureEventObject;
                        if (obj != null && obj.SceneType == 41)
                        {
                            Monster injureMonster = obj.Monster;
                            if (injureMonster != null)
                            {
                                if (this.IsQiZhiExtensionID(injureMonster.MonsterInfo.ExtensionID))
                                {
                                    this.RuntimeData.KarenBattleDamage.TryGetValue(injureMonster.MonsterInfo.ExtensionID, out obj.Injure);
                                    eventObject.Handled = true;
                                    eventObject.Result  = true;
                                }
                            }
                        }
                    }
                }
                else
                {
                    OnCreateMonsterEventObject e = eventObject as OnCreateMonsterEventObject;
                    if (null != e)
                    {
                        KarenBattleQiZhiConfig_West qiZhiConfig = e.Monster.Tag as KarenBattleQiZhiConfig_West;
                        if (null != qiZhiConfig)
                        {
                            e.Monster.Camp = qiZhiConfig.BattleWhichSide;
                            e.Result       = true;
                            e.Handled      = true;
                        }
                    }
                }
            }
            else
            {
                ProcessClickOnNpcEventObject e2 = eventObject as ProcessClickOnNpcEventObject;
                if (null != e2)
                {
                    if (null != e2.Npc)
                    {
                        int npcId = e2.Npc.NpcID;
                    }
                    if (this.OnSpriteClickOnNpc(e2.Client, e2.NpcId, e2.ExtensionID))
                    {
                        e2.Result  = false;
                        e2.Handled = true;
                    }
                }
            }
        }
コード例 #2
0
        public bool OnSpriteClickOnNpc(GameClient client, int npcID, int npcExtentionID)
        {
            KarenBattleQiZhiConfig_West item = null;
            bool             isQiZuo         = false;
            bool             installJunQi    = false;
            KarenBattleScene scene           = client.SceneObject as KarenBattleScene;
            bool             result;

            if (null == scene)
            {
                result = isQiZuo;
            }
            else
            {
                lock (this.RuntimeData.Mutex)
                {
                    if (scene.NPCID2QiZhiConfigDict.TryGetValue(npcExtentionID, out item))
                    {
                        isQiZuo = true;
                        if (item.Alive)
                        {
                            return(isQiZuo);
                        }
                        if (client.ClientData.BattleWhichSide == item.BattleWhichSide || Math.Abs(TimeUtil.NOW() - item.DeadTicks) >= 5000L)
                        {
                            if (scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                            {
                                if (Math.Abs(client.ClientData.PosX - item.PosX) <= 1000 && Math.Abs(client.ClientData.PosY - item.PosY) <= 1000)
                                {
                                    installJunQi = true;
                                }
                            }
                        }
                    }
                    if (installJunQi)
                    {
                        this.InstallJunQi(scene, client, item);
                    }
                }
                result = isQiZuo;
            }
            return(result);
        }
コード例 #3
0
 public void OnProcessMonsterDead(GameClient client, Monster monster)
 {
     if (client != null && this.IsQiZhiExtensionID(monster.MonsterInfo.ExtensionID))
     {
         KarenBattleScene            scene       = client.SceneObject as KarenBattleScene;
         KarenBattleQiZhiConfig_West qizhiConfig = monster.Tag as KarenBattleQiZhiConfig_West;
         if (scene != null && null != qizhiConfig)
         {
             lock (this.RuntimeData.Mutex)
             {
                 scene.ScoreData[qizhiConfig.BattleWhichSide - 1].ResourceList.Remove(qizhiConfig.ID);
                 qizhiConfig.DeadTicks       = TimeUtil.NOW();
                 qizhiConfig.Alive           = false;
                 qizhiConfig.BattleWhichSide = client.ClientData.BattleWhichSide;
                 qizhiConfig.OwnTicks        = 0L;
                 qizhiConfig.OwnTicksDelta   = 0L;
                 this.BroadcastSceneScoreInfo(scene);
             }
         }
     }
 }
コード例 #4
0
        public void InstallJunQi(KarenBattleScene scene, GameClient client, KarenBattleQiZhiConfig_West item)
        {
            CopyMap copyMap = scene.CopyMap;
            GameMap gameMap = GameManager.MapMgr.GetGameMap(scene.m_nMapCode);

            if (copyMap != null && null != gameMap)
            {
                item.Alive           = true;
                item.BattleWhichSide = client.ClientData.BattleWhichSide;
                item.OwnTicks        = TimeUtil.NOW();
                scene.ScoreData[item.BattleWhichSide - 1].ResourceList.Add(item.ID);
                GameManager.MonsterZoneMgr.AddDynamicMonsters(copyMap.MapCode, item.QiZhiID, copyMap.CopyMapID, 1, item.PosX / gameMap.MapGridWidth, item.PosY / gameMap.MapGridHeight, 0, 0, SceneUIClasses.KarenWest, item, null);
                SystemXmlItem systemNPC = null;
                if (GameManager.SystemNPCsMgr.SystemXmlItemDict.TryGetValue(item.QiZuoID, out systemNPC))
                {
                    string param  = systemNPC.GetStringValue("SName");
                    string param2 = client.ClientData.JunTuanName;
                    KarenBattleManager.getInstance().NtfKarenNotifyMsg(scene, KarenNotifyMsgType.Own, client.ClientData.JunTuanId, param, param2);
                }
                this.BroadcastSceneScoreInfo(scene);
            }
        }
コード例 #5
0
 private void CheckSceneScoreTime(KarenBattleScene karenBattleScene, long nowTicks)
 {
     lock (this.RuntimeData.Mutex)
     {
         bool NotifyScoreData = false;
         foreach (KeyValuePair <int, KarenBattleQiZhiConfig_West> item in karenBattleScene.NPCID2QiZhiConfigDict)
         {
             KarenBattleQiZhiConfig_West qizhi = item.Value;
             if (qizhi.BattleWhichSide != 0 && qizhi.Alive)
             {
                 qizhi.OwnTicksDelta += nowTicks - qizhi.OwnTicks;
                 qizhi.OwnTicks       = nowTicks;
                 if (qizhi.OwnTicksDelta >= (long)(qizhi.ProduceTime * 1000) && qizhi.ProduceTime > 0)
                 {
                     int calRate = (int)(qizhi.OwnTicksDelta / (long)(qizhi.ProduceTime * 1000));
                     qizhi.OwnTicksDelta -= (long)(calRate * qizhi.ProduceTime * 1000);
                     karenBattleScene.ScoreData[qizhi.BattleWhichSide - 1].Score += calRate * qizhi.ProduceNum;
                     karenBattleScene.ScoreData[qizhi.BattleWhichSide - 1].ticks  = nowTicks;
                     NotifyScoreData = true;
                 }
             }
         }
         if (NotifyScoreData)
         {
             List <GameClient> objsList = karenBattleScene.CopyMap.GetClientsList();
             if (objsList != null && objsList.Count > 0)
             {
                 for (int i = 0; i < objsList.Count; i++)
                 {
                     GameClient c = objsList[i];
                     if (c != null && c.ClientData.CopyMapID == karenBattleScene.CopyMap.CopyMapID)
                     {
                         this.NotifyTimeStateInfoAndScoreInfo(c, false, true);
                     }
                 }
             }
         }
     }
 }
コード例 #6
0
        public bool InitConfig()
        {
            bool   success  = true;
            string fileName = "";

            lock (this.RuntimeData.Mutex)
            {
                try
                {
                    this.RuntimeData.MapBirthPointDict.Clear();
                    fileName = "Config/LegionsWestBirthPoint.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.KarenBattleDamage.Clear();
                    List <string> damageList = GameManager.systemParamsList.GetParamValueStringListByName("LegionsWest", '|');
                    if (null != damageList)
                    {
                        foreach (string item2 in damageList)
                        {
                            string[] intArray = item2.Split(new char[]
                            {
                                ','
                            });
                            int key   = Global.SafeConvertToInt32(intArray[0]);
                            int value = Global.SafeConvertToInt32(intArray[1]);
                            this.RuntimeData.KarenBattleDamage[key] = value;
                        }
                    }
                    this.RuntimeData.NPCID2QiZhiConfigDict.Clear();
                    fileName         = "Config/LegionsWest.xml";
                    fullPathFileName = Global.GameResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (XElement node in nodes)
                    {
                        KarenBattleQiZhiConfig_West item3 = new KarenBattleQiZhiConfig_West();
                        item3.ID      = (int)Global.GetSafeAttributeLong(node, "ID");
                        item3.QiZhiID = (int)Global.GetSafeAttributeLong(node, "QiZhiID");
                        item3.QiZuoID = (int)Global.GetSafeAttributeLong(node, "QiZuoID");
                        string   SiteString = Global.GetSafeAttributeStr(node, "QiZuoSite");
                        string[] SiteFields = SiteString.Split(new char[]
                        {
                            '|'
                        });
                        if (2 == SiteFields.Length)
                        {
                            item3.PosX = Global.SafeConvertToInt32(SiteFields[0]);
                            item3.PosY = Global.SafeConvertToInt32(SiteFields[1]);
                        }
                        SiteString = Global.GetSafeAttributeStr(node, "RebirthSite");
                        SiteFields = SiteString.Split(new char[]
                        {
                            '|'
                        });
                        if (2 == SiteFields.Length)
                        {
                            item3.BirthX = Global.SafeConvertToInt32(SiteFields[0]);
                            item3.BirthY = Global.SafeConvertToInt32(SiteFields[1]);
                        }
                        item3.BirthRadius = (int)Global.GetSafeAttributeLong(node, "RebirthRadius");
                        item3.ProduceTime = (int)Global.GetSafeAttributeLong(node, "ProduceTime");
                        item3.ProduceNum  = (int)Global.GetSafeAttributeLong(node, "ProduceNum");
                        this.RuntimeData.NPCID2QiZhiConfigDict[item3.QiZuoID] = item3;
                    }
                }
                catch (Exception ex)
                {
                    success = false;
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex, true);
                }
            }
            return(success);
        }