public void Refresh() { Mechanics.BreadthSearch search = new Mechanics.BreadthSearch(_ghost.Game); path = search.getPath(_ghost.CurrentPlate, _ghost.Game.Maze1.maze[_zoneY, _zoneX]); isInCorner = false; LookAhead(); }
public void LookAhead() { if (needRefresh) { needRefresh = false; Refresh(); return; } if (path == null) { Mechanics.BreadthSearch search = new Mechanics.BreadthSearch(_ghost.Game); path = search.getPath(_ghost.CurrentPlate, _ghost.Game.Maze1.maze[_zoneY, _zoneX]); } if (!isInCorner && path.Count <= 1) { isInCorner = true; } if (!isInCorner) { //if (path.Count == 1) isInCorner = true; _ghost.nextPlate = path.Dequeue(); for (int i = 0; i < _ghost.CurrentPlate.diretions.Length; i++) { if (_ghost.CurrentPlate.diretions[i] == _ghost.nextPlate) { _ghost.Direction = (Direction)i; } } } else { if (_ghost.CurrentPlate.diretions[_ghost.NextTurn].Passable) { _ghost.nextPlate = _ghost.CurrentPlate.diretions[_ghost.NextTurn]; _ghost.Direction = (Direction)_ghost.NextTurn; _ghost.NextTurn = (_ghost.NextTurn + 1) % 4; } else if (_ghost.CurrentPlate.diretions[(_ghost.NextTurn + 2) % 4].Passable) { _ghost.NextTurn = (_ghost.NextTurn + 2) % 4; _ghost.nextPlate = _ghost.CurrentPlate.diretions[_ghost.NextTurn]; _ghost.Direction = (Direction)_ghost.NextTurn; _ghost.NextTurn = (_ghost.NextTurn + 1) % 4; } else { _ghost.nextPlate = _ghost.CurrentPlate.diretions[(int)_ghost.Direction]; } } }
public void FollowPath() { if (_ghost.Path.Count == 0) { if (_ghost.ActivPath) { if (_ghost.Game.getDistance(_ghost.Xpos, _ghost.RespawnPos.Xpos, _ghost.Ypos, _ghost.RespawnPos.Ypos) <= 5) { _ghost.returnToGame(); return; } if (_ghost.CurrentPlate == _ghost.RespawnPos) { _ghost.returnToGame(); return; } else { Mechanics.BreadthSearch aStar = new Mechanics.BreadthSearch(_ghost.Game); _ghost.Path = aStar.getPath(_ghost.CurrentPlate, _ghost.RespawnPos); _ghost.FollowPath(); return; } } _ghost.findPlate((int)_ghost.Direction); return; } _ghost.nextPlate = _ghost.Path.Dequeue(); for (int i = 0; i < _ghost.CurrentPlate.diretions.Length; i++) { if (_ghost.CurrentPlate.diretions[i] == _ghost.nextPlate) { _ghost.Direction = (Direction)i; } } }
public void Refresh() { Mechanics.BreadthSearch aStar = new Mechanics.BreadthSearch(_ghost.Game); _ghost.Path = aStar.getPath(_ghost.CurrentPlate, target.Invoke(0)); }
public void getToPosition(Plate destination) { Mechanics.BreadthSearch aStar = new Mechanics.BreadthSearch(_ghost.Game); _ghost.Path = aStar.getPath(_ghost.CurrentPlate, destination); }