Exemple #1
0
        private void MoveTowardsGoal()
        {
            if (this.X == this.goal.X && this.Y == this.goal.Y)
            {
                this.goal    = map.FindEmptyPosition();
                this.goalMap = this.CreateGoalMap();
            }

            var path = goalMap.FindPath(this.X, this.Y);

            if (path != null)
            {
                var now      = path.Steps.First();
                var nextStep = path.Steps.Skip(1).FirstOrDefault();
                if (nextStep != null && map.IsWalkable(nextStep.X, nextStep.Y))
                {
                    this.Move(nextStep.X, nextStep.Y);
                }
                else
                {
                    // Pick a new goal next time
                    this.goal = new Point(this.X, this.Y);
                }
            }
            else
            {
                // No path to goal... Pick a new goal next time
                this.goal = new Point(this.X, this.Y);
            }
        }
Exemple #2
0
        public Monster(ColourTuple colour, int agility, string visionType, int visionSize, CaveFloorMap map) : base('m', colour, true)
        {
            this.Agility    = agility;
            this.VisionType = visionType;
            this.VisionSize = visionSize;

            Monster.map  = map;
            this.goal    = map.FindEmptyPosition();
            this.goalMap = this.CreateGoalMap();
        }