Example #1
0
        public World()
        {
            this.sizeX = WORLD_SIZE;
            this.sizeY = WORLD_SIZE/3;//UP

            this.sizeZ = WORLD_SIZE;
            Random r = new Random ();
            this.color = System.Drawing.Color.Green;

            for (int i = 0; i < this.Heightmap.GetLength(0); i++) {
                for (int j = 0; j < this.Heightmap.GetLength(1); j++) {
                    Heightmap [i, j] = new WorldNode(this, j,r.Next (0, sizeY),i);
                }
            }
        }
Example #2
0
        public List<Coords>GetPath(WorldNode start, WorldNode end)
        {
            //TODO a*
            List<Coords> output = new List<Coords> ();
            if (this.AStar == null) {
                this.AStar = new AStar (start, end);
            } else {
                this.AStar.Reset(start, end);
            }
            Pathfinding.State s = this.AStar.Run ();
            //Console.WriteLine(s);
            //TRanslate to coords
            if (s == Pathfinding.State.GoalFound) {
                List<INode> data = this.AStar.GetPath ();
                if(data!=null){
                    foreach(INode node in data){
                        output.Add(new Coords(node.X,node.Y, node.Z));
                    }
                }
            }

            return output;
        }