Trying to iterate over a Dictionary of (int, Class) Classes - and cannot for the life of me figure out HOW to reference a method in the script of the current iterated Object “CheckDirection()”, which returns String. I have another Dictionary with the coords, but I don’t iterate over that.
Everytime I step through the foreach loop, I get the same Object (the first one with index 0), never the others?
Am I trying to do something that is not allowed? Or am I doing it wrong?
Short sample of code.
Happy to supply any details required, this is not a secret game or anything. Just me fooling about, trying to learn
// moveString is either Up, Down, Left or Right //
string newdirection;
foreach (KeyValuePair<int, Block> block in GridManager.Instance._blocks)
{
// Open the CheckDirection() Method on current Object //
newdirection = block.Value.CheckDirection(moveString);
int val = block.Key;
string[] blockstr = block.Value.ToString().Split(" ");
_startposition = new Vector2(GridManager.Instance._blocksPos[val].x, GridManager.Instance._blocksPos[val].y);
_vector2 = GetNextMove(newdirection, blockstr[0], _startposition.x, _startposition.y);
_finishposition = _vector2;
}