コード例 #1
0
        public IEnumerator RepairAttractionWithMoneyButNoAvaliableMechanics()
        {
            test = false;
            List <Vector2Int> positionList =
                wcObject.GetPositionList(new Vector2Int(0, 0), BuildingTypeSO.Direction.Down);

            gameManager.Money = 99999;
            Building wc = Building.SpawnBuilding(Vector3.zero, new Vector2Int(0, 0), BuildingTypeSO.Direction.Down, wcObject, positionList);

            yield return(new WaitForSeconds(0.1f));

            Attraction help  = (Attraction)wc;
            GameObject empty = new GameObject();

            help.brokeVisual = empty.transform;
            help.BreakBuilding();
            yield return(new WaitForSeconds(0.1f));

            gameManager.RepairAttraction((Attraction)(wc));
            yield return(new WaitForSeconds(0.1f));

            Assert.AreEqual(99999, gameManager.Money);
        }
コード例 #2
0
        public IEnumerator UpgradeAttractionWithMoney()
        {
            List <Vector2Int> positionList =
                wcObject.GetPositionList(new Vector2Int(0, 0), BuildingTypeSO.Direction.Down);

            gameManager.Money = 9999;
            Building wc = Building.SpawnBuilding(Vector3.zero, new Vector2Int(0, 0), BuildingTypeSO.Direction.Down, wcObject, positionList);

            yield return(new WaitForSeconds(0.1f));

            Attraction help  = (Attraction)wc;
            GameObject empty = new GameObject();

            help.brokeVisual = empty.transform;
            help.BreakBuilding();
            yield return(new WaitForSeconds(0.1f));

            bool helpBool = gameManager.UpgradeBuilding((Attraction)(wc));

            yield return(new WaitForSeconds(0.1f));

            Assert.IsFalse(false);
        }
コード例 #3
0
    private void UpdateProperties()
    {
        if (testMode)
        {
            return;
        }
        foreach (Building building in this.buildingSystem.Buildings)
        {
            if (building.Type.type == BuildingTypeSO.Type.Attraction)
            {
                Attraction current = (Attraction)building;
                this.money -= current.Upkeep;
                this.money += current.Income;

                float rand_float = Random.Range(0f, 1f);
                if (rand_float < current.BreakChance)
                {
                    current.BreakBuilding();
                }
            }
        }


        this.money -= (mechanicSalary * totalMechanics);

        //Calculate trash level

        trashLevel += currentVisitors * 0.2f / 24f / 60f;

        trashLevel -= NavigationManager.instance.reachableTrashBinCount * 3 * 0.2f / 24f / 60f;

        foreach (Janitor janitor in this.janitors)
        {
            this.money -= janitor.Salary;
            trashLevel -= 0.2f / 24f / 60f * 15;
        }


        if (this.trashLevel > this.TotalCapacity)
        {
            this.trashLevel = this.TotalCapacity;
        }

        if (trashLevel < 0)
        {
            trashLevel = 0;
        }

        if (this.TotalCapacity == 0)
        {
            this.trashPercentage = 0;
        }
        else
        {
            this.trashPercentage = this.trashLevel / this.TotalCapacity;
        }

        this.totalHappiness = 1f - this.trashPercentage;

        if (currentVisitors > 0)
        {
            if (Random.Range(0f, 1f) <= totalHappiness / 60f / 12f)
            {
                float extraMoney = currentVisitors * Random.Range(0.9f, 1.8f);
                money += extraMoney;
                EventManager.instance.HappinessMoney(extraMoney);
            }
        }
    }