Exemple #1
0
    public void SetCurrEnergy(float TankEnergy, bool wrapped)
    {
        tankEnergy = TankEnergy;

        cEnergyBar.SetCurrEnergy(tankEnergy, tankEnergy == 0f ? hudEnergyBar.ESetMode.Insta : wrapped == true ? hudEnergyBar.ESetMode.Wrapped : hudEnergyBar.ESetMode.Normal);
        updateEnergyBarCurrEnergy(wrapped);
    }
Exemple #2
0
 public void SetBossParams(bool Visible, string name, string subtitle, float curenerg, float maxenerg)
 {
     //calculateMode = calculate;
     visible = Visible;
     if (Visible)
     {
         bossBar.SetFilledDrainSpeed(maxenerg);
         bossBar.SetCurrEnergy(curenerg, hudEnergyBar.ESetMode.Normal);
         bossBar.SetMaxEnergy(maxenerg);
         textBoss.text    = name;
         textBossSub.text = subtitle;
     }
     curEnergy = curenerg;
     maxEnergy = maxenerg;
     bossIni   = true;
 }
Exemple #3
0
 void updateEnergyBarCurrEnergy(bool Wrapped)
 {
     combatEnergyBar.SetCurrEnergy(tankEnergy, tankEnergy == 0f ? hudEnergyBar.ESetMode.Insta : Wrapped == true ? hudEnergyBar.ESetMode.Wrapped : hudEnergyBar.ESetMode.Normal);
     ballEnergyBar.SetCurrEnergy(tankEnergy, tankEnergy == 0f ? hudEnergyBar.ESetMode.Insta : Wrapped == true ? hudEnergyBar.ESetMode.Wrapped : hudEnergyBar.ESetMode.Normal);
 }
Exemple #4
0
    public void UpdateHud(float dt)
    {
        if (missileCapacity < 1)
        {
            if (missileIcon.enabled)
            {
                missileIcon.enabled = false;
            }
        }
        else
        {
            if (!missileIcon.enabled)
            {
                missileIcon.enabled = true;
            }
        }

        if (missileIconIncrement < 0f)
        {
            missileIconIncrement -= 3f * dt;
            if (missileIconIncrement <= -1f)
            {
                missileIconIncrement = 1f;
            }
        }
        else if (missileIconIncrement > 0f)
        {
            missileIconIncrement = Mathf.Max(0f, missileIconIncrement - dt);
        }

        Color addColor = hudColors.missileIconColorActive * missileIconIncrement;

        if (missileIconAltDeplete > 0f)
        {
            missileIcon.color = Color.Lerp(hudColors.missileIconColorInactive, hudColors.missileIconDepleteAlt, missileIconAltDeplete) + addColor;
        }
        else
        {
            if (hasAlt)
            {
                if (numMissiles > 5)
                {
                    missileIcon.color = hudColors.missileIconColorCanAlt + addColor;
                }
                else
                {
                    missileIcon.color = hudColors.missileIconColorNoAlt + addColor;
                }
            }
            else
            {
                // Color lerp2Test = Color.Lerp(hudColors.missileIconColorInactive, hudColors.missileIconColorActive, iconLerp);
                if (missilesActive)
                {
                    missileIcon.color = hudColors.missileIconColorActive + addColor;
                }
                //missileIcon.color = lerp2Test + addColor;
                else
                {
                    missileIcon.color = hudColors.missileIconColorInactive + addColor;
                }
                //missileIcon.color = lerp1Test + addColor;
                //if (iconLerp < 1 && missilesActive) {
                //missileIcon.color = lerp2Test + addColor;
                //    if (rIconLerp != 0)
                //        rIconLerp = 0;
                //}
                //if (!missilesActive)
                //{
                //    getReverseIconLerp();
                //    Color lerp1Test = Color.Lerp(hudColors.missileIconColorActive, hudColors.missileIconColorInactive, rIconLerp);
                //    missileIcon.color = lerp1Test + addColor;
                //}
            }
        }


        missileIconAltDeplete = Mathf.Max(0f, missileIconAltDeplete - dt);

        missileBar.SetMaxEnergy(missileCapacity);
        missileBar.SetCurrEnergy(numMissiles, hudEnergyBar.ESetMode.Normal);

        missileIcon.transform.localPosition = new Vector3(0f, numMissiles * IconTranslateRange / (float)missileCapacity, 0f);
        if (hasArrows)
        {
            if (arrowTimer > 0f)
            {
                arrowTimer = Mathf.Max(0f, arrowTimer - dt);
                Color color = hudColors.missileIconColorActive;
                color.a      *= arrowTimer / 0.5f;
                arrowUp.color = color;
                if (!arrowUp.enabled)
                {
                    arrowUp.enabled = true;
                }
                if (arrowDown.enabled)
                {
                    arrowDown.enabled = false;
                }
            }
            else if (arrowTimer < 0f)
            {
                arrowTimer = Mathf.Min(0f, arrowTimer + dt);
                Color color = hudColors.missileIconColorActive;
                color.a        *= -arrowTimer / 0.5f;
                arrowDown.color = color;
                if (!arrowDown.enabled)
                {
                    arrowDown.enabled = true;
                }
                if (arrowUp.enabled)
                {
                    arrowUp.enabled = false;
                }
            }
            else
            {
                //if (arrowUp.enabled || arrowDown.enabled)
                //{
                arrowDown.enabled = false;
                arrowUp.enabled   = false;
                //}
            }
        }

        if (missileWarning)
        {
            invStatus curStatus = GetInvStatus();
            if (curStatus != latestStatus)
            {
                string tString = "";
                switch (curStatus)
                {
                case invStatus.Warning:
                    tString = "Missiles Low";
                    break;

                case invStatus.Depleted:
                    tString = "Depleted";
                    break;

                default:
                    break;
                }
                missileWarning.text = tString;
                if (latestStatus == invStatus.Normal && curStatus == invStatus.Warning)
                {
                    //play missile warning
                    missileWarningPulse = 7f;
                }
                else if (curStatus == invStatus.Depleted)
                {
                    //play missile warning
                    missileWarningPulse = 7f;
                }
                latestStatus = curStatus;
            }

            missileWarningPulse = Mathf.Max(0f, missileWarningPulse - dt);
            float warnPulse = Mathf.Min(missileWarningPulse, 1f);
            debugWarnPulse = warnPulse;
            if (latestStatus != invStatus.Normal)
            {
                missileWarningAlpha = Mathf.Min(missileWarningAlpha + 2f * dt, 1f);
            }
            else
            {
                missileWarningAlpha = Mathf.Max(0f, missileWarningAlpha - 2f * dt);
            }
            debugMissileWarningAlpha = missileWarningAlpha;
            float tmp = Mathf.Abs(fmod(GetSecondsMod900(), 0.5f));
            debugTMP = tmp;
            if (tmp < 0.25f)
            {
                tmp = tmp / 0.25f;
            }
            else
            {
                tmp = (0.5f - tmp) / 0.25f;
            }

            Color color = Color.white;
            color.a = missileWarningAlpha * tmp * warnPulse;
            missileWarning.material.color = color;
            if (missileWarning.material.color.a > 0)
            {
                //if (!missileWarning.enabled)
                missileWarning.enabled = true;
            }
            else
            {
                //if (missileWarning.enabled)
                missileWarning.enabled = false;
            }
        }
        missileBar.updateBar(dt);
        missileBar.Draw();
    }
Exemple #5
0
    public void UpdateHud(float dt)
    {
        threatBar.updateBar(dt);
        debugMaxEnergy = threatBar.GetMaxEnergy();
        Color warningColor = Color.Lerp(hudColors.threatIconColor, hudColors.threatIconWarning, warningColorLerp);

        float maxThreatEnergy = 10f;


        if (arrowTimer > 0f)
        {
            arrowUp.enabled = true;
            arrowTimer      = Mathf.Max(0f, arrowTimer - dt);
            Color color = warningColor;
            color.a           = arrowTimer / 0.5f;
            arrowUp.color     = color;
            arrowDown.enabled = false;
        }
        else if (arrowTimer < 0f)
        {
            arrowDown.enabled = true;
            arrowTimer        = Mathf.Min(0f, arrowTimer + dt);
            Color color = warningColor;
            color.a         = -arrowTimer / 0.5f;
            arrowDown.color = color;
            arrowUp.enabled = false;
        }
        else
        {
            arrowUp.enabled   = false;
            arrowDown.enabled = false;
        }


        if (threatDist <= maxThreatEnergy)
        {
            float tmp = threatDist - (maxThreatEnergy - threatBar.GetSetEnergy());



            debugTMP = tmp;
            if (tmp < -0.01f)
            {
                arrowTimer = 0.5f;
            }
            else if (tmp > 0.01f)
            {
                arrowTimer = -0.5f;
            }
        }
        else
        {
            arrowTimer = 0f;
        }

        if (threatDist <= maxThreatEnergy)
        {
            threatBar.SetCurrEnergy(threatBar.GetMaxEnergy() - threatDist, hudEnergyBar.ESetMode.Normal);
            threatIcon[0].GetComponent <Image>().color = warningColor;
        }
        else
        {
            threatBar.SetCurrEnergy(0f, hudEnergyBar.ESetMode.Normal);
            threatIcon[0].GetComponent <Image>().color = hudColors.threatIconSafeColor;
        }

        threatIcon[0].transform.localPosition = new Vector3(0f, Mathf.Max(0f, maxThreatEnergy - threatDist) * iconTranslateRange / maxThreatEnergy, 0f);

        if (threatWarning)
        {
            if (threatBar.GetActualFraction() > 0.8f)
            {
                threatWarning.enabled = true;
            }
            else
            {
                threatWarning.enabled = false;
            }

            ThreatStatus newStatus;
            if (maxThreatEnergy == threatBar.GetSetEnergy())
            {
                newStatus = ThreatStatus.Damage;
            }
            else if (threatBar.GetActualFraction() > 0.8f)
            {
                newStatus = ThreatStatus.Warning;
            }
            else
            {
                newStatus = ThreatStatus.Normal;
            }

            if (threatStatus != newStatus)
            {
                string tString = "";
                if (newStatus == ThreatStatus.Warning)
                {
                    tString = "Warning";
                }
                else if (newStatus == ThreatStatus.Damage)
                {
                    tString = "Damage";
                }

                threatWarning.text = tString;

                if (threatStatus == ThreatStatus.Normal && newStatus == ThreatStatus.Warning)
                {
                    //play threatWarning
                }
                else if (newStatus == ThreatStatus.Damage)
                {
                    //play threatDamage
                }

                threatStatus = newStatus;
            }
        }

        float oldDPT = damagePulseTimer;

        damagePulseTimer = Mathf.Abs(fmod(GetSecondsMod900(), 0.5f));
        if (damagePulseTimer < 0.25f)
        {
            damagePulse = damagePulseTimer / 0.25f;
        }
        else
        {
            damagePulse = (0.5f - damagePulseTimer) / 0.25f;
        }

        if (threatStatus == ThreatStatus.Damage && damagePulseTimer < oldDPT)
        {
            //play threat damage
        }

        if (threatWarning)
        {
            if (threatStatus != ThreatStatus.Normal)
            {
                warningLerpAlpha = Mathf.Min(warningLerpAlpha + 2f * dt, 1f);
                Color color = Color.white;
                color.a = warningLerpAlpha * damagePulse;
                threatWarning.material.color = color;
            }
            else
            {
                warningLerpAlpha = Mathf.Max(0f, warningLerpAlpha - 2f * dt);
                Color color = Color.white;
                color.a = warningLerpAlpha * damagePulse;
                threatWarning.material.color = color;
            }
            if (threatWarning.material.color.a > 0f)
            {
                threatWarning.enabled = true;
            }
            else
            {
                threatWarning.enabled = false;
            }
        }

        if (threatStatus == ThreatStatus.Damage)
        {
            warningColorLerp = Mathf.Min(warningColorLerp + 2f * dt, 1f);
        }
        else
        {
            warningColorLerp = Mathf.Max(0f, warningColorLerp - 2f * dt);
        }
    }