Beispiel #1
0
        private void determenTileValue(Tile currentTile, Tile testingTile)
        {
            if (testingTile == null)
            {
                return;
            }
            //check if we have found the target
            if (testingTile == TargetTile)
            {
                testingTile.Parent = currentTile;
                FoundTarget = true;
                return;
            }

            if (!closeList.Contains(testingTile))
            {
                if (openList.Contains(testingTile))
                {
                    int newGCost = currentTile.GValue + currentTile.BaseGvalue;

                    if (newGCost < testingTile.GValue)
                    {
                        testingTile.Parent = currentTile;
                        testingTile.GValue = newGCost;
                        testingTile.calculateFValue();
                    }
                }

                else
                {
                    testingTile.Parent = currentTile;
                    testingTile.GValue = currentTile.GValue + currentTile.BaseGvalue;
                    testingTile.calculateFValue();
                    openList.Add(testingTile);
                }
            }
        }