Beispiel #1
0
    private void RefreshCargoSpace(List <InvItemData> source, float maxSpace)
    {
        float usage = 0;

        foreach (InvItemData itemData in source)
        {
            usage += itemData.Item.CargoUnits * itemData.Quantity;
        }

        AvailableCargoSpaceValue = Mathf.Clamp(maxSpace - usage, 0, maxSpace);
        AvailableCargoSpace.text = Mathf.CeilToInt(AvailableCargoSpaceValue).ToString();
        CargoSpace.SetFillPercentage(Mathf.Clamp01(usage / maxSpace));
    }
Beispiel #2
0
    private void UpdateWeaponCapacitorAmount()
    {
        float totalCapacitor   = GameManager.Inst.PlayerControl.PlayerShip.WeaponCapacitor.Capacity;
        float currentCapacitor = GameManager.Inst.PlayerControl.PlayerShip.WeaponCapacitor.Amount;

        if (totalCapacitor > 0)
        {
            WeaponCapacitorIndicator.SetFillPercentage(currentCapacitor / totalCapacitor);
        }
        else
        {
            WeaponCapacitorIndicator.SetFillPercentage(0);
        }
    }
Beispiel #3
0
    private void UpdateHullAmount()
    {
        float totalHull   = GameManager.Inst.PlayerControl.PlayerShip.HullCapacity;
        float currentHull = GameManager.Inst.PlayerControl.PlayerShip.HullAmount;

        HullAmountIndicator.SetFillPercentage(currentHull / totalHull);
        HullAmount.text = Mathf.FloorToInt(currentHull).ToString();
    }
Beispiel #4
0
    private void UpdateShieldAmount()
    {
        ShieldBase shieldBase = GameManager.Inst.PlayerControl.PlayerShip.Shield;

        if (shieldBase != null && shieldBase.Type == ShieldType.Fighter)
        {
            FighterShield shield = (FighterShield)shieldBase;
            ShieldAmountIndicator.SetFillPercentage(shield.GetShieldPercentage());
            ShieldAmount.text = Mathf.FloorToInt(shield.Amount).ToString();
        }
        else if (shieldBase != null && shieldBase.Type == ShieldType.BigShip)
        {
            BigShipShield shield = (BigShipShield)shieldBase;
            ShieldAmountIndicator.SetFillPercentage(shield.GetShieldPercentage());
            ShieldAmount.text = Mathf.FloorToInt(shield.Amount).ToString();
        }
    }
Beispiel #5
0
    public void RefreshProposedCargoUsage(float additionalUsage)
    {
        if (ProposedCargoUsage != null)
        {
            UISprite indicatorSprite = ProposedCargoUsage.GetComponent <UISprite>();
            if (additionalUsage >= 0)
            {
                indicatorSprite.depth = 9;
            }
            else
            {
                indicatorSprite.depth = 11;
            }

            if (InventoryType == InventoryType.CargoBay)
            {
                float maxSpace = GameManager.Inst.ItemManager.AllShipStats[CurrentLoadout.ShipID].CargoBaySize;
                float newUsage = additionalUsage + (maxSpace - AvailableCargoSpaceValue);
                if (newUsage <= maxSpace)
                {
                    indicatorSprite.color = new Color(1, 0.75f, 0);
                    ProposedCargoUsage.SetFillPercentage(Mathf.Clamp01(newUsage / maxSpace));
                }
                else
                {
                    indicatorSprite.color = new Color(1, 0, 0);
                    ProposedCargoUsage.SetFillPercentage(1);
                }
            }
            else if (InventoryType == InventoryType.AmmoBay)
            {
                float maxSpace = GameManager.Inst.ItemManager.AllShipStats[CurrentLoadout.ShipID].AmmoBaySize;
                float newUsage = additionalUsage + (maxSpace - AvailableAmmoSpaceValue);
                if (newUsage <= maxSpace)
                {
                    ProposedCargoUsage.GetComponent <UISprite>().color = new Color(1, 0.75f, 0);
                    ProposedCargoUsage.SetFillPercentage(Mathf.Clamp01(newUsage / maxSpace));
                }
                else
                {
                    ProposedCargoUsage.GetComponent <UISprite>().color = new Color(1, 0, 0);
                    ProposedCargoUsage.SetFillPercentage(1);
                }
            }
        }
    }
    public void Refresh()
    {
        Debug.Log("Current loadout id: " + CurrentLoadout.LoadoutID);
        List <InvItemData> loadoutEquipment = new List <InvItemData>();

        loadoutEquipment.Add(CurrentLoadout.Shield);
        loadoutEquipment.Add(CurrentLoadout.WeaponCapacitor);
        loadoutEquipment.Add(CurrentLoadout.Thruster);
        loadoutEquipment.Add(CurrentLoadout.Scanner);
        loadoutEquipment.Add(CurrentLoadout.Teleporter);
        EquipmentInventory.Initialize(loadoutEquipment);

        //hide mod slots beyond what ship has
        int numberSlots = GameManager.Inst.ItemManager.AllShipStats[CurrentLoadout.ShipID].ModSlots;

        for (int i = 0; i < ShipModsInventory.ItemEntries.Count; i++)
        {
            if (i < numberSlots)
            {
                NGUITools.SetActive(ShipModsInventory.ItemEntries[i].gameObject, true);
            }
            else
            {
                NGUITools.SetActive(ShipModsInventory.ItemEntries[i].gameObject, false);
            }
        }
        //here add all the mods to loadoutEquipment
        List <InvItemData> loadoutShipMods = new List <InvItemData>();

        for (int i = 0; i < CurrentLoadout.ShipMods.Length; i++)
        {
            loadoutShipMods.Add(CurrentLoadout.ShipMods[i]);
        }
        ShipModsInventory.Initialize(loadoutShipMods);

        //now get power usage
        float powerUsageEquipment = CalculatePowerUsage(loadoutEquipment);
        float powerUsageShipMods  = CalculatePowerUsage(loadoutShipMods);
        float powerUsage          = powerUsageEquipment + powerUsageShipMods;
        float totalPower          = GameManager.Inst.ItemManager.AllShipStats[CurrentLoadout.ShipID].PowerSupply;

        _availablePower = totalPower - powerUsage;
        PowerUsage.SetFillPercentage(powerUsage / totalPower);
        AvailablePower.text = _availablePower.ToString();

        ShipInventorySheet.InventoryItemTypes.Clear();
        ShipInventorySheet.InventoryItemTypes.Add(ItemType.Equipment);
        ShipInventorySheet.InventoryItemTypes.Add(ItemType.ShipMod);
        ShipInventorySheet.Refresh();
        ShipInventorySheet.RefreshLoadButtons(null);
        ClearSelections();
    }
Beispiel #7
0
    private void UpdateCruisePrep()
    {
        float prepPercent = GameManager.Inst.PlayerControl.PlayerShip.Engine.PrepPercent;

        if (prepPercent <= 0 || prepPercent >= 0.99f)
        {
            CruisePrepIndicator.Frame.alpha = 0;
        }
        else
        {
            CruisePrepIndicator.Frame.alpha = 0.7f;
        }
        CruisePrepIndicator.SetFillPercentage(prepPercent);
    }
    private void RefreshHangarSpace(HomeStationData homeStationData, List <InvItemData> hangarItems)
    {
        if (homeStationData == null)
        {
            AvailableHangarSpaceValue = 0;
            HangarSpace.SetFillPercentage(1);
            AvailableHangarSpace.text = "0";

            return;
        }

        int   totalHangarSpace = homeStationData.HangarSize;
        float usedSpace        = 0;

        foreach (InvItemData itemData in hangarItems)
        {
            usedSpace += itemData.Item.GetIntAttribute("Hangar Units");
        }

        AvailableHangarSpaceValue = totalHangarSpace - usedSpace;
        HangarSpace.SetFillPercentage(usedSpace / totalHangarSpace);
        AvailableHangarSpace.text = AvailableHangarSpaceValue.ToString();
    }
Beispiel #9
0
    private void RefreshVaultSpace(HomeStationData homeStationData, List <InvItemData> vaultItems)
    {
        if (homeStationData == null)
        {
            AvailableVaultSpaceValue = 0;
            VaultSpace.SetFillPercentage(1);
            AvailableVaultSpace.text = "0";

            return;
        }

        int   totalVaultSpace = homeStationData.VaultSize;
        float usedSpace       = 0;

        foreach (InvItemData itemData in vaultItems)
        {
            usedSpace += itemData.Item.CargoUnits * itemData.Quantity;
        }

        AvailableVaultSpaceValue = Mathf.Clamp(totalVaultSpace - usedSpace, 0, homeStationData.VaultSize);
        VaultSpace.SetFillPercentage(Mathf.Clamp01(usedSpace / totalVaultSpace));
        AvailableVaultSpace.text = Mathf.CeilToInt(AvailableVaultSpaceValue).ToString();
    }
    public void SetPowerPercentageFromButtonPos(Vector3 buttonLocalPos)
    {
        float shieldDist = Vector3.Distance(buttonLocalPos, ShieldTarget.localPosition);
        float weaponDist = Vector3.Distance(buttonLocalPos, WeaponTarget.localPosition);
        float EngineDist = Vector3.Distance(buttonLocalPos, EngineTarget.localPosition);

        float total = shieldDist + weaponDist + EngineDist;

        Debug.Log(shieldDist + "/" + total);
        float shieldPower = 1 - shieldDist / total;
        float weaponPower = 1 - weaponDist / total;
        float enginePower = 1 - EngineDist / total;

        ShieldPowerInd.SetFillPercentage(shieldPower);
        WeaponPowerInd.SetFillPercentage(weaponPower);
        EnginePowerInd.SetFillPercentage(enginePower);
        //Debug.Log(shieldPower + " " + weaponPower + " " + enginePower);

        GameManager.Inst.PlayerControl.PlayerShip.ShieldPowerAlloc = shieldPower * 1.5f;
        GameManager.Inst.PlayerControl.PlayerShip.WeaponPowerAlloc = weaponPower * 1.5f;
        GameManager.Inst.PlayerControl.PlayerShip.EnginePowerAlloc = enginePower * 1.5f;
    }
Beispiel #11
0
    public void Refresh()
    {
        string    shipID = CurrentLoadout.ShipID;
        ShipStats stats  = GameManager.Inst.ItemManager.GetShipStats(shipID);

        ShipName.text        = stats.DisplayName;
        ShipDescription.text = stats.Description;
        if (ShipImage != null)
        {
            GameObject.Destroy(ShipImage.gameObject);
        }
        ShipImage = GameManager.Inst.UIManager.LoadUISprite("ShipIcon" + shipID, ShipImageAnchor.transform, 230, 172, 10);



        float hullAmountPercent = 0;
        float fuelAmountPercent = 0;
        float lsAmountPercent   = 0;

        if (GameManager.Inst.SceneType == SceneType.Space)
        {
            hullAmountPercent = GameManager.Inst.PlayerControl.PlayerShip.HullAmount / GameManager.Inst.PlayerControl.PlayerShip.HullCapacity;
            fuelAmountPercent = GameManager.Inst.PlayerControl.PlayerShip.FuelAmount / GameManager.Inst.PlayerControl.PlayerShip.MaxFuel;
            lsAmountPercent   = GameManager.Inst.PlayerControl.PlayerShip.LifeSupportAmount / GameManager.Inst.PlayerControl.PlayerShip.MaxLifeSupport;
        }
        else if (GameManager.Inst.SceneType == SceneType.Station)
        {
            hullAmountPercent = CurrentLoadout.HullAmount / GameManager.Inst.ItemManager.GetShipStats(CurrentLoadout.ShipID).Hull;
            fuelAmountPercent = CurrentLoadout.FuelAmount / GameManager.Inst.ItemManager.GetShipStats(CurrentLoadout.ShipID).MaxFuel;
            lsAmountPercent   = CurrentLoadout.LifeSupportAmount / GameManager.Inst.ItemManager.GetShipStats(CurrentLoadout.ShipID).LifeSupport;
        }

        HullIndicator.SetFillPercentage(hullAmountPercent);
        FuelIndicator.SetFillPercentage(fuelAmountPercent);
        LifeSupportIndicator.SetFillPercentage(lsAmountPercent);
    }