public override void StateEnter() { base.StateEnter(); status = StateStatus.Error; if (brain.PathFinder == null) { return; } Vector3 center; if (brain.InGroup() && !brain.IsGroupLeader) { center = brain.Events.Memory.Position.Get(5); center = BasePathFinder.GetPointOnCircle(center, Random.Range(2f, 7f), Random.Range(0f, 359f)); } else { center = brain.PathFinder.GetBestRoamPosition(brain.Navigator, brain.Events.Memory.Position.Get(4), 20f, 100f); } if (brain.Navigator.SetDestination(center, BaseNavigator.NavigationSpeed.Slow)) { if (brain.InGroup() && brain.IsGroupLeader) { brain.SetGroupRoamRootPosition(center); } status = StateStatus.Running; } else { status = StateStatus.Error; } }
public void init(int height, int width) { DefaultPathfinderParams parms = new DefaultPathfinderParams(); parms.Height = height; parms.Width = width; this.pathFinder = new DefaultPathFinder(parms); this.PlayerDetected = false; }
private void FaceNewDirection() { if (Random.Range(0, 100) <= turnChance) { Vector3 position = GetEntity().transform.position; Vector3 normalized = (BasePathFinder.GetPointOnCircle(position, 1f, Random.Range(0f, 594f)) - position).normalized; brain.Navigator.SetFacingDirectionOverride(normalized); } nextTurnTime = Time.realtimeSinceStartup + Random.Range(minTurnTime, maxTurnTime); }
public void init(int height, int width) { DefaultPathfinderParams parms = new DefaultPathfinderParams(); parms.Height = height; parms.Width = width; parms.AllowCornerCutting = false; parms.DirectionRestrictionType = BasePathFinder.RestrictionType.Restricted; this.pathFinder = new DefaultPathFinder(parms); }
public List <SearchResultState> GetWay(SearchParameters parameters) { LastSearchParameters = parameters; // remove unuse items parameters.StartState.Items.RemoveAll(item => !item.BasicItem.InUse || !item.BasicItem.IsProhibiting); var stopwatch = Stopwatch.StartNew(); IPathFinder pathFinder = null; // TODO: Add mapping switch (parameters.Algorithm) { case SearchAlgorithm.Bfs: pathFinder = new LongestPathFinder(new BfsPathStateGenerator()); break; case SearchAlgorithm.Dfs: pathFinder = new LongestPathFinder(new DfsPathStateGenerator(false)); break; case SearchAlgorithm.RandomDfs: pathFinder = new LongestPathFinder(new DfsPathStateGenerator(true)); break; case SearchAlgorithm.DiscoverNewParagraph: pathFinder = new BasePathFinder(new BfsPathStateGenerator(), new DiscoverNewParagraphPathFormator(m_Paragraphs)); break; } var result = pathFinder.FindPath(parameters.StartState, m_Edges); stopwatch.Stop(); if (result != null) { HandleNewPath(result); LastGeneratedWay = result; } return(result); }