コード例 #1
0
    private IEnumerator GenerateWorld_Random()
    {
        int numTypes = System.Enum.GetValues(typeof(WorldTileType)).Length;

        for (int row = 0; row < _numRows; row++)
        {
            for (int col = 0; col < _numCols; col++)
            {
                WorldTileType tileType = (WorldTileType)(Random.Range(0, numTypes));
                if (col == 0 || col == _numCols - 1)
                {
                    tileType = WorldTileType.Pillar;
                }
                if (row == 0 || row == _numRows - 1)
                {
                    tileType = WorldTileType.Pillar;
                }

                WorldTile tile = GetRootTile(col, row);
                tile.SetTileType(tileType);
            }

            yield return(new WaitForEndOfFrame());
        }
    }
コード例 #2
0
    private IEnumerator InitWorld_Random()
    {
        WorldTile.SetTileColors(
            new Dictionary <WorldTileType, Color>()
        {
            { WorldTileType.Undefined, new Color(0f, 0f, 0f) },
            { WorldTileType.Room, new Color(0.1f, 0.1f, 0.1f) },
            { WorldTileType.Wall, new Color(0.5f, 0.5f, 0.5f) },
            { WorldTileType.Pillar, new Color(1.0f, 1.0f, 1.0f) }
        }
            );

        for (int row = 0; row < _numRows; row++)
        {
            for (int col = 0; col < _numCols; col++)
            {
                //WorldTileConfig tileConfig = _tileSeed.GetTileConfig( col, row );

                WorldTileType tileType = WorldTileType.Undefined;
                if (col == 0 || col == _numCols - 1)
                {
                    tileType = WorldTileType.Pillar;
                }
                if (row == 0 || row == _numRows - 1)
                {
                    tileType = WorldTileType.Pillar;
                }

                WorldTile tile = CreateTile(col, row, tileType);
                _tiles[col, row] = tile;
            }

            yield return(new WaitForEndOfFrame());
        }
    }
コード例 #3
0
    private WorldTile CreateTile(int col, int row, WorldTileType tileType)
    {
        WorldTile tile = new WorldTile(col, row);

        tile.SetTileType(tileType);

        return(tile);
    }
コード例 #4
0
 public static WorldTileTemplate Find(WorldTileType name)
 {
     if (tileTemplate.ContainsKey(name))
     {
         return(tileTemplate[name]);
     }
     return(tileTemplate[WorldTileType.Undefined]);
 }
コード例 #5
0
        public Mission.Mission DecideMission(WorldTileType type, int Wealth)
        {
            List <Mission.Mission> missions = new List <Mission.Mission> {
                new BearMission(), new ElementalWizardFight(), new AttackCampMission(), new SpiderNestMission(), new BanditMission(), new DragonFight()
            };

            missions = missions.Where(m => m.MissionAllowed(type, Wealth)).ToList();
            return(missions.GetRandom());
        }
コード例 #6
0
 protected WorldTileTemplate(WorldTileType name, int movementCost, bool traversable, int healAttrition, int rangeBonus, int accuracyBonus, int defenseBonus)
 {
     Name          = name;
     MovementCost  = movementCost;
     Traversable   = traversable;
     HealAttrition = healAttrition;
     RangeBonus    = rangeBonus;
     AccuracyBonus = accuracyBonus;
     DefenseBonus  = defenseBonus;
 }
コード例 #7
0
        public WorldTile(double Height, WorldTileType type, double cost, Point position, double rainFall)
        {
            height        = Height;
            this.type     = type;
            movementCost  = cost;
            this.position = position;
            switch (type)
            {
            case WorldTileType.Ocean:
                forest = 0;
                break;

            case WorldTileType.River:
                forest = 0;
                break;

            case WorldTileType.TemperateGrassland:
                forest = 10 * (1 + rainFall);
                break;

            case WorldTileType.Rainforest:
                forest = 100;
                break;

            case WorldTileType.Desert:
                forest = 0;
                break;

            case WorldTileType.Tundra:
                forest = 40 * (1 + rainFall);
                break;

            case WorldTileType.TemperateForest:
                forest = 60 * (1 + rainFall / 2);
                break;

            case WorldTileType.Savanna:
                forest = 10 * (1 + rainFall);
                break;

            case WorldTileType.Alpine:
                forest = 20 * (1 + rainFall);
                break;

            case WorldTileType.SeaIce:
                forest = 0;
                break;

            default:
                throw new NotImplementedException();
            }
            forest.Cut(0, 100);
            // TODO: Find a better way to determine these values
            rock = new WorldRockMaterial(80, 0.01, 0.3);
        }
コード例 #8
0
    public static Color GetTileColor(WorldTileType tileType)
    {
        Color color;

        if (!TileColors.TryGetValue(tileType, out color))
        {
            color = Color.magenta;
        }

        return(color);
    }
コード例 #9
0
    private List <WorldTile> GetAdjacentRootTiles(int col, int row, WorldTileType tileType)
    {
        WorldTile        rootTile  = GetRootTile(col, row);
        List <WorldTile> rootTiles = rootTile.GetTileGroup();

//		Debug.Log(" Looking for " + tileType + " adjacent to " + rootTile + " : ");
//		for ( int i = 0; i < rootTiles.Count; i++ )
//			Debug.Log("   --> " + rootTiles[i]);

        List <WorldTile> adjacentRootTiles = new List <WorldTile>();

        for (int i = 0; i < rootTiles.Count; i++)
        {
            WorldTile tile1 = TryGetRootTile(rootTiles[i].Col + 1, rootTiles[i].Row, tileType);
            if (tile1 != null && !rootTiles.Contains(tile1) && !adjacentRootTiles.Contains(tile1))
            {
                adjacentRootTiles.Add(tile1);
            }
//			else
//				Debug.Log(" --- right tile is not added as adjacent");

            WorldTile tile2 = TryGetRootTile(rootTiles[i].Col - 1, rootTiles[i].Row, tileType);
            if (tile2 != null && !rootTiles.Contains(tile2) && !adjacentRootTiles.Contains(tile2))
            {
                adjacentRootTiles.Add(tile2);
            }
//			else
//				Debug.Log(" --- left tile is not added as adjacent : tile2=" + ( tile2 != null ).ToString() + ", rootTiles.Contains( tile2 )=" + rootTiles.Contains( tile2 ).ToString() + ", adjacentTiles.Contains( tile2 )=" + adjacentTiles.Contains( tile2 ) );

            WorldTile tile3 = TryGetRootTile(rootTiles[i].Col, rootTiles[i].Row + 1, tileType);
            if (tile3 != null && !rootTiles.Contains(tile3) && !adjacentRootTiles.Contains(tile3))
            {
                adjacentRootTiles.Add(tile3);
            }
//			else
//				Debug.Log(" --- up tile is not added as adjacent");

            WorldTile tile4 = TryGetRootTile(rootTiles[i].Col, rootTiles[i].Row - 1, tileType);
            if (tile4 != null && !rootTiles.Contains(tile4) && !adjacentRootTiles.Contains(tile4))
            {
                adjacentRootTiles.Add(tile4);
            }
//			else
//				Debug.Log(" --- down tile is not added as adjacent");
        }

        return(adjacentRootTiles);
    }
コード例 #10
0
    private WorldTile TryGetRootTile(int col, int row, WorldTileType tileType)
    {
        WorldTile maybeRootTile = GetRootTile(col, row);

        if (maybeRootTile == null)
        {
//			Debug.Log(" adjacent tile is null~");
            return(null);
        }

        if (maybeRootTile.TileType != tileType)
        {
//			Debug.Log(" adjacent tile is wrong type: " + adjacentTile.TileType );
            return(null);
        }

        return(maybeRootTile);
    }
コード例 #11
0
        public static int GetMinimumHumdity(WorldTileType type)
        {
            switch (type)
            {
            case WorldTileType.Ocean:
                return(300);

            case WorldTileType.River:
                return(120);

            case WorldTileType.TemperateGrassland:
                return(60);

            case WorldTileType.Rainforest:
                return(WindStrength);

            case WorldTileType.Desert:
                return(98);

            case WorldTileType.Tundra:
                return(50);

            case WorldTileType.TemperateForest:
                return(55);

            case WorldTileType.Savanna:
                return(70);

            case WorldTileType.Alpine:
                return(60);

            case WorldTileType.SeaIce:
                return(95);

            default:
                throw new NotImplementedException();
            }
        }
コード例 #12
0
        public static float GetAlebdo(WorldTileType type)
        {
            switch (type)
            {
            case WorldTileType.Ocean:
                return(0.05f);

            case WorldTileType.River:
                return(0.05f);

            case WorldTileType.TemperateGrassland:
                return(0.27f);

            case WorldTileType.Rainforest:
                return(0.15f);

            case WorldTileType.Desert:
                return(0f);    // To increase insolation

            case WorldTileType.Tundra:
                return(0.21f);

            case WorldTileType.TemperateForest:
                return(0.23f);

            case WorldTileType.Savanna:
                return(0.3f);

            case WorldTileType.Alpine:
                return(0.4f);

            case WorldTileType.SeaIce:
                return(0.4f);

            default:
                throw new NotImplementedException();
            }
        }
コード例 #13
0
        public static float GetEvaporationRate(WorldTileType type)
        {
            switch (type)
            {
            case WorldTileType.Ocean:
                return(0.8f);

            case WorldTileType.River:
                return(0.8f);

            case WorldTileType.TemperateGrassland:
                return(0.3f);

            case WorldTileType.Rainforest:
                return(0.5f);

            case WorldTileType.Desert:
                return(0);

            case WorldTileType.Tundra:
                return(0.2f);

            case WorldTileType.TemperateForest:
                return(0.35f);

            case WorldTileType.Savanna:
                return(0.1f);

            case WorldTileType.Alpine:
                return(0.1f);

            case WorldTileType.SeaIce:
                return(0.1f);

            default:
                throw new NotImplementedException();
            }
        }
コード例 #14
0
        public static float GetGroundHeatCapacity(WorldTileType type)
        {
            switch (type)
            {
            case WorldTileType.Ocean:
                return(10);

            case WorldTileType.River:
                return(10);

            case WorldTileType.TemperateGrassland:
                return(6);

            case WorldTileType.Rainforest:
                return(8);

            case WorldTileType.Desert:
                return(2);

            case WorldTileType.Tundra:
                return(3);

            case WorldTileType.TemperateForest:
                return(7);

            case WorldTileType.Savanna:
                return(5);

            case WorldTileType.Alpine:
                return(5);

            case WorldTileType.SeaIce:
                return(8);

            default:
                throw new NotImplementedException();
            }
        }
コード例 #15
0
        public void DetermineBiome()
        {
            WorldTileType oldType = type;
            //Determine average averageTemp and water
            double aTemp    = 0;
            double aWater   = 0;
            int    scanSize = 3;

            for (int y = 0; y < scanSize; y++)
            {
                for (int x = 0; x < scanSize; x++)
                {
                    int lX = (position.X - (x - scanSize / 2)).Cut(0, WORLD_SIZE - 1);
                    int lY = (position.Y - (y - scanSize / 2)).Cut(0, WORLD_SIZE - 1);
                    aTemp  += Instance.worldMap[lX, lY].averageTemp;
                    aWater += Instance.worldMap[lX, lY].landWater;
                }
            }
            aTemp  /= scanSize * scanSize;
            aWater /= scanSize * scanSize;

            if (height < 0.42)
            {
                if (aTemp < 0)
                {
                    type = WorldTileType.SeaIce;
                }
                else
                {
                    type = WorldTileType.Ocean;
                }
                Instance.costMap[position.X, position.Y] = 20;
            }
            else if (height > 0.7)
            {
                type = WorldTileType.Alpine;
                Instance.costMap[position.X, position.Y] = 4;
            }
            else if (aTemp < 5)
            {
                type = WorldTileType.Tundra;
                Instance.costMap[position.X, position.Y] = 2;
            }
            else if (aWater > 40 && aTemp > 15)
            {
                type = WorldTileType.Rainforest;
                Instance.costMap[position.X, position.Y] = 4;
            }
            else if (aWater < 15 && aTemp > 20)
            {
                type = WorldTileType.Desert;
                Instance.costMap[position.X, position.Y] = 3;
            }
            else if (aTemp > 18)
            {
                type = WorldTileType.Savanna;
                Instance.costMap[position.X, position.Y] = 2;
            }
            else if (aWater > 20)
            {
                type = WorldTileType.TemperateForest;
                Instance.costMap[position.X, position.Y] = 1;
            }
            else
            {
                type = WorldTileType.TemperateGrassland;
                Instance.costMap[position.X, position.Y] = 1;
            }
            if (type != oldType)
            {
                Instance.lost[oldType]++;
                Instance.gained[type]++;
                WeatherPoint weatherPoint = Instance.GetAtmosphereValue(position.X, position.Y, 0);
                weatherPoint.baseEvaporationRate = GetEvaporationRate(type);
                weatherPoint.albedo              = GetAlebdo(type);
                weatherPoint.groundHeatCapacity  = GetGroundHeatCapacity(type);
                weatherPoint.baseMinimumHumditiy = GetMinimumHumdity(type);
            }
            landWater = 0;
        }
コード例 #16
0
    private IEnumerator InitWorld_Prim()
    {
        WorldTile.SetTileColors(
            new Dictionary <WorldTileType, Color>()
        {
            { WorldTileType.Undefined, new Color(0f, 0f, 0f) },
            { WorldTileType.Room, new Color(0.8f, 0.9f, 0.8f) },
            { WorldTileType.Wall, new Color(0.2f, 0.2f, 0.2f) },
            { WorldTileType.Pillar, new Color(0.1f, 0.1f, 0.1f) },
            { WorldTileType.WallOpen, new Color(0.8f, 0.9f, 0.8f) },

            { WorldTileType.WallA, new Color(0.2f, 0.1f, 0.1f) },
            { WorldTileType.WallB, new Color(0.1f, 0.2f, 0.1f) },
        }
            );

        // initialize the board with tiles
        for (int row = 0; row < _numRows; row++)
        {
            for (int col = 0; col < _numCols; col++)
            {
                WorldTileConfig tileConfig = _tileSeed.GetTileConfig(col, row);
                WorldTileType   tileType   = tileConfig.TileType;
                if (_numCols > 5)
                {
                    if (tileType == WorldTileType.WallA)
                    {
                        tileType = WorldTileType.Wall;
                    }
                    else if (tileType == WorldTileType.WallB)
                    {
                        tileType = WorldTileType.Wall;
                    }
                }

                // world edges are always pillars
                if (_numCols > 10 && _numRows > 10)
                {
                    if (col == 0 || col == _numCols - 1)
                    {
                        tileType = WorldTileType.Pillar;
                    }
                    else if (row == 0 || row == _numRows - 1)
                    {
                        tileType = WorldTileType.Pillar;
                    }
                }

                WorldTile tile = CreateTile(col, row, tileType);
                _tiles[col, row] = tile;

                // remember where we put the rooms so we can easily choose a random room to start our generation
                if (tile.TileType == WorldTileType.Room)
                {
                    _listRooms.Add(tile);
                }
            }

            // frame limiting
            if (row % _generationRate == 0)
            {
                yield return(new WaitForEndOfFrame());
            }
        }

        //Debug.Log("connecting adjoined tiles...");

        yield return(new WaitForEndOfFrame());

        // connect adjoined tiles
        for (int row = 0; row < _numRows; row++)
        {
            for (int col = 0; col < _numCols; col++)
            {
                WorldTileConfig tileConfig = _tileSeed.GetTileConfig(col, row);
                if (tileConfig.ParentX != 0 || tileConfig.ParentY != 0)
                {
//					Debug.Log(" tile " + col + "x" + row + " is a child of offset (" + tileConfig.ParentX + "," + tileConfig.ParentY + ")");

                    WorldTile parentTile = GetTile(col + tileConfig.ParentX, row + tileConfig.ParentY);
                    if (parentTile != null)
                    {
                        WorldTile childTile = GetTile(col, row);

//						Debug.Log("  >> setting tile " + childTile + " as child of " + parentTile + " ==> (" + tileConfig.ParentX + "," + tileConfig.ParentY + ")");

                        childTile.SetParentTile(parentTile);
                    }
                }
            }

//			yield return new WaitForEndOfFrame();
        }
    }
コード例 #17
0
ファイル: Mission.cs プロジェクト: quajak/StartGame
 public override bool MissionAllowed(WorldTileType type, int wealth)
 {
     return(type == WorldTileType.TemperateForest || type == WorldTileType.TemperateGrassland || type == WorldTileType.Alpine);
 }
コード例 #18
0
 public WorldTileConfig(WorldTileType tileType, int xParent, int yParent)
 {
     _tileType = tileType;
     _xParent  = xParent;
     _yParent  = yParent;
 }
コード例 #19
0
ファイル: Mission.cs プロジェクト: quajak/StartGame
 public override bool MissionAllowed(WorldTileType type, int wealth)
 {
     return(type == WorldTileType.TemperateForest);
 }
コード例 #20
0
ファイル: Mission.cs プロジェクト: quajak/StartGame
 public override bool MissionAllowed(WorldTileType type, int wealth)
 {
     return(wealth > 30);
 }
コード例 #21
0
ファイル: Mission.cs プロジェクト: quajak/StartGame
 public override bool MissionAllowed(WorldTileType type, int wealth)
 {
     return(type != WorldTileType.Ocean);
 }
コード例 #22
0
ファイル: Mission.cs プロジェクト: quajak/StartGame
 public override bool MissionAllowed(WorldTileType type, int wealth)
 {
     return(type == WorldTileType.Alpine);
 }
コード例 #23
0
ファイル: Mission.cs プロジェクト: quajak/StartGame
 public abstract bool MissionAllowed(WorldTileType type, int wealth);
コード例 #24
0
 public WorldTileConfig(WorldTileType tileType)
 {
     _tileType = tileType;
     _xParent  = 0;
     _yParent  = 0;
 }
コード例 #25
0
    public void SetTileType(WorldTileType tileType)
    {
        _tileType = tileType;

//		SetColor( GetTileColor( tileType ) );
    }