Beispiel #1
0
        public NavMeshInstance(NavMesh mesh, TravelMode mode, int startNode, bool random, bool reverse, bool allowU, int timeOut)
        {
            m_navMesh = mesh;
            m_currentNode = new Node(startNode);

            m_overrideMode = mode;
            m_startNode = startNode;
            m_random = random;
            m_reverse = reverse;
            m_allowU = allowU;
            timeOut = Math.Max(0, timeOut);

            m_timeOut = timeOut;
        }
Beispiel #2
0
        public void Import(NavMesh mesh, XmlNode node)
        {
            mesh.Name = node.Attributes.GetNamedItem("name").Value;
            mesh.DefaultMode = NavMesh.ParseTravelMode(node.Attributes.GetNamedItem("default_mode").Value);

            foreach (XmlNode childNode in node.ChildNodes)
            {
                switch (childNode.Name)
                {
                    case "mesh_node":
                        Vector3 meshNodePos;
                        string pos = childNode.Attributes.GetNamedItem("p").Value;
                        try
                        {
                            meshNodePos = Vector3.Parse(pos);
                        }
                        catch (Exception e)
                        {
                            throw new System.Xml.XmlException("Failed to parse mesh_node position: " + pos + ". Reason: " + e.Message);
                        }
                        mesh.AddNode(meshNodePos);
                    break;

                    case "mesh_edge":
                        int e1 = Convert.ToInt32(childNode.Attributes.GetNamedItem("e1").Value);
                        int e2 = Convert.ToInt32(childNode.Attributes.GetNamedItem("e2").Value);
                        TravelMode mode = mesh.DefaultMode;

                        try
                        {
                            mode = NavMesh.ParseTravelMode(childNode.Attributes.GetNamedItem("mode").Value);
                        } catch (Exception) {}

                        try
                        {
                            mesh.AddEdge(e1, e2, mode);
                        }
                        catch (System.ArgumentException)
                        {
                            m_log.Warn("[NavMeshSerializer]: Duplicate edge from: " + e1.ToString() + " to: " + e2.ToString() + ".");
                        }
                        break;

            //                    default:
            //                        throw new System.Xml.XmlException("Unknown xml element: " + childNode.Name + ".");
                }
            }
        }
Beispiel #3
0
 // read config data for single navmesh
 private void createNavMesh(XmlNode node)
 {
     NavMesh mesh = new NavMesh();
     NavMeshSerializer serializer = new NavMeshSerializer();
     serializer.Import(mesh, node);
     try
     {
         m_navMeshManager.AddNavMesh(mesh);
     }
     catch (System.ArgumentException)
     {
         m_log.Error("[RexBotManager]: NavMesh with the name: " + mesh.Name + " already exists! NavMeshes must be unique.");
     }
 }
Beispiel #4
0
 public void AddNavMesh(NavMesh mesh)
 {
     m_navMeshes.Add(mesh.Name, mesh);
 }