示例#1
0
    public Enc(string t, List <EncChoice> c, TileTerrain tt, TileFeatures tf)
    {
        text        = t;
        choices     = c;
        terrainType = tt;
        featureType = tf;

        encounters = new List <string>();
    }
示例#2
0
    public GameTile GetNearestTile(GameTile tile, TileTerrain terrain, TileFeatures feature, int distance)
    {
        List <GameTile> allowed = new List <GameTile>();

        if (terrain == TileTerrain.Land)
        {
            allowed.AddRange(regionLand);
        }
        else if (terrain == TileTerrain.River)
        {
            allowed.AddRange(regionRiver);
        }
        else if (terrain == TileTerrain.DeepSea)
        {
            allowed.AddRange(regionDeepSea);
        }
        else if (terrain == TileTerrain.ShallowSea)
        {
            allowed.AddRange(regionSea);
        }
        else if (terrain == TileTerrain.Sand)
        {
            allowed.AddRange(regionSand);
        }
        else if (terrain == TileTerrain.Grass || terrain == TileTerrain.Grass2)
        {
            allowed.AddRange(regionGrass);
        }
        else if (terrain == TileTerrain.Mountain || terrain == TileTerrain.Mountain2)
        {
            allowed.AddRange(regionMountain);
        }
        else if (terrain == TileTerrain.Snow || terrain == TileTerrain.Snow2)
        {
            allowed.AddRange(regionSnow);
        }


        allowed = allowed.OrderBy(o => o.DistanceTo(tile)).ToList();

        while (true)
        {
            for (int i = 0; i < allowed.Count; i++)
            {
                if (tile.DistanceTo(allowed[i]) > distance && allowed[i].tileFeatures == feature)
                {
                    return(allowed[i]);
                }
            }
            distance = Mathf.Clamp(distance - 2, 1, distance);
        }
    }
示例#3
0
    public void PlaceFeature(GameObject feature, TileFeatures featureType, int distanceFromSameFeature, List <TileTerrain> allowedTerrain)
    {
        List <GameTile> placed       = new List <GameTile>();
        List <GameTile> allowedTiles = new List <GameTile>();

        if (allowedTerrain.Contains(TileTerrain.River))
        {
            allowedTiles.AddRange(map.regionRiver);
        }
        if (allowedTerrain.Contains(TileTerrain.DeepSea))
        {
            allowedTiles.AddRange(map.regionDeepSea);
        }
        if (allowedTerrain.Contains(TileTerrain.ShallowSea))
        {
            allowedTiles.AddRange(map.regionSea);
        }
        if (allowedTerrain.Contains(TileTerrain.Sand) || allowedTerrain.Contains(TileTerrain.Land))
        {
            allowedTiles.AddRange(map.regionSand);
        }
        if (allowedTerrain.Contains(TileTerrain.Grass) || allowedTerrain.Contains(TileTerrain.Grass2) || allowedTerrain.Contains(TileTerrain.Land))
        {
            allowedTiles.AddRange(map.regionGrass);
        }
        if (allowedTerrain.Contains(TileTerrain.Mountain) || allowedTerrain.Contains(TileTerrain.Mountain2) || allowedTerrain.Contains(TileTerrain.Land))
        {
            allowedTiles.AddRange(map.regionMountain);
        }
        if (allowedTerrain.Contains(TileTerrain.Snow) || allowedTerrain.Contains(TileTerrain.Snow2) || allowedTerrain.Contains(TileTerrain.Land))
        {
            allowedTiles.AddRange(map.regionSnow);
        }

        Debug.Log("wat " + allowedTiles.Count);
        for (int i = 0; i < allowedTiles.Count; i++)
        {
            if (EvaluateFeaturePosition(allowedTiles[i].transform.position, placed, distanceFromSameFeature) && allowedTiles[i].tileFeatures == TileFeatures.None)
            {
                if (featureType == TileFeatures.Bridge)
                {
                    if (allowedTiles[i].tileDown.tileTerrain != TileTerrain.River && allowedTiles[i].tileUp.tileTerrain != TileTerrain.River &&
                        allowedTiles[i].tileDown.tileTerrain != TileTerrain.ShallowSea && allowedTiles[i].tileUp.tileTerrain != TileTerrain.ShallowSea)
                    {
                        GameObject temp = Instantiate(feature);
                        temp.transform.localPosition = allowedTiles[i].transform.position;
                        Vector3 tempRot = temp.transform.localEulerAngles;
                        tempRot.y = 90;
                        temp.transform.localEulerAngles = tempRot;
                        temp.transform.parent           = featuresBucket.transform;
                        placed.Add(allowedTiles[i]);
                        allowedTiles[i].tileFeatures = featureType;
                    }
                    else if (allowedTiles[i].tileLeft.tileTerrain != TileTerrain.River && allowedTiles[i].tileRight.tileTerrain != TileTerrain.River &&
                             allowedTiles[i].tileDown.tileTerrain != TileTerrain.ShallowSea && allowedTiles[i].tileUp.tileTerrain != TileTerrain.ShallowSea)
                    {
                        GameObject temp = Instantiate(feature);
                        temp.transform.localPosition = allowedTiles[i].transform.position;
                        temp.transform.parent        = featuresBucket.transform;
                        placed.Add(allowedTiles[i]);
                        allowedTiles[i].tileFeatures = featureType;
                    }
                }
                else
                {
                    GameObject temp = Instantiate(feature);
                    temp.transform.localPosition = allowedTiles[i].transform.position;
                    temp.transform.parent        = featuresBucket.transform;
                    placed.Add(allowedTiles[i]);
                    allowedTiles[i].tileFeatures = featureType;

                    if (featureType == TileFeatures.Castle || featureType == TileFeatures.Cave || featureType == TileFeatures.Town ||
                        featureType == TileFeatures.Village || featureType == TileFeatures.swamp)
                    {
                        Vector3 tempRot = temp.transform.localEulerAngles;
                        tempRot.y = (int)Random.Range(1f, 4f) * 90;
                        temp.transform.localEulerAngles = tempRot;
                    }
                }
            }
        }
    }
示例#4
0
 public GameTile GetNearestTile(TileTerrain terrain, TileFeatures feature, int distance)
 {
     return(map.GetNearestTile(player.Tile, terrain, feature, distance));
 }
示例#5
0
    private List <Enc> GetEncounterByTerrainAndFeature(List <Enc> list, TileTerrain terrain, TileFeatures feature)
    {
        List <Enc> newList = new List <Enc>();

        for (int i = 0; i < list.Count; i++)
        {
            if (list[i].terrainType == terrain && list[i].featureType == feature)
            {
                newList.Add(list[i]);
            }
        }
        return(newList);
    }