Exemplo n.º 1
0
        public void RefreshWeaponsPowerUsage()
        {
            for (int i = 0; i < GameManager.shipWeapons.Count; i++)
            {
                GameObject weapon           = weapons.transform.GetChild(i).gameObject;
                Weaponry   shipWeapon       = GameManager.shipWeapons[i].GetComponent <Weaponry>();
                PowerUsage weaponPowerUsage = weapon.GetComponent <PowerUsage>();

                // if weapon is damaged, turn icon red
                if (shipWeapon.IsDamaged)
                {
                    weaponPowerUsage.iconGO.GetComponent <Image>().color = weapon.GetComponent <Image>().color = damagedColor;
                }
                else
                {
                    weaponPowerUsage.iconGO.GetComponent <Image>().color = weapon.GetComponent <Image>().color = NORMAL_COLOR;
                }

                weaponPowerUsage.maxUsage  = GameManager.ship.WeaponsRoom.weaponsEquipped[i].powerConsumption;
                weaponPowerUsage.usage     = shipWeapon.powerConsumption;
                weaponPowerUsage.IsPowered = shipWeapon.IsPowered;
                weaponPowerUsage.RefreshPowerUsageUI(shipWeapon);
            }

            // refresh power value
            powerValueTxt      = powerValue.GetComponent <TMPro.TextMeshProUGUI>();
            powerValueTxt.text = playerShip.reactor.ToString();
        }
Exemplo n.º 2
0
        public void RefreshSystemsPowerUsage()
        {
            for (int i = 0; i < GameManager.shipSystems.Count; i++)
            {
                int childCount = systemPanel.transform.childCount;

                ShipSystem shipSystem = GameManager.shipSystems[i].GetComponent <ShipSystem>();

                GameObject systemButton = systemPanel.transform.GetChild(i).gameObject;

                PowerUsage systemPowerUsage = systemButton.GetComponent <PowerUsage>();

                //if system is damaged, turn icon red
                if (shipSystem.IsDamaged)
                {
                    systemPowerUsage.iconGO.GetComponent <Image>().color = systemButton.GetComponent <Image>().color = damagedColor;
                }
                else
                {
                    systemPowerUsage.iconGO.GetComponent <Image>().color = systemButton.GetComponent <Image>().color = NORMAL_COLOR;
                }

                if (systemPowerUsage != null)
                {
                    systemPowerUsage.usage     = shipSystem.powerConsumption;
                    systemPowerUsage.IsPowered = shipSystem.IsPowered;
                    systemPowerUsage.RefreshPowerUsageUI(shipSystem);
                }
                else
                {
                    Debug.LogError(shipSystem.name + " is missing the power usage component");
                }
            }

            // refresh power value
            powerValueTxt      = powerValue.GetComponent <TMPro.TextMeshProUGUI>();
            powerValueTxt.text = playerShip.reactor.ToString();
        }