Пример #1
0
        public int GetBirthPoint(GameClient client, out int posX, out int posY, bool isLogin = false)
        {
            posX = 0;
            posY = 0;
            double distance = 0.0;
            int    side     = client.ClientData.BattleWhichSide;

            lock (this.RuntimeData.Mutex)
            {
                KarenBattleBirthPoint birthPoint = null;
                if (!this.RuntimeData.MapBirthPointDict.TryGetValue(side, out birthPoint))
                {
                    return(-1);
                }
                posX     = birthPoint.PosX;
                posY     = birthPoint.PosY;
                distance = Global.GetTwoPointDistance(new Point((double)posX, (double)posY), new Point((double)client.ClientData.PosX, (double)client.ClientData.PosY));
            }
            int result;

            if (isLogin)
            {
                result = side;
            }
            else
            {
                KarenBattleScene scene = null;
                if (this.SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene))
                {
                    foreach (KeyValuePair <int, KarenBattleQiZhiConfig_West> item in scene.NPCID2QiZhiConfigDict)
                    {
                        if (item.Value.BattleWhichSide == side)
                        {
                            double tempdis = Global.GetTwoPointDistance(new Point((double)item.Value.BirthX, (double)item.Value.BirthY), new Point((double)client.ClientData.PosX, (double)client.ClientData.PosY));
                            if (tempdis < distance)
                            {
                                distance = tempdis;
                                Point BirthPoint = Global.GetMapPointByGridXY(ObjectTypes.OT_CLIENT, client.ClientData.MapCode, item.Value.BirthX / scene.MapGridWidth, item.Value.BirthY / scene.MapGridHeight, item.Value.BirthRadius / scene.MapGridWidth, 0, false);
                                posX = (int)BirthPoint.X;
                                posY = (int)BirthPoint.Y;
                            }
                        }
                    }
                }
                result = side;
            }
            return(result);
        }
Пример #2
0
        public int GetBirthPoint(GameClient client, out int posX, out int posY)
        {
            posX = 0;
            posY = 0;
            int side = client.ClientData.BattleWhichSide;

            lock (this.RuntimeData.Mutex)
            {
                KarenBattleBirthPoint birthPoint = null;
                if (!this.RuntimeData.MapBirthPointDict.TryGetValue(side, out birthPoint))
                {
                    return(-1);
                }
                posX = birthPoint.PosX;
                posY = birthPoint.PosY;
                double distance = Global.GetTwoPointDistance(new Point((double)posX, (double)posY), new Point((double)client.ClientData.PosX, (double)client.ClientData.PosY));
            }
            return(side);
        }
Пример #3
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);
        }
Пример #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);
        }