Esempio n. 1
0
 public static void Register(string type, EMapNodeType eNodeType, EMapJudgeType eJudgeType, bool bWalkType)
 {
     MapCfg.s_oDicNodeType.Add(type, eNodeType);
     MapCfg.s_oDicJudegeType.Add(type, eJudgeType);
     MapCfg.s_oDicWalkType.Add(type, bWalkType);
     MapCfg.s_oDicMapNodeType2String.Add(eNodeType, type);
 }
Esempio n. 2
0
 /// <summary>
 /// 根据node类型找出地图上所有的node
 /// </summary>
 /// <param name="eMapNodeType"></param>
 /// <returns></returns>
 public List <CVector3> GetNodesByType(EMapNodeType eMapNodeType)
 {
     if (this.m_map == null)
     {
         return(null);
     }
     return(this.m_map.GetNodesByType(eMapNodeType));
 }
Esempio n. 3
0
 public MapNode()
 {
     this.nIndexX         = 0;
     this.nIndexY         = 0;
     this.nIndexU         = 0;
     this.m_eMapNodeType  = EMapNodeType.MAP_NODE_INVALID;
     this.m_eMapJudgeType = EMapJudgeType.MAP_JUDGE_INVALID;
     this.m_bCanWalk      = false;
 }
Esempio n. 4
0
 /// <summary>
 /// 更改地图格子类型,也要重新替换模型
 /// </summary>
 /// <param name="type"></param>
 public void ChangeNodeType(EMapNodeType type)
 {
     switch (type)
     {
     case EMapNodeType.MAP_NODE_ROCK:
         this.m_strModelFile = "Data/3D/Scene/EnergyTrap";
         this.ChangeModel();
         break;
     }
 }
Esempio n. 5
0
    public static string MapNodeType2String(EMapNodeType eMapNodeType)
    {
        string result = "";

        if (!MapCfg.s_oDicMapNodeType2String.TryGetValue(eMapNodeType, out result))
        {
            Debug.LogError("m_oDicMapNodeType2String.TryGetValue(eMapNodeType, out strMapNodeString) == false:" + eMapNodeType);
        }
        return(result);
    }
Esempio n. 6
0
 /// <summary>
 /// 显示所有格子模型
 /// </summary>
 /// <param name="eMapNodeType"></param>
 /// <param name="bVisible"></param>
 public void SetMapNodeBuildingVisible(EMapNodeType eMapNodeType, bool bVisible)
 {
     for (int i = 0; i < this.m_listMapNodeBuilding.Count; i++)
     {
         MapNodeBuilding mapNodeBuilding = this.m_listMapNodeBuilding[i];
         if (mapNodeBuilding.MapNodeType == eMapNodeType)
         {
             mapNodeBuilding.SetVisible(bVisible);
         }
     }
 }
Esempio n. 7
0
        /// <summary>
        /// 根据格子类型取得MapNodeBuilding类
        /// </summary>
        /// <param name="eMapNodeType"></param>
        /// <returns></returns>
        public MapNodeBuilding GetMapNodeBuildingByType(EMapNodeType eMapNodeType)
        {
            MapNodeBuilding result = null;

            foreach (var build in this.m_listMapNodeBuilding)
            {
                if (build.MapNodeType == eMapNodeType)
                {
                    result = build;
                }
            }
            return(result);
        }
Esempio n. 8
0
    /// <summary>
    /// 根据格子类型字符,返回格子类型
    /// </summary>
    /// <param name="strType"></param>
    /// <returns></returns>
    public static EMapNodeType String2MapNodeType(string strType)
    {
        if (string.IsNullOrEmpty(strType))
        {
            return(EMapNodeType.MAP_NODE_INVALID);
        }
        EMapNodeType result = EMapNodeType.MAP_NODE_INVALID;

        if (MapCfg.s_oDicNodeType.TryGetValue(strType, out result))
        {
            return(result);
        }
        return(EMapNodeType.MAP_NODE_INVALID);
    }
Esempio n. 9
0
    public List <CVector3> GetNodesByType(EMapNodeType eMapNodeType)
    {
        List <MapNode>  list  = this.m_oMapData.GetNodesByType(eMapNodeType);
        List <CVector3> list2 = new List <CVector3>();

        foreach (var item in list)
        {
            list2.Add(new CVector3
            {
                nRow = item.nRow,
                nCol = item.nCol
            });
        }
        return(list2);
    }
Esempio n. 10
0
    public List <MapNode> GetNodesByType(EMapNodeType eMapNodeType)
    {
        List <MapNode> list = new List <MapNode>();

        foreach (var current in this.m_dicMapData)
        {
            foreach (var current2 in current.Value)
            {
                MapNode value = current2.Value;
                if (value.m_eMapNodeType == eMapNodeType)
                {
                    list.Add(value);
                }
            }
        }
        return(list);
    }
Esempio n. 11
0
        /// <summary>
        /// 创建格子模型建筑
        /// </summary>
        /// <param name="scene"></param>
        public void CreateTerrainBuildings(CScene scene)
        {
            foreach (var XYAndNode in scene.DicMapData)
            {
                foreach (var YAndNode in XYAndNode.Value)
                {
                    MapNode         node            = YAndNode.Value;
                    MapNodeBuilding mapNodeBuilding = new MapNodeBuilding();
                    mapNodeBuilding.MapNodeType = node.m_eMapNodeType;
                    mapNodeBuilding.HexPos      = new CVector3(node.nIndexX, node.nIndexY, node.nIndexU);
                    //从服务器收到动态地图的消息,里面存储不同格子坐标上的不同建筑
                    if (this.m_ListNodeData != null)
                    {
                        for (int i = 0; i < this.m_ListNodeData.Count; i++)
                        {
                            if (mapNodeBuilding.HexPos.Equals(this.m_ListNodeData[i].m_oPos))
                            {
                                EMapNodeType eMapNodeType = (EMapNodeType)this.m_ListNodeData[i].m_nType;
                                mapNodeBuilding.MapNodeType = eMapNodeType;
                                mapNodeBuilding.ChangeNodeType(eMapNodeType);
                                this.m_sceneCurrent.ChangeMapNodeType(this.m_ListNodeData[i].m_oPos, MapCfg.MapNodeType2String(eMapNodeType));
                                break;
                            }
                        }
                    }

                    //DataTerrain_node dataByType = DataTerrain_nodeManager.Instance.GetDataByType(MapCfg.MapNodeType2String(node.m_eMapNodeType));
                    DataTerrainNode dataByType = GameData <DataTerrainNode> .dataMap[MapCfg.MapNodeTypeToInt(node.m_eMapNodeType)];
                    if (null != dataByType)
                    {
                        mapNodeBuilding.EffectId        = dataByType.EffectId;
                        mapNodeBuilding.TriggerEffectId = dataByType.TriggerEffectId;
                    }
                    //初始化基地模型
                    MapNodeTypeInfo mapNodeTypeInfo = null;
                    if (scene.DicMapNodeTypeInfo.TryGetValue(node.m_eMapNodeType, out mapNodeTypeInfo))
                    {
                        mapNodeBuilding.ModelFile       = mapNodeTypeInfo.ModelFile;
                        mapNodeBuilding.OriginModelFile = mapNodeTypeInfo.ModelFile;
                        mapNodeBuilding.ChangeModel();
                    }
                    this.m_listMapNodeBuilding.Add(mapNodeBuilding);
                }
            }
        }
Esempio n. 12
0
 public static int MapNodeTypeToInt(EMapNodeType eMapNodeType)
 {
     return((int)eMapNodeType);
 }
Esempio n. 13
0
 public MapNodeTypeInfo(EMapNodeType eMapNodeType, string strModelFile)
 {
     this.m_eMapNodeType = eMapNodeType;
     this.m_strModeFile  = strModelFile;
 }
Esempio n. 14
0
 private void OnLoadFinishEventHandler(XmlDocument xmlDoc)
 {
     try
     {
         XmlNode     xmlNode    = xmlDoc.SelectSingleNode("table");
         XmlNode     xmlNode2   = xmlNode.SelectSingleNode("map");
         XmlNodeList childNodes = xmlNode2.ChildNodes;
         foreach (XmlNode xmlNode3 in childNodes)
         {
             XmlElement xmlElement = (XmlElement)xmlNode3;
             MapNode    mapNode    = new MapNode();
             //初始化格子坐标
             mapNode.nIndexX   = Convert.ToInt32(xmlElement.GetAttribute("X"));
             mapNode.nIndexY   = Convert.ToInt32(xmlElement.GetAttribute("Y"));
             mapNode.nIndexU   = Convert.ToInt32(xmlElement.GetAttribute("U"));
             mapNode.m_strType = xmlElement.GetAttribute("type");
             //初始化格子类型
             if (!MapCfg.MapNodeTransfer(mapNode))
             {
                 Debug.LogError("m_oCfg.MapNodeTransfer(oNode) == false");
                 return;
             }
             if (this.m_dicMapData.ContainsKey(mapNode.nIndexX))
             {
                 //如果xy都已经存在缓存格子中,说明肯定出错了,重复初始化话,就报错
                 if (this.m_dicMapData[mapNode.nIndexX].ContainsKey(mapNode.nIndexY))
                 {
                     string message = string.Format("XY conflict x={0},y={1}", mapNode.nIndexX, mapNode.nIndexY);
                     this.logger.Error("m_oDicMapData[oNode.nIndexX].ContainsKey(oNode.nIndexY) == true,");
                     this.logger.Error(message);
                     return;
                 }
                 //如果没有重复,就加到缓存格子中
                 this.m_dicMapData[mapNode.nIndexX].Add(mapNode.nIndexY, mapNode);
             }
             else
             {
                 Dictionary <int, MapNode> dictionary = new Dictionary <int, MapNode>();
                 dictionary.Add(mapNode.nIndexY, mapNode);
                 this.m_dicMapData.Add(mapNode.nIndexX, dictionary);
             }
             //如果节点的类型是基地类型,初始化基地节点变量
             if (mapNode.m_eMapNodeType == EMapNodeType.MAP_NODE_EMPIRE_BASE)
             {
                 this.empireMapNode.m_nX = mapNode.nIndexX;
                 this.empireMapNode.m_nY = mapNode.nIndexY;
                 this.empireMapNode.m_nU = mapNode.nIndexU;
             }
             else
             {
                 if (mapNode.m_eMapNodeType == EMapNodeType.MAP_NODE_LEAGUE_BASE)
                 {
                     this.leagueMapNode.m_nX = mapNode.nIndexX;
                     this.leagueMapNode.m_nY = mapNode.nIndexY;
                     this.leagueMapNode.m_nU = mapNode.nIndexU;
                 }
             }
         }
         XmlNode xmlNode4 = xmlNode.SelectSingleNode("mapInfo");
         if (xmlNode4 != null)
         {
             XmlElement xmlElement2 = xmlNode4 as XmlElement;
             string     attribute   = xmlElement2.GetAttribute("pos");
             Vector3    vector      = UnityTools.String2Vector3(attribute);
             string     attribute2  = xmlElement2.GetAttribute("rotation");
             Vector3    vector2     = UnityTools.String2Vector3(attribute2);
             //初始化地图坐标和旋转方向
             this.InitPos      = vector;
             this.InitRotation = vector2;
             XmlNodeList xmlNodeList = xmlNode4.SelectNodes("nodeType");
             foreach (XmlNode xmlNode5 in xmlNodeList)
             {
                 try
                 {
                     XmlElement      xmlElement3     = (XmlElement)xmlNode5;
                     string          attribute3      = xmlElement3.GetAttribute("type");
                     EMapNodeType    eMapNodeType    = MapCfg.String2MapNodeType(attribute3);
                     string          attribute4      = xmlElement3.GetAttribute("file");
                     MapNodeTypeInfo mapNodeTypeInfo = new MapNodeTypeInfo(eMapNodeType, attribute4);
                     string          attribute5      = xmlElement3.GetAttribute("localPos");
                     if (!string.IsNullOrEmpty(attribute5))
                     {
                         mapNodeTypeInfo.LocalPos = UnityTools.String2Vector3(attribute5);
                     }
                     string attribute6 = xmlElement3.GetAttribute("localRotation");
                     if (!string.IsNullOrEmpty(attribute6))
                     {
                         mapNodeTypeInfo.LocalRotation = UnityTools.String2Vector3(attribute6);
                     }
                     string attribute7 = xmlElement3.GetAttribute("effectId");
                     if (!string.IsNullOrEmpty(attribute7))
                     {
                         mapNodeTypeInfo.EffectId = Convert.ToInt32(attribute7);
                     }
                     string attribute8 = xmlElement3.GetAttribute("triggerEffectId");
                     if (!string.IsNullOrEmpty(attribute8))
                     {
                         mapNodeTypeInfo.GetEffectId = Convert.ToInt32(attribute8);
                     }
                     this.m_dicMapNodeTypeInfo.Add(eMapNodeType, mapNodeTypeInfo);
                 }
                 catch (Exception ex)
                 {
                     this.logger.Fatal(ex.ToString());
                 }
             }
         }
         XmlNode xmlNode6 = xmlNode.SelectSingleNode("pveSetting");
         if (xmlNode6 != null)
         {
             this.PVESetting = new PVESetting();
             XmlNode xmlNode7 = xmlNode6.SelectSingleNode("ourBase");
             if (xmlNode7 != null)
             {
                 XmlElement xmlElement4 = (XmlElement)xmlNode7;
                 string     attribute9  = xmlElement4.GetAttribute("file");
                 this.PVESetting.OurBaseModelFile = attribute9;
                 string attribute10 = xmlElement4.GetAttribute("LocalPos");
                 if (!string.IsNullOrEmpty(attribute10))
                 {
                     this.PVESetting.OurBaseLocalPos = UnityTools.String2Vector3(attribute10);
                 }
                 string attribute11 = xmlElement4.GetAttribute("LocalRotation");
                 if (!string.IsNullOrEmpty(attribute11))
                 {
                     this.PVESetting.OurBaseLocalRotation = UnityTools.String2Vector3(attribute11);
                 }
             }
             XmlNode xmlNode8 = xmlNode6.SelectSingleNode("enemyBase");
             if (xmlNode8 != null)
             {
                 XmlElement xmlElement5 = (XmlElement)xmlNode8;
                 string     attribute12 = xmlElement5.GetAttribute("file");
                 this.PVESetting.EnemyBaseModelFile = attribute12;
                 string attribute13 = xmlElement5.GetAttribute("LocalPos");
                 if (!string.IsNullOrEmpty(attribute13))
                 {
                     this.PVESetting.EnemyBaseLocalPos = UnityTools.String2Vector3(attribute13);
                 }
                 string attribute14 = xmlElement5.GetAttribute("LocalRotation");
                 if (!string.IsNullOrEmpty(attribute14))
                 {
                     this.PVESetting.EnemyBaseLocalRotation = UnityTools.String2Vector3(attribute14);
                 }
             }
         }
     }
     catch (Exception ex2)
     {
         this.logger.Fatal(ex2.Message);
     }
 }