private uint WalkPath(Queue <PointWalk> points, Point target, uint magicNumber, int maxDistance) { HashSet <ulong> visited = new HashSet <ulong>(); uint walkingPoints = 0; while (points.Count > 0) { PointWalk pointWalk = points.Dequeue(); Point point = pointWalk.Point; // check if this is the target if (maxDistance <= 0 && point.X == target.X && point.Y == target.Y) { return(pointWalk.Distance); } if (!IsOpen((uint)point.X, (uint)point.Y, magicNumber)) { continue; } if (visited.Contains(GetId(point.X, point.Y))) { continue; } visited.Add(GetId(point.X, point.Y)); if (maxDistance > 0) { if (pointWalk.Distance <= maxDistance) { ++walkingPoints; } else { continue; } } // add new points points.Enqueue(new PointWalk(new Point(point.X + 1, point.Y), pointWalk.Distance + 1)); points.Enqueue(new PointWalk(new Point(point.X, point.Y + 1), pointWalk.Distance + 1)); if (point.X > 0) { points.Enqueue(new PointWalk(new Point(point.X - 1, point.Y), pointWalk.Distance + 1)); } if (point.Y > 0) { points.Enqueue(new PointWalk(new Point(point.X, point.Y - 1), pointWalk.Distance + 1)); } } return(walkingPoints); }
void Start() { // Set values playerScript = player.GetComponent <PointWalk>(); particle = particleEffect.GetComponentInChildren <ParticleSystem>(); particle.Stop(); vide = GetComponent <VIDE_Assign>(); accessoryPrev.SetActive(true); accessoryNew.SetActive(false); if (accessoryNew2) { accessoryNew2.SetActive(false); } GetComponent <Renderer>().material = materialPrev; }
// Start is called before the first frame update void Start() { playerScript = player.GetComponent <PointWalk>(); vide = GetComponent <VIDE_Assign>(); }
// Start is called before the first frame update void Start() { walking = GetComponent <PointWalk>(); }