Esempio n. 1
0
    // Update is called once per frame


    public void hudUpdate(float dt)
    {
        //if (bossBar.GetCalculateMode() != calculateMode)
        //    bossBar.SetCalulateMode(calculateMode);
        bossBar.updateBar(dt);

        if (visible)
        {
            fader = Mathf.Min(fader + dt, 1f);
        }
        else
        {
            fader = Mathf.Max(0f, fader - dt);
        }

        if (fader > 0f)
        {
            Color color = Color.white;
            color.a    = alpha * fader;
            debugColor = color;
            for (int i = 0; i < rootChildren.Count; i++)
            {
                if (rootChildren[i].gameObject.GetComponent <Image>() != null)
                {
                    rootChildren[i].gameObject.GetComponent <Image>().material.color = color;
                }

                else if (rootChildren[i].gameObject.GetComponent <Text>() != null)
                {
                    rootChildren[i].gameObject.GetComponent <Text>().material.color = color;
                    //Debug.Log(rootChildren[i].gameObject.GetComponent<Text>().material.color);
                }
                else if (rootChildren[i].gameObject.GetComponent <RawImage>() != null)
                {
                    rootChildren[i].gameObject.GetComponent <RawImage>().material.color = color;
                }
            }
            for (int i = 0; i < rootChildren.Count; i++)
            {
                root.SetActive(true);
                rootChildren[i].SetActive(true);
            }
        }
        else
        {
            for (int i = 0; i < rootChildren.Count; i++)
            {
                root.SetActive(false);
                rootChildren[i].SetActive(false);
            }
        }
        //if (calculateMode == hudEnergyBar.CalculateMode.manual)
        //    bossBar.SetBarPercentage(healthP);
        bossBar.Draw();
    }
Esempio n. 2
0
    public void UpdateHud(float dt, float energyLowPulse)
    {
        //if (energyBar.GetCalculateMode() != calculateMode)
        //    energyBar.SetCalulateMode(calculateMode);
        if (cEnergyWarning)
        {
            if (energyLow)
            {
                energyLowFader = Mathf.Min(energyLowFader + 2f * dt, 1f);
                Color color = Color.white;
                color.a = energyLowFader * energyLowPulse;
                cEnergyWarning.material.color      = color;
                combatEnergyWarning.material.color = color;
                ballEnergyWarning.material.color   = color;
            }
            else
            {
                energyLowFader = Mathf.Max(0f, energyLowFader - 2f * dt);
                Color color = Color.white;
                color.a = energyLowFader * energyLowPulse;
                cEnergyWarning.material.color      = color;
                combatEnergyWarning.material.color = color;
                ballEnergyWarning.material.color   = color;
            }
            if (cEnergyWarning.material.color.a > 0f)
            {
                cEnergyWarning.enabled      = true;
                combatEnergyWarning.enabled = true;
                ballEnergyWarning.enabled   = true;
            }

            else
            {
                cEnergyWarning.enabled      = false;
                combatEnergyWarning.enabled = false;
                ballEnergyWarning.enabled   = false;
            }
        }

        if (cEnergyBar.GetFilledEnergy() != cachedBarEnergy || barDirty)
        {
            barDirty        = false;
            cachedBarEnergy = cEnergyBar.GetFilledEnergy();
            string lString = ((int)fmod(cachedBarEnergy, 101f)).ToString("d2");
            cEnergyDigits.text      = lString;
            combatEnergyDigits.text = lString;
            ballEnergyDigits.text   = lString;
        }

        //hudChangingColors.hudColors.EnergyBarColors barColors = hudColors.getVisorEnergyBarColors();
        Color emptyColor   = energyLow ? hudColors.energyBarEmptyLow : barColors.empty;
        Color filledColor  = energyLow ? hudColors.energyBarFilledLow : barColors.filled;
        Color shadowColor  = energyLow ? hudColors.energyBarShadowLow : barColors.shadow;
        Color useFillColor = Color.Lerp(filledColor, hudColors.energyBarFlashColor, flashMag);

        if (energyLow)
        {
            useFillColor = Color.Lerp(useFillColor, new Color(1f, 0.8f, 0.4f, 1f), energyLowPulse);
        }
        cEnergyBar.SetFilledColor(useFillColor);

        cEnergyBar.SetShadowColor(shadowColor);
        cEnergyBar.SetEmptyColor(emptyColor);
        updateEnergyBarColors(useFillColor, shadowColor, emptyColor);
        cEnergyBar.updateBar(dt);
        //if (calculateMode == hudEnergyBar.CalculateMode.manual)
        //{

        //    energyBar.SetBarPercentage(healthP);

        //}
        cEnergyBar.Draw();
    }
Esempio n. 3
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();
    }
Esempio n. 4
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);
        }
    }