Example #1
0
        private static RogueSharp.Path GeneratePath(GameQuery_Command commandQuery, GameQuery_Position targetPos)
        {
            // TODO: Wow this is awkward!?
            var commandPos  = commandQuery.CommandEntity.TryGetPosition();
            var commandCell = commandQuery.ArenaState.ArenaMap.GetCell(commandPos.X, commandPos.Y);
            var targetCell  = commandQuery.ArenaState.ArenaMap.GetCell(targetPos.X, targetPos.Y);

            return(commandQuery.ArenaState.ShortestPath(commandCell, targetCell));
        }
Example #2
0
        public void DeterminePatrolPath(ArenaState state, IRandom rand)
        {
            this.PatrolStart = this.Parent.TryGetPosition();
            var  cells = state.WalkableCells();
            Cell cell  = rand.RandomElement(cells);

            while (Config.MinPatrolDistance < ArenaState.DistanceBetweenPositions(this.PatrolStart.X,
                                                                                  this.PatrolStart.Y, cell.X, cell.Y))
            {
                cell = rand.RandomElement(cells);
            }
            var endPos = new GameQuery_Position();

            endPos.RegisterPosition(cell.X, cell.Y, false);
            this.PatrolEnd = endPos;
        }
Example #3
0
        private bool EnemyOnPath(GameQuery_Position targetPos)
        {
            bool future = false;

            foreach (var step in this.lastPath.Steps)
            {
                if (step == this.lastPath.CurrentStep)
                {
                    future = true;
                }

                if (future && step.X == targetPos.X && step.Y == targetPos.Y)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #4
0
 private Cell PositionToCell(GameQuery_Position pos, ArenaState arena)
 {
     return(arena.ArenaMap.GetCell(pos.X, pos.Y));
 }
Example #5
0
 private void HandleQueryPosition(GameQuery_Position q)
 {
     q.RegisterPosition(this.X, this.Y, this.BlocksMovement);
 }
Example #6
0
 private Cell PositionToCell(GameQuery_Position pos, FloorState floor)
 {
     return(floor.FloorMap.GetCell(pos.X, pos.Y));
 }