Beispiel #1
0
 void Start()
 {
     //tp = FindObjectOfType<TerrestrialPainter>();
     tf        = FindObjectOfType <TerrainFeatures>();
     canvasCam = GameObject.FindGameObjectWithTag("CanvasCam").transform;
     planet    = GameObject.FindGameObjectWithTag("Planet").transform;
 }
Beispiel #2
0
        public override int Effect(Deity creator)
        {
            TerrainFeatures terrain = WeightedObjects <TerrainFeatures> .ChooseRandomObject(potential_construction_sites(), rnd);

            Building building = new Building(null, creator, _type);

            building.Terrain = terrain;
            building.Effect();

            terrain.Buildings.Add(building);

            return(0);
        }
Beispiel #3
0
        public void AddRecord(TerrainFeatures terrain, PrintFunction print)
        {
            Record record = new Record();

            record.Type    = RecordType.CreateTerrainFeature;
            record.Terrain = terrain;

            record.Turn = Simulation.Time.Turn;
            record.Year = Simulation.Time.Shuffle;

            record.printFunction = print;
            Records.Add(record);
        }
Beispiel #4
0
        public override int Effect(Deity creator)
        {
            // Choose the city location at random.
            TerrainFeatures construction_site = _valid_city_terrains[rnd.Next(_valid_city_terrains.Count)];

            // The city is created and placed in the world. The nation is defined as the city owner.
            City founded_city = new City("PlaceHolder", creator);

            founded_city.TerrainFeature = construction_site;
            founded_city.Owner          = _commanded_nation;

            // Tell the location, that it now has a city.
            construction_site.City = founded_city;

            // add the city to the list of cities owned by the nation.
            _commanded_nation.Cities.Add(founded_city);

            //New War Goal to conquer this city.
            _commanded_nation.PossibleWarGoals.Add(new WarGoal(WarGoalType.CityConquest));
            _commanded_nation.PossibleWarGoals.Last().City = founded_city;

            founded_city.Name = Program.GenerateNames.GetName("city_names");

            // Add city related powers and the creator
            creator.FoundedCities.Add(founded_city);
            creator.Powers.Add(new RaiseArmy(founded_city));
            creator.Powers.Add(new ConstructBuilding(founded_city, BuildingType.CityWall));
            creator.Powers.Add(new ConstructBuilding(founded_city, BuildingType.Temple));
            creator.Powers.Add(new ConstructBuilding(founded_city, BuildingType.Shrine));

            creator.LastCreation = founded_city;

            //Program.WorldHistory.AddRecord(founded_city);

            return(0);
        }
Beispiel #5
0
    public AudioClip[] placeAudioClips;  // 0 drop-tree, 1 cactus-plant, 2 island-place, 3 snow-good,
                                         // 4 grass-good, 5 rocks-falling, 6 basic-thud, 7 sand-disperse
                                         // 8 digital-water, 9 pouring-sand

    void Start()
    {
        tf         = GetComponent <TerrainFeatures>();
        planet     = GameObject.FindGameObjectWithTag("Planet");
        selectedGO = biomes[selectedBiome]; // default
    }
 public void RegisterTerrainFeature(Func <IDeepWoodsLocation, Vector2, bool> decisionCallback, Func <TerrainFeature> creationCallback)
 {
     TerrainFeatures.Add(Tuple.Create(decisionCallback, creationCallback));
 }
        public override int Effect(Deity creator)
        {
            // Create the river
            River river = new River(Program.GenerateNames.GetName("river_names"), SelectedProvince, creator);

            river.BiomeType = BiomeType.PermanentRiver;
            river.Spring    = (MountainRange)SelectedProvince.PrimaryTerrainFeature;
            river.Riverbed.Add(river.Spring.Province);

            // the primary direction of the river.
            Array     directions        = Enum.GetValues(typeof(Direction));
            Direction primary_direction = (Direction)directions.GetValue(rnd.Next(directions.Length));

            Direction[] other_directions = new Direction[2];
            switch (primary_direction)
            {
            case Direction.North:
                other_directions[0] = Direction.East;
                other_directions[1] = Direction.West;
                break;

            case Direction.East:
                other_directions[0] = Direction.South;
                other_directions[1] = Direction.North;
                break;

            case Direction.South:
                other_directions[0] = Direction.East;
                other_directions[1] = Direction.West;
                break;

            case Direction.West:
                other_directions[0] = Direction.North;
                other_directions[1] = Direction.South;
                break;
            }

            bool[] not_taken_other_direction = new bool[2] {
                true, true
            };

            Province current_location          = SelectedProvince;
            bool     not_has_found_destination = true;

            while (not_has_found_destination)
            {
                // Check if there are any lakes and/or rivers in this area, then let this new river flow into a random one.
                if (current_location.SecondaryTerrainFeatures.Exists(x => x.GetType() == typeof(Lake)) ||
                    current_location.SecondaryTerrainFeatures.Exists(y => y.GetType() == typeof(River)))
                {
                    List <TerrainFeatures> lakes_and_rivers = current_location.SecondaryTerrainFeatures.FindAll(x => x.GetType() == typeof(Lake) || x.GetType() == typeof(River));
                    TerrainFeatures        destination      = lakes_and_rivers[rnd.Next(lakes_and_rivers.Count)];

                    if (typeof(Lake) == destination.GetType())
                    {
                        river.DestinationLake = (Lake)destination;
                        ((Lake)destination).SourceRivers.Add(river);
                    }
                    else
                    {
                        river.DestinationRiver = (River)destination;
                        ((River)destination).SourceRivers.Add(river);
                    }

                    not_has_found_destination = false;
                }
                else
                {
                    // else go towards terrain...
                    int       chance         = rnd.Next(100);
                    Direction next_direction = Direction.North;
                    // ...straight in primary direction
                    if (chance < 50)
                    {
                        next_direction = primary_direction;
                        not_taken_other_direction[0] = true;
                        not_taken_other_direction[1] = true;
                    }
                    // ... turn clock-wise from primary direction
                    else if (chance < 75 && not_taken_other_direction[0])
                    {
                        next_direction = other_directions[0];
                        not_taken_other_direction[1] = false;
                    }
                    // ... turn counter-clock-wise from primary direction
                    else if (chance < 100 && not_taken_other_direction[1])
                    {
                        next_direction = other_directions[1];
                        not_taken_other_direction[0] = false;
                    }

                    SystemCoordinates coords = null;
                    switch (next_direction)
                    {
                    case Direction.North:
                        coords = current_location.Coordinates.North;
                        break;

                    case Direction.East:
                        coords = current_location.Coordinates.East;
                        break;

                    case Direction.South:
                        coords = current_location.Coordinates.South;
                        break;

                    case Direction.West:
                        coords = current_location.Coordinates.West;
                        break;
                    }


                    if (coords.isInTileGridBounds())
                    {
                        // Assign next location
                        current_location = Program.State.ProvinceGrid[coords.X, coords.Y];
                    }
                    else
                    {
                        current_location = null;
                    }

                    if (current_location != null)
                    {
                        // if that new area is ocean the river ends here.
                        if (current_location.Type == TerrainType.Ocean || current_location.Type == TerrainType.Island)
                        {
                            river.Riverbed.Add(current_location);
                            river.Destination         = current_location;
                            not_has_found_destination = false;
                        }
                        // otherwise the river runs further.
                        else
                        {
                            river.Riverbed.Add(current_location);
                        }
                    }
                    else // if current location is null then the border of the map has been found and the river ends in unknown land.
                    {
                        river.Destination      = new Province(null, null);
                        river.Destination.Type = TerrainType.Unknown;
                        river.Destination.Name = "Unknown Land";
                        river.Riverbed.Add(river.Destination);
                        not_has_found_destination = false;
                    }
                }
            }

            // Add river to terrains at the end in order to avoid the river ending in itself.
            foreach (Province province in river.Riverbed)
            {
                if (province.Type != TerrainType.Unknown)
                {
                    province.SecondaryTerrainFeatures.Add(river);
                }
            }

            river.Modifiers.NaturalDefenceValue += 1;

            // Add river to deity list.
            creator.TerrainFeatures.Add(river);
            creator.LastCreation = river;

            Program.WorldHistory.AddRecord(river, river.printTerrainFeature);

            return(0);
        }