- Home /
I need help with path hexagon
I've been following this tutorial "http://tbswithunity3d.wordpress.com/" and now I'm getting this error:
Assets/ForceX Hex Grid/Scripts/Path.cs(7,14): error CS0535: `Path' does not implement interface member `System.Collections.IEnumerable.GetEnumerator()'
Could anyone help me, I'm new to C#. I have never worked with objective oriented code before, I've worked with HTML and PHP. Now I'm working with a couple of friends with a turn based HexGrid game and we really need some help.
Thanks in advanced for anyone who takes the time to reply!
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class Path: IEnumerable
{
class Path<Node> : IEnumerable<Node>
{
public Node LastStep { get; private set; }
public Path<Node> PreviousSteps { get; private set; }
public double TotalCost { get; private set; }
public Path(Node lastStep, Path<Node> previousSteps, double totalCost)
{
LastStep = lastStep;
PreviousSteps = previousSteps;
TotalCost = totalCost;
}
public Path(Node start) : this(start, null, 0) {}
public Path<Node> AddStep(Node step, double stepCost)
{
return new Path<Node>(step, this, TotalCost + stepCost);
}
public IEnumerator<Node> GetEnumerator()
{
for (Path<Node> p = this; p != null; p = p.PreviousSteps)
yield return p.LastStep;
}
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}
}
Your answer
Follow this Question
Related Questions
Whats wrong with this simple code? 2 Answers
MonoDevelop 4.0.1 code folding 1 Answer
Handheld.PlayFullScreenMovie on iOS not loading video 0 Answers
OnTriggerEnter isn't working 1 Answer
unknown identifer explosion problem 2 Answers