private bool MoveToRandomNearbyCell() { List <Vec2I> possible = new List <Vec2I>(); foreach (Vec2I neighbor in owner.cell.neighbors) { if (!AI.CanPath(neighbor)) { continue; } if (AI.GetHeat(neighbor).x >= 1f) { continue; } if (AI.HasLedge(owner.cell, neighbor)) { continue; } possible.Add(neighbor); } if (possible.Count == 0) { return(false); } Vec2I d = Vec2I.directions[AxMath.RogueDirection(owner.cell, possible[Random.Range(0, possible.Count)])]; wantDirection = new Vector3(d.x, 0, d.y).normalized; return(true); }
private bool MoveToRandomClosestBreath() { int lowest = int.MaxValue; List <Breath> bestBreaths = new List <Breath>(); foreach (Breath b in GameManager.Instance.Player[0].playerBreath.GetNearbyBreaths(owner.cell, 1)) { if (AI.HasLedge(owner.cell, b.position)) { continue; } Vector3 heat = AI.GetHeat(b.position); if (heat.x >= 1f) { continue; } if (heat.x >= .5f) { continue; } if (b.steps < lowest) { bestBreaths.Clear(); bestBreaths.Add(b); lowest = b.steps; } else if (b.steps == lowest) { bestBreaths.Add(b); } } if (bestBreaths.Count == 0) { return(false); } Vec2I d = Vec2I.directions[AxMath.RogueDirection(owner.cell, bestBreaths[Random.Range(0, bestBreaths.Count)].position)]; wantDirection = new Vector3(d.x, 0, d.y).normalized; wantMove = true; return(true); }