當前位置: 首頁>>代碼示例>>C#>>正文


C# NavGraph.GetType方法代碼示例

本文整理匯總了C#中Pathfinding.NavGraph.GetType方法的典型用法代碼示例。如果您正苦於以下問題:C# NavGraph.GetType方法的具體用法?C# NavGraph.GetType怎麽用?C# NavGraph.GetType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pathfinding.NavGraph的用法示例。


在下文中一共展示了NavGraph.GetType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DeSerializeSettings

        //This is intended for quick saving of settings for e.g Undo operations
        public void DeSerializeSettings(NavGraph graph, AstarPath active)
        {
            ISerializableGraph serializeGraph = graph as ISerializableGraph;

            if (serializeGraph == null) {
                Debug.LogError ("The graph specified is not (de)serializable (how it could be serialized in the first place is a mystery) the graph was of type "+graph.GetType());
                return;
            }

            graph.open = readerStream.ReadBoolean ();

            //readerStream.ReadString ();
            serializeGraph.DeSerializeSettings (this);
        }
開發者ID:rmkeezer,項目名稱:fpsgame,代碼行數:15,代碼來源:AstarSerialize.cs

示例2: SerializeSettings

        /** Called to serialize a graphs settings. \note Before calling this, setting #sPrefix to something unique for the graph is a good idea to avoid collisions in variable names */
        public void SerializeSettings(NavGraph graph, AstarPath active)
        {
            ISerializableGraph serializeGraph = graph as ISerializableGraph;

            if (serializeGraph == null) {
                Debug.LogError ("The graph specified is not serializable, the graph is of type "+graph.GetType());
                return;
            }

            serializeGraph.SerializeSettings (this);
        }
開發者ID:rmkeezer,項目名稱:fpsgame,代碼行數:12,代碼來源:AstarSerialize.cs

示例3: DeserializeNodes

        /** Deserializes nodes in the graph. The deserialized nodes will be created using graph.CreateNodes (numberOfNodes).
         * \astarpro */
        public void DeserializeNodes(NavGraph graph, NavGraph[] graphs, int graphIndex, AstarPath active)
        {
            if (mask == SMask.SaveNodes) {

                ISerializableGraph serializeGraph = graph as ISerializableGraph;

                if (serializeGraph == null) {
                    Debug.LogError ("The graph specified is not serializable, the graph is of type "+graph.GetType());
                    return;
                }

                int numNodes = readerStream.ReadInt32 ();

                graph.nodes = serializeGraph.CreateNodes (numNodes);

                if (numNodes == 0) {
                    return;
                }

                for (int i=0;i<graph.nodes.Length;i++) {
                    graph.nodes[i].graphIndex = graphIndex;
                }

                Debug.Log ("Loading "+numNodes+ " nodes");
                if (!MoveToVariableAnchor ("DeserializeGraphNodes")) {
                    Debug.LogError ("Error loading nodes - Couldn't find anchor");
                }

                serializeGraph.DeSerializeNodes (graph.nodes,this);

                if (!MoveToVariableAnchor ("DeserializeNodes")) {
                    Debug.LogError ("Error loading nodes - Couldn't find anchor");
                    return;
                }

                if (mask == SMask.RunLengthEncoding) {
                    int totalCount = 0;

                    //Penalties
                    while (totalCount < graph.nodes.Length) {
                        int runLength = (int)readerStream.ReadByte ();
                        int value = readerStream.ReadInt32 ();
                        int endIndex = totalCount+runLength;

                        if (endIndex > graph.nodes.Length) {
                            Debug.LogError ("Run Length Encoding is too long "+runLength+" "+endIndex+ " "+graph.nodes.Length+" "+totalCount);
                            endIndex = graph.nodes.Length;
                        }

                        for (int i=totalCount;i<endIndex;i++) {
                            graph.nodes[i].penalty = (uint)value;
                        }
                        totalCount = endIndex;
                    }

                    totalCount = 0;

                    //Flags
                    while (totalCount < graph.nodes.Length) {
                        int runLength = (int)readerStream.ReadByte ();
                        int value = readerStream.ReadInt32 ();
                        int endIndex = totalCount+runLength;

                        if (endIndex > graph.nodes.Length) {
                            Debug.LogError ("Run Length Encoding is too long "+runLength+" "+endIndex+ " "+graph.nodes.Length+" "+totalCount);
                            endIndex = graph.nodes.Length;
                        }

                        for (int i=totalCount;i<endIndex;i++) {
                            graph.nodes[i].flags = value;
                        }
                        totalCount += runLength;
                    }
                }

                for (int i=0;i<graph.nodes.Length;i++) {
                    DeSerializeNode (graph.nodes[i], graphs, graphIndex, readerStream);
                }
            }
        }
開發者ID:rmkeezer,項目名稱:fpsgame,代碼行數:82,代碼來源:AstarSerialize.cs

示例4: SerializeNodes

        /** Serializes the nodes in the graph.
         * \astarpro */
        public void SerializeNodes(NavGraph graph, AstarPath active)
        {
            if (mask == SMask.SaveNodes) {

                ISerializableGraph serializeGraph = graph as ISerializableGraph;

                if (serializeGraph == null) {
                    Debug.LogError ("The graph specified is not serializable, the graph is of type "+graph.GetType());
                    return;
                }

                if (graph.nodes == null || graph.nodes.Length == 0) {
                    writerStream.Write (0);
                    //Debug.LogWarning ("No nodes to serialize");
                    return;
                }

                writerStream.Write (graph.nodes.Length);

                //writerStream.Write (savingToFile ? 753 : 1337);
                Debug.Log ("Stored nodes "+" "+writerStream.BaseStream.Position);

                SizeProfiler.Begin ("Graph specific nodes",writerStream);

                AddVariableAnchor ("DeserializeGraphNodes");
                serializeGraph.SerializeNodes (graph.nodes,this);

                SizeProfiler.End ("Graph specific nodes",writerStream);

                AddVariableAnchor ("DeserializeNodes");

                if (mask == SMask.RunLengthEncoding) {

                    SizeProfiler.Begin ("RLE Penalty",writerStream);
                    //Penalties
                    int lastValue = (int)graph.nodes[0].penalty;
                    int lastEntry = 0;

                    for (int i=1;i<graph.nodes.Length;i++) {
                        if (graph.nodes[i].penalty != lastValue || (i-lastEntry) >= byte.MaxValue-1) {
                            writerStream.Write ((byte)(i-lastEntry));
                            writerStream.Write (lastValue);
                            lastValue = (int)graph.nodes[i].penalty;
                            lastEntry = i;
                        }
                    }

                    writerStream.Write ((byte)(graph.nodes.Length-lastEntry));
                    writerStream.Write (lastValue);

                    SizeProfiler.Begin ("RLE Flags",writerStream);

                    //Flags
                    lastValue = graph.nodes[0].flags;
                    lastEntry = 0;

                    for (int i=1;i<graph.nodes.Length;i++) {
                        if (graph.nodes[i].flags != lastValue || (i-lastEntry) >= byte.MaxValue) {
                            writerStream.Write ((byte)(i-lastEntry));
                            writerStream.Write (lastValue);
                            lastValue = graph.nodes[i].flags;
                            lastEntry = i;
                        }
                    }
                    writerStream.Write ((byte)(graph.nodes.Length-lastEntry));
                    writerStream.Write (lastValue);

                    SizeProfiler.End ("RLE Flags",writerStream);
                }

                SizeProfiler.Begin ("Nodes, other",writerStream);

                for (int i=0;i<graph.nodes.Length;i++) {
                    SerializeNode (graph.nodes[i], writerStream);
                }

                SizeProfiler.End ("Nodes, other",writerStream);
            }
        }
開發者ID:rmkeezer,項目名稱:fpsgame,代碼行數:81,代碼來源:AstarSerialize.cs


注:本文中的Pathfinding.NavGraph.GetType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。