Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        ini = false;
        string path = "combatHud/Envirorment";

        damagePulse        = 0f;
        damagePulseTimer   = 0f;
        arrowTimer         = 0f;
        warningColorLerp   = 0f;
        warningLerpAlpha   = 0f;
        threatStatus       = ThreatStatus.Normal;
        visible            = true;
        iconTranslateRange = 342.5f;
        hudColors          = new hudChangingColors.hudColors(true);

        //lhudTimer = new hudTimer();

        threatStuff = gameObject.transform.Find(path).gameObject;
        threatIcon  = new List <GameObject>();
        foreach (Transform transform in threatStuff.transform.Find("EnIcon").GetComponentsInChildren <Transform>())
        {
            threatIcon.Add(transform.gameObject);
            //Debug.Log(transform.gameObject + "[" + threatIcon.Count + "]");
        }
        arrowDown     = threatStuff.transform.Find("EnIcon/EnarrowDown").gameObject.GetComponent <Image>();
        arrowUp       = threatStuff.transform.Find("EnIcon/EnarrowUp").gameObject.GetComponent <Image>();
        threatWarning = threatStuff.transform.Find("EnIcon/warningText").gameObject.GetComponent <Text>();
        threatBar     = threatStuff.transform.Find("EnBarBack/EnBar").gameObject.GetComponent <hudEnergyBar>();
        //threatBar.initBars(threatBar.gameObject.GetComponent<Image>(), threatBar.gameObject.transform.parent.Find("EnBarShadow").gameObject.GetComponent<Image>());
        //Debug.Log(threatBar);
        hasArrows = arrowUp != null && arrowDown != null;

        threatIcon[0].GetComponent <Image>().color = hudColors.threatIconColor;
        threatIconTrans = threatIcon[0].transform;

        threatBar.SetFilledColor(hudColors.threatBarFilled);
        //Debug.Log(threatBar.GetFilledColor());
        threatBar.SetShadowColor(hudColors.threatBarShadow);
        //Debug.Log(threatBar.GetShadowColor());
        threatBar.SetEmptyColor(hudColors.threatBarEmpty);
        //Debug.Log(threatBar.GetEmptyColor());
        threatBar.SetTesselation(1f);
        threatBar.SetMaxEnergy(10f);
        threatBar.SetFilledDrainSpeed(9999f);
        threatBar.SetShadowDrainSpeed(9999f);
        threatBar.SetShadowDrainDelay(0f);
        threatBar.SetIsAlwaysResetTimer(false);

        if (threatWarning)
        {
            threatWarning.color = hudColors.threatWarningFont;
            threatWarning.gameObject.GetComponent <Outline>().effectColor = hudColors.threatWarningOutline;
        }

        //localMat = new Material(threatWarning.material);
        //threatWarning.material = localMat;
        debugIniMaxEnergy = threatBar.GetMaxEnergy();
        ini = true;
    }
Example #2
0
    //Material localMat;
    // Start is called before the first frame update
    void Start()
    {
        rendertimings         = 0;
        arrowTimer            = 0f;
        missileWarningAlpha   = 0f;
        latestStatus          = invStatus.Normal;
        missileWarningPulse   = 0f;
        missileIconAltDeplete = 0f;
        missileIconIncrement  = 0f;
        visible            = true;
        IconTranslateRange = 342.5f;
        hudColors          = new hudChangingColors.hudColors(true);
        string path = "combatHud/Missiles";

        //hudType = HudType;
        //missileCapacity = MissileCapacity;
        //numMissiles = NumMissiles;
        //missilesActive = MissilesActive;
        missileIcon         = gameObject.transform.Find(path + "/MIcon").gameObject.GetComponent <Image>();
        missileDigits       = gameObject.transform.Find(path + "/MIcon/count").gameObject.GetComponent <Text>();
        missileBar          = gameObject.transform.Find(path + "/MBarBack/MBar").gameObject.GetComponent <hudEnergyBar>();
        missileWarning      = gameObject.transform.Find(path + "/MIcon/depleted").gameObject.GetComponent <Text>();
        arrowUp             = gameObject.transform.Find(path + "/MIcon/arrowUp").gameObject.GetComponent <Image>();
        arrowDown           = gameObject.transform.Find(path + "/MIcon/arrowDown").gameObject.GetComponent <Image>();
        hasArrows           = arrowUp && arrowDown;
        iconTransform       = missileIcon.transform;
        missileDigits.color = hudColors.missileDigitsFont;
        missileDigits.gameObject.GetComponent <Outline>().effectColor = hudColors.missileDigitsOutline;
        missileIcon.color = hudColors.missileIconColorInactive;
        missileBar.SetEmptyColor(hudColors.missileBarEmpty);
        missileBar.SetFilledColor(hudColors.missileBarFilled);
        missileBar.SetShadowColor(hudColors.missileBarShadow);
        missileBar.SetTesselation(1f);
        missileBar.SetMaxEnergy(5f);
        missileBar.SetFilledDrainSpeed(99f);
        missileBar.SetShadowDrainSpeed(20f);
        missileBar.SetShadowDrainDelay(0.7f);
        missileBar.SetIsAlwaysResetTimer(true);
        rIconLerp = 1f;
        missIni   = false;
        if (missileWarning)
        {
            missileWarning.color = hudColors.missileWarningFont;
            missileWarning.gameObject.GetComponent <Outline>().effectColor = hudColors.missileWarningOutline;
        }
        //localMat = new Material(missileDigits.material);
        //missileDigits.material = localMat;
        latestStatus = GetInvStatus();
    }
Example #3
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;
 }
Example #4
0
    //  public void SetCalculateMode(hudEnergyBar.CalculateMode calculate) { calculateMode = calculate; }
    // public hudEnergyBar.CalculateMode GetCalculateMode(){ return calculateMode; }
    //  public void SetHealthP(float per) { healthP = per; }
    public void initValues(hudTypes hud, float TankEnergy, int totalTanks, int NumTanksFilled, bool EnergyLow)
    {
        //calculateMode = calculate;
        hudTypes         = hud;
        tankEnergy       = TankEnergy;
        totalEnergyTanks = totalTanks;
        numTanksFilled   = NumTanksFilled;
        energyLow        = EnergyLow;
        cEmptyTanks      = new List <Image>();
        cFilledTanks     = new List <Image>();
        updateItems(hud);
        combatEnergyBar.SetTesselation(1f);
        ballEnergyBar.SetTesselation(1f);
        //energyBar.SetCalulateMode(calculate);

        combatEnergyBar.SetMaxEnergy(100f);
        ballEnergyBar.SetMaxEnergy(100f);
        combatEnergyBar.SetFilledColor(hudColors.getVisorEnergyBarColors(true).filled);
        ballEnergyBar.SetFilledColor(hudColors.getVisorEnergyBarColors(false).filled);
        combatEnergyBar.SetShadowColor(hudColors.getVisorEnergyBarColors(true).shadow);
        ballEnergyBar.SetShadowColor(hudColors.getVisorEnergyBarColors(false).shadow);
        combatEnergyBar.SetEmptyColor(hudColors.getVisorEnergyBarColors(true).empty);
        ballEnergyBar.SetEmptyColor(hudColors.getVisorEnergyBarColors(false).empty);

        combatEnergyBar.SetFilledDrainSpeed(99f);
        ballEnergyBar.SetFilledDrainSpeed(99f);
        combatEnergyBar.SetShadowDrainSpeed(20f);
        ballEnergyBar.SetShadowDrainSpeed(20f);
        combatEnergyBar.SetShadowDrainDelay(0.7f);
        ballEnergyBar.SetShadowDrainDelay(0.7f);
        combatEnergyBar.SetIsAlwaysResetTimer(false);
        ballEnergyBar.SetIsAlwaysResetTimer(false);
        cEnergyDigits.color      = initColors.digitsFont;
        combatEnergyDigits.color = hudColors.getVisorEnergyInitColors(true).digitsFont;
        ballEnergyDigits.color   = hudColors.getVisorEnergyInitColors(false).digitsFont;

        cEnergyDigits.gameObject.GetComponent <Outline>().effectColor      = initColors.digitsOutline;
        combatEnergyDigits.gameObject.GetComponent <Outline>().effectColor = hudColors.getVisorEnergyInitColors(true).digitsOutline;
        ballEnergyDigits.gameObject.GetComponent <Outline>().effectColor   = hudColors.getVisorEnergyInitColors(false).digitsOutline;

        cEnergyWarning.color      = hudColors.energyWarningFont;
        combatEnergyWarning.color = hudColors.energyWarningFont;
        ballEnergyWarning.color   = hudColors.energyWarningFont;
        cEnergyWarning.gameObject.GetComponent <Outline>().effectColor      = hudColors.energyWarningOutline;
        combatEnergyWarning.gameObject.GetComponent <Outline>().effectColor = hudColors.energyWarningOutline;
        ballEnergyWarning.gameObject.GetComponent <Outline>().effectColor   = hudColors.energyWarningOutline;
        if (energyLow)
        {
            cEnergyWarning.text      = "Energy Low";
            combatEnergyWarning.text = "Energy Low";
            ballEnergyWarning.text   = "Energy Low";
        }

        else
        {
            cEnergyWarning.text      = "";
            combatEnergyWarning.text = "";
            ballEnergyWarning.text   = "";
        }



        for (int i = 0; i < 6; i++)
        {
            cEmptyTanks[i].color       = initColors.tankEmpty;
            combatEmptyTanks[i].color  = hudColors.getVisorEnergyInitColors(true).tankEmpty;
            ballEmptyTanks[i].color    = hudColors.getVisorEnergyInitColors(false).tankEmpty;
            cFilledTanks[i].color      = initColors.tankFilled;
            combatFilledTanks[i].color = hudColors.getVisorEnergyInitColors(true).tankFilled;
            ballFilledTanks[i].color   = hudColors.getVisorEnergyInitColors(false).tankFilled;
        }
        for (int i = 0; i < 6; i++)
        {
            if (i < numTanksFilled)
            {
                cFilledTanks[i].gameObject.SetActive(true);
                combatFilledTanks[i].gameObject.SetActive(true);
                ballFilledTanks[i].gameObject.SetActive(true);
            }


            else
            {
                cFilledTanks[i].gameObject.SetActive(false);
                combatFilledTanks[i].gameObject.SetActive(false);
                ballFilledTanks[i].gameObject.SetActive(false);
            }
        }
        initHealth = true;
    }
Example #5
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();
    }