示例#1
0
 public override Dictionary <string, object> WriteJson(Type type, object value)
 {
     Pathfinding.Util.Guid m = (Pathfinding.Util.Guid)value;
     return(new Dictionary <string, object>()
     {
         { "value", m.ToString() }
     });
 }
示例#2
0
 public override bool Equals(object _rhs)
 {
     if (!(_rhs is Pathfinding.Util.Guid))
     {
         return(false);
     }
     Pathfinding.Util.Guid guid = (Pathfinding.Util.Guid)_rhs;
     return((this._a == guid._a) && (this._b == guid._b));
 }
示例#3
0
        public virtual void DeserializeSettings(GraphSerializationContext ctx)
        {
            guid           = new Guid(ctx.reader.ReadBytes(16));
            initialPenalty = ctx.reader.ReadUInt32();
            open           = ctx.reader.ReadBoolean();
            name           = ctx.reader.ReadString();
            drawGizmos     = ctx.reader.ReadBoolean();
            infoScreenOpen = ctx.reader.ReadBoolean();

            for (int i = 0; i < 4; i++)
            {
                Vector4 row = Vector4.zero;
                for (int j = 0; j < 4; j++)
                {
                    row[j] = ctx.reader.ReadSingle();
                }
                matrix.SetRow(i, row);
            }
        }
示例#4
0
        /** Tries to find a graph with the specified GUID in the #graphs array. Returns null if none is found
         * \see GuidToIndex */
        public NavGraph GuidToGraph(Guid guid)
        {
            if (graphs == null)
            {
                return(null);
                //CollectGraphs ();
            }

            for (var i = 0; i < graphs.Length; i++)
            {
                if (graphs[i] == null)
                {
                    continue;
                }
                if (graphs[i].guid == guid)
                {
                    return(graphs[i]);
                }
            }
            return(null);
        }
示例#5
0
        /** Tries to find a graph with the specified GUID in the #graphs array.
         * If a graph is found it returns its index, otherwise it returns -1
         * \see GuidToGraph */
        public int GuidToIndex(Guid guid)
        {
            if (graphs == null)
            {
                return(-1);
                //CollectGraphs ();
            }

            for (var i = 0; i < graphs.Length; i++)
            {
                if (graphs[i] == null)
                {
                    continue;
                }
                if (graphs[i].guid == guid)
                {
                    return(i);
                }
            }
            return(-1);
        }
示例#6
0
        public void SetUpGraphRefs(NavGraph[] graphs)
        {
            graphRefGuids = new int[loadedGraphGuids.Length];

            for (int i=0;i<loadedGraphGuids.Length;i++) {

                Pathfinding.Util.Guid guid = new Pathfinding.Util.Guid (loadedGraphGuids[i]);

                graphRefGuids[i] = -1;

                for (int j=0;j<graphs.Length;j++) {
                    if (graphs[j].guid == guid) {
                        graphRefGuids[i] = i;
                    }
                }
                //graphRefGuids[i] = astarData.GuidToIndex ());
            }
        }
示例#7
0
文件: Base.cs 项目: Marchys/fanalet
		public virtual void DeserializeSettings ( GraphSerializationContext ctx ) {

			guid = new Guid(ctx.reader.ReadBytes (16));
			initialPenalty = ctx.reader.ReadUInt32 ();
			open = ctx.reader.ReadBoolean();
			name = ctx.reader.ReadString();
			drawGizmos = ctx.reader.ReadBoolean();
			infoScreenOpen = ctx.reader.ReadBoolean();

			for ( int i = 0; i < 4; i++ ) {
				Vector4 row = Vector4.zero;
				for ( int j = 0; j < 4; j++ ) {
					row[j] = ctx.reader.ReadSingle ();
				}
				matrix.SetRow (i, row);
			}
		}
示例#8
0
 static Guid()
 {
     zero       = new Pathfinding.Util.Guid(new byte[0x10]);
     zeroString = new Pathfinding.Util.Guid(new byte[0x10]).ToString();
     random     = new Random();
 }
示例#9
0
		/** Tries to find a graph with the specified GUID in the #graphs array. Returns null if none is found
		 * \see GuidToIndex */
		public NavGraph GuidToGraph (Guid guid) {
			
			if (graphs == null) {
				return null;
				//CollectGraphs ();
			}
			
			for (var i=0;i<graphs.Length;i++) {
				if (graphs[i] == null) {
					continue;
				}
				if (graphs[i].guid == guid) {
					return graphs[i];
				}
			}
			return null;
		}
示例#10
0
		/** Tries to find a graph with the specified GUID in the #graphs array.
		 * If a graph is found it returns its index, otherwise it returns -1
		 * \see GuidToGraph */
		public int GuidToIndex (Guid guid) {
			
			if (graphs == null) {
				return -1;
				//CollectGraphs ();
			}
			
			for (var i=0;i<graphs.Length;i++) {
				if (graphs[i] == null) {
					continue;
				}
				if (graphs[i].guid == guid) {
					return i;
				}
			}
			return -1;
		}
示例#11
0
        /** Deserializes common info additively
         * Common info is what is shared between the editor serialization and the runtime serializer.
         * This is mostly everything except the graph inspectors which serialize some extra data in the editor
         */
        public void DeserializeGraphsPartAdditive(AstarSerializer sr)
        {
            if (graphs == null)
            {
                graphs = new NavGraph[0];
            }
            if (userConnections == null)
            {
                userConnections = new UserConnection[0];
            }

            var gr = new List <NavGraph>(graphs);

            gr.AddRange(sr.DeserializeGraphs());
            graphs = gr.ToArray();
            if (graphs != null)
            {
                for (var i = 0; i < graphs.Length; i++)
                {
                    if (graphs[i] != null)
                    {
                        graphs[i].graphIndex = (uint)i;
                    }
                }
            }

            var conns = new List <UserConnection>(userConnections);

            conns.AddRange(sr.DeserializeUserConnections());
            userConnections = conns.ToArray();
            sr.DeserializeNodes();

            //Assign correct graph indices. Issue #21
            for (var i = 0; i < graphs.Length; i++)
            {
                if (graphs[i] == null)
                {
                    continue;
                }
                graphs[i].GetNodes(delegate(GraphNode node) {
                    //GraphNode[] nodes = graphs[i].nodes;
                    node.GraphIndex = (uint)i;
                    return(true);
                });
            }

            sr.DeserializeExtraInfo();
            sr.PostDeserialization();

            for (var i = 0; i < graphs.Length; i++)
            {
                for (var j = i + 1; j < graphs.Length; j++)
                {
                    if (graphs[i] != null && graphs[j] != null && graphs[i].guid == graphs[j].guid)
                    {
                        Debug.LogWarning("Guid Conflict when importing graphs additively. Imported graph will get a new Guid.\nThis message is (relatively) harmless.");
                        graphs[i].guid = Guid.NewGuid();
                        break;
                    }
                }
            }
        }