コード例 #1
0
        public void BuildingUpgrade()
        {
            if (!healthScript)
            {
                healthScript = GetComponent <HealthScript>();
            }

            if (!grabBuildingStats)
            {
                grabBuildingStats = GameObject.FindGameObjectWithTag("SellMenu").GetComponent <GrabBuildingStats>();
            }

            Level++;
            Damage                       += Damage / 2;
            AttackCoolDown               -= AttackCoolDown / 3;
            AttackRange                  += AttackRange / 4;
            healthScript.MaxHealth       += healthScript.MaxHealth / 2;
            healthScript.HealthGenAmount += healthScript.HealthGenAmount / 2;

            Gold  += Gold;
            Wood  += Wood;
            Stone += Stone;

            CalculateRepairCosts();
            grabBuildingStats.SellMenuStats();
        }
コード例 #2
0
        public void CalculateRepairCosts()
        {
            if (!healthScript)
            {
                healthScript = GetComponent <HealthScript>();
            }

            if (!grabBuildingStats)
            {
                grabBuildingStats = GameObject.FindGameObjectWithTag("SellMenu").GetComponent <GrabBuildingStats>();
            }

            float healthGainPerWood  = healthScript.MaxHealth / Wood;
            float healthGainPerStone = healthScript.MaxHealth / Stone;

            float repairHealth = healthScript.MaxHealth - healthScript.CurrentHealth;

            WoodRepairCost  = Mathf.RoundToInt(repairHealth / healthGainPerWood);
            StoneRepairCost = Mathf.RoundToInt(repairHealth / healthGainPerStone);

            if (!healthScript.IsAlive)
            {
                Destroy(gameObject);
            }

            grabBuildingStats.UpdateRepairCostAndHealth();
        }
コード例 #3
0
ファイル: GridSystem.cs プロジェクト: Michael97/Base-Defence
    void Start()
    {
        GrabBuildingStats = SellMenu.GetComponent <GrabBuildingStats>();
        SelectedBuilding  = PrefabBase;

        gameControllerScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControllerScript>();
        grabPlayerStats      = GameObject.FindGameObjectWithTag("PlayerStats").GetComponent <GrabPlayerStats>();
    }