Exemplo n.º 1
0
    private void SpawnInnerCityHouse()
    {
        var candidates = new List <Tuple <Block, Block> >();

        foreach (var bigHouse in _worldPlane.GetBlocksWithHousesStream())
        {
            if (!bigHouse.GetOccupantHouse().IsBig())
            {
                continue;
            }

            foreach (var nearbyVacantLot in _worldPlane.GetNearbyVacantLotsStream(bigHouse.GetGridPosition()))
            {
                candidates.Add(new Tuple <Block, Block>(bigHouse, nearbyVacantLot));
            }
        }

        if (candidates.Count > 0)
        {
            var(bigHouse, vacantLot) = candidates.ElementAt(Random.Range(0, candidates.Count));
            var house = Instantiate(tinyHouseTemplate);
            house.GetComponent <HouseSpawn>().SetIsInnerCity();
            vacantLot.Occupy(house);

            var target = bigHouse.transform.position;
            target.y = house.transform.position.y;
            house.transform.LookAt(target);

            _lastPlacedInnerCityHouse = Time.fixedTime;
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        if (!_featureToggles.fort)
        {
            return;
        }
        if (!CanWorkThisFrame())
        {
            return;
        }

        if (_fortCount > 1)
        {
            return;
        }
        var houseCount = _worldPlane.GetBlocksWithHousesStream().Count();

        if (houseCount < 3)
        {
            return;
        }

        if (Random.value < .001f)
        {
            TrySpawnFort();
        }
    }
Exemplo n.º 3
0
    public bool CanManuallyConstructAnyKindOfFarm()
    {
        // TODO: Make Farms grow slowly over time. That why you can take your time with the game and not just speed build.
        float houseCount = _worldPlane.GetBlocksWithHousesStream().Count();

        return(houseCount >= City.SelfSustainedHouses);
    }