Esempio n. 1
0
    public HashSet <Vector3Int> GetViable(Vector3Int current, int team, int mobilityLeft, Dictionary <Territory.Type, int> mods, HashSet <Vector3Int> visitedBefore)
    {
        HashSet <Vector3Int> visited = visitedBefore;

        visited.Add(current);         // TODO: check if unit is here
        if (CanMoveOver(team))
        {
            for (int i = 0; i < 6; i++)
            {
                Vector3Int neighbour = GetNeighbour(current, i);
                Territory  t         = map.GetTerritoryAt(neighbour);
                if (t != null)
                {
                    Territory.Type type = t.GetTerritoryType();
                    if (mods.ContainsKey(type))
                    {
                        int cost = mods[type];
                        if (cost <= mobilityLeft)
                        {
                            // move there and recalculate
                            visited = GetViable(neighbour, team, mobilityLeft - cost, mods, visited);
                        }
                    }
                }                 // else just skip
            }
        }
        return(visited);
    }
Esempio n. 2
0
    private static HashSet <Vector3Int> PathFromNeighbours(TerrainManager map, HashSet <Vector3Int> visitedBefore, Vector3Int current, ArmyUnit unit, int mobilityLeft)
    {
        HashSet <Vector3Int> visited = visitedBefore;

        for (int i = 0; i < 6; i++)
        {
            Vector3Int neighbour = GetNeighbour(current, i);
            Territory  t         = map.GetTerritoryAt(neighbour);
            if (t != null)
            {
                // t we can move
                Territory.Type type = t.GetTerritoryType();
                int            cost = unit.TerrainCost(type);
                if (cost >= 0 && cost <= mobilityLeft && CanMoveOver(map, unit, current))
                {
                    visited.Add(current);
                    visited = NeighbourPath(map, visited, neighbour, unit, mobilityLeft - cost);
                }
            }
        }
        return(visited);
    }
Esempio n. 3
0
    private Tile GetTile(Territory t)
    {
        Tile tile;

        switch (t.GetTerritoryType())
        {
        case Territory.Type.PLAIN: tile = Instantiate(plains); break;

        case Territory.Type.FOREST: tile = Instantiate(forests); break;

        case Territory.Type.MOUNTAIN: tile = Instantiate(mountains); break;

        case Territory.Type.SWAMP: tile = Instantiate(swamps); break;

        case Territory.Type.DESERT: tile = Instantiate(deserts); break;

        case Territory.Type.WATER: tile = Instantiate(waters); break;

        case Territory.Type.CIRCLE: tile = Instantiate(circle); break;

        default: tile = null; break;
        }
        return(tile);
    }