Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        float hpRatio = (float)status.getHP() * 100 / status.maxHP;

        text.text = string.Format("{0}%", (int)(hpRatio));

        if (status.getHP() <= 0)
        {
            text.color = Color.red;
        }
    }
Ejemplo n.º 2
0
    private void Update()
    {
        float hpRatio = (float)status.getHP() * 100 / status.maxHP;

        HP.fillAmount = hpRatio / 100;
        HP.color      = Color.Lerp(emptyHPColor, fullHPColor, hpRatio / 100);
        HPText.text   = string.Format("{0}%", (int)(hpRatio));

        float backRatio = control.backGunHeat / control.backGunMaxHeat;

        backBullet.fillAmount = backRatio;
        backBullet.color      = Color.Lerp(fullHPColor, emptyHPColor, backRatio);
        backBulletText.text   = string.Format("{0}%", (int)(backRatio * 100));

        UpdateBullet(control.frontGunMag, control.frontGunSlot, emptyBulletColor, fullBulletColor, frontBullet, frontBulletText, control.frontGunReloadTime, control.lastFrontGunReload);
        UpdateBullet(control.leftGunMag, control.sideGunSlot, emptyBulletColor, fullBulletColor, LBullet, LsideBulletText, control.sideGunReloadTime, control.lastLeftGunReload);
        UpdateBullet(control.rightGunMag, control.sideGunSlot, emptyBulletColor, fullBulletColor, RBullet, RsideBulletText, control.sideGunReloadTime, control.lastRightGunReload);
        UpdateBullet(control.mainGunMag, control.mainGunSlot, emptyBulletColor, fullBulletColor, mainBullet, mainBulletText, control.mainGunReloadTime, control.lastMainGunReload);
    }
Ejemplo n.º 3
0
    private void FixedUpdate()
    {
        if (currentPhase == 0)
        {
            fightStatus.isInvincible = true;
            Aiming();
            if (Time.time - startTime > prepareTime)
            {
                currentPhase    = 1;
                changePhaseTime = Time.time;
                actionTime      = Time.time;
            }
        }
        else if (currentPhase == 1)
        {
            fightStatus.isInvincible = false;
            Aiming();
            float actionTimeDiff = Time.time - actionTime;
            // phase 1.action 1
            if (actionTimeDiff < 15)
            {
                bool reach = MoveToTarget(normalMoveSpeed, normalMoveGoal);

                if (reach)
                {
                    normalMoveGoal = normalMoveBound.GetRandomPosInBound();
                }

                bool fired = FixedPatternFire(ref lastnormalFire, normalFireFreq, normalPattern, normalBullet, normalBulletSpeed, normalBulletIncreaseSpeed);
                if (fired)
                {
                    laser3SE.Play();
                }
            }
            // phase 1.action 2
            else if (actionTimeDiff >= 15 && actionTimeDiff < 18)
            {
                bool reach = MoveToTarget(recenterSpeed, Vector3.zero);
            }
            // phase 1.action 3
            else if (actionTimeDiff >= 18 && actionTimeDiff < 28)
            {
                bool fired = FixedPatternFire(ref lastRotateFire, rotateFireFreq, rotatePattern1, rotateBullet, rotateBulletSpeed, rotateBulletIncreaseSpeed);
                if (fired)
                {
                    lastRotateFire = -100; // reset fire time
                    FixedPatternFire(ref lastRotateFire, rotateFireFreq, rotatePattern2, rotateBullet, rotateBulletSpeed, rotateBulletIncreaseSpeed);

                    if (fired)
                    {
                        laser2SE.Play();
                    }
                }
            }
            else if (actionTimeDiff >= 28 && actionTimeDiff < 31)
            {
            }
            // reset phase 1
            else
            {
                actionTime = Time.time;
            }

            if (fightStatus.getHP() <= phase2HP)
            {
                changePhaseTime = Time.time;
                actionTime      = Time.time;
                currentPhase    = 2;
                explosionSE.Play();
                haloEffect.StartScaleUp();
                moonShake.GenerateImpulse();
                fightStatus.isInvincible = true;
            }
        }
        else if (currentPhase == 2)
        {
            Aiming();
            float actionTimeDiff = Time.time - actionTime;

            if (actionTimeDiff > changePhaseInvincible)
            {
                fightStatus.isInvincible = false;
            }

            if (actionTimeDiff < 3)
            {
                bool reach = MoveToTarget(recenterSpeed, Vector3.zero);
            }
            else if (actionTimeDiff >= 3 && actionTimeDiff < 13)
            {
                RandomFire(ref lastRandomFire, randomFireFreq, randomBullet, randomBulletSpeed, randomBulletIncreaseSpeed, randomFireCount, randomFireDistance, transform.position);
                if (!loopSE.isPlaying)
                {
                    loopSE.Play();
                }
            }
            else if (actionTimeDiff >= 13 && actionTimeDiff < 19)
            {
                RandomFire(ref lastRandomFire, randomFireFreq, randomBullet, randomBulletSpeed, randomBulletIncreaseSpeed, randomFireCount, randomFireDistance, transform.position);
                bool fired = FixedPatternFire(ref lastVortexFire, vortexFireFreq, vortexPattern, vortexBullet1, vortexBulletSpeed, vortexBulletIncreaseSpeed);
                if (fired)
                {
                    laser1SE.Play();
                }
            }
            else if (actionTimeDiff >= 19 && actionTimeDiff < 25)
            {
                RandomFire(ref lastRandomFire, randomFireFreq, randomBullet, randomBulletSpeed, randomBulletIncreaseSpeed, randomFireCount, randomFireDistance, transform.position);
                bool fired = FixedPatternFire(ref lastVortexFire, vortexFireFreq, vortexPattern, vortexBullet2, vortexBulletSpeed, vortexBulletIncreaseSpeed);
                if (fired)
                {
                    laser1SE.Play();
                }
            }
            else
            {
                if (loopSE.isPlaying)
                {
                    loopSE.Stop();
                }
                actionTime = Time.time;
            }

            if (fightStatus.getHP() <= phase3HP)
            {
                if (loopSE.isPlaying)
                {
                    loopSE.Stop();
                }
                changePhaseTime      = Time.time;
                actionTime           = Time.time;
                currentPhase         = 3;
                currentEdgeMoveIndex = 0;
                explosionSE.Play();
                haloEffect.StartScaleUp();
                moonShake.GenerateImpulse();

                fightStatus.isInvincible = true;
            }
        }
        else if (currentPhase == 3)
        {
            float actionTimeDiff = Time.time - actionTime;
            Aiming();
            if (actionTimeDiff > changePhaseInvincible)
            {
                fightStatus.isInvincible = false;
            }

            if (actionTimeDiff <= 3)
            {
                // pause 3s
            }
            else if (actionTimeDiff >= 3 && actionTimeDiff < 13)
            {
                bool reach = MoveToTarget(edgeMoveSpeed, edgeMovePositions[currentEdgeMoveIndex].position);

                if (reach)
                {
                    currentEdgeMoveIndex = (currentEdgeMoveIndex + 1) % edgeMovePositions.Length;
                }

                bool fired = FixedPatternFire(ref lastqRotateFire, qrotateFireFreq, quickRotatePattern1, rotateBullet, qrotateBulletSpeed, qrotateBulletIncreaseSpeed);
                if (fired)
                {
                    laser2SE.Play();
                }
            }
            else if (actionTimeDiff >= 13 && actionTimeDiff < 16)
            {
                // pause 3s
            }
            else if (actionTimeDiff >= 16 && actionTimeDiff < 26)
            {
                bool fired = FixedPatternFire(ref lastqRotateFire, qrotateFireFreq, quickRotatePattern1, rotateBullet, qrotateBulletSpeed, qrotateBulletIncreaseSpeed);
                if (fired)
                {
                    laser2SE.Play();
                }
                fired = FixedPatternFire(ref lastVortexFire, vortexFireFreq, vortexPattern, vortexBullet2, vortexBulletSpeed, vortexBulletIncreaseSpeed);
                if (fired)
                {
                    laser1SE.Play();
                }
            }
            else if (actionTimeDiff >= 26 && actionTimeDiff < 29)
            {
                // pause 3s
            }
            else if (actionTimeDiff >= 29 && actionTimeDiff < 39)
            {
                bool reach = MoveToTarget(edgeMoveSpeed, edgeMovePositions[currentEdgeMoveIndex].position);

                if (reach)
                {
                    currentEdgeMoveIndex = (currentEdgeMoveIndex + 1) % edgeMovePositions.Length;
                }

                bool fired = FixedPatternFire(ref lastRotateFire, rotateFireFreq, quickRotatePattern2, rotateBullet, rotateBulletSpeed, rotateBulletIncreaseSpeed);
                if (fired)
                {
                    laser2SE.Play();
                }
            }
            else if (actionTimeDiff >= 39 && actionTimeDiff < 42)
            {
                // pause 3s
            }
            else if (actionTimeDiff >= 42 && actionTimeDiff < 52)
            {
                bool fired = FixedPatternFire(ref lastqRotateFire, qrotateFireFreq, quickRotatePattern2, rotateBullet, qrotateBulletSpeed, qrotateBulletIncreaseSpeed);
                if (fired)
                {
                    laser2SE.Play();
                }
                fired = FixedPatternFire(ref lastVortexFire, vortexFireFreq, vortexPattern, vortexBullet1, vortexBulletSpeed, vortexBulletIncreaseSpeed);
                if (fired)
                {
                    laser1SE.Play();
                }
            }
            else
            {
                actionTime = Time.time;
            }

            if (fightStatus.getHP() <= 0)
            {
                changePhaseTime      = Time.time;
                actionTime           = Time.time;
                currentPhase         = 4;
                currentEdgeMoveIndex = 0;
                explosionSE.Play();
                haloEffect.StartScaleUp();
                moonShake.GenerateImpulse();
                endPhaseSound.Play();
            }
        }
        else if (currentPhase == 4)
        {
            float actionTimeDiff = Time.time - actionTime;
            AimingPhase4();
            if (actionTimeDiff < 3)
            {
                bool reach = MoveToTarget(recenterSpeed, Vector3.zero);
            }
            else if (actionTimeDiff >= 3 && actionTimeDiff < 18)
            {
                if (!loopSE.isPlaying)
                {
                    loopSE.Play();
                }
                RandomFire(ref lastRandomFire, randomFireFreq, randomBullet, randomBulletSpeed, randomBulletIncreaseSpeed, randomFireCount, randomFireDistance, transform.position);
            }
            else if (actionTimeDiff >= 18 && actionTimeDiff < 21)
            {
                RandomFire(ref lastRandomFire, randomFireFreq, randomBullet, randomBulletSpeed, randomBulletIncreaseSpeed, randomFireCount, randomFireDistance, transform.position);
            }
            else if (actionTimeDiff >= 21 && actionTimeDiff < 36)
            {
                RandomFire(ref lastRandomFire, randomFireFreq, randomBullet, randomBulletSpeed, randomBulletIncreaseSpeed, randomFireCount - 1, randomFireDistance, transform.position);
                bool fired = FixedPatternFire(ref lastnormalFire, normalFireFreq * 1.3f, normalPattern, normalBullet, normalBulletSpeed, normalBulletIncreaseSpeed);
                if (fired)
                {
                    laser3SE.Play();
                }
            }
            else if (actionTimeDiff >= 36 && actionTimeDiff < 39)
            {
                RandomFire(ref lastRandomFire, randomFireFreq, randomBullet, randomBulletSpeed, randomBulletIncreaseSpeed, randomFireCount - 1, randomFireDistance, transform.position);
                bool fired = FixedPatternFire(ref lastnormalFire, normalFireFreq * 1.3f, normalPattern, normalBullet, normalBulletSpeed, normalBulletIncreaseSpeed);
                if (fired)
                {
                    laser3SE.Play();
                }
            }
            else if (actionTimeDiff >= 39 && actionTimeDiff < 49)
            {
                RandomFire(ref lastRandomFire, randomFireFreq, randomBullet, randomBulletSpeed, randomBulletIncreaseSpeed, randomFireCount - 2, randomFireDistance, transform.position);
                bool fired = FixedPatternFire(ref lastnormalFire, normalFireFreq * 1.3f, normalPattern, normalBullet, normalBulletSpeed, normalBulletIncreaseSpeed);
                if (fired)
                {
                    laser3SE.Play();
                }
                fired = FixedPatternFire(ref lastVortexFire, vortexFireFreq * 1.6f, vortexPattern, vortexBullet1, vortexBulletSpeed, vortexBulletIncreaseSpeed);
                if (fired)
                {
                    laser1SE.Play();
                }
            }
            else if (actionTimeDiff >= 49 && actionTimeDiff < 51)
            {
                RandomFire(ref lastRandomFire, randomFireFreq, randomBullet, randomBulletSpeed, randomBulletIncreaseSpeed, randomFireCount - 2, randomFireDistance, transform.position);
                bool fired = FixedPatternFire(ref lastnormalFire, normalFireFreq * 1.3f, normalPattern, normalBullet, normalBulletSpeed, normalBulletIncreaseSpeed);
                if (fired)
                {
                    laser3SE.Play();
                }
                fired = FixedPatternFire(ref lastVortexFire, vortexFireFreq * 1.6f, vortexPattern, vortexBullet1, vortexBulletSpeed, vortexBulletIncreaseSpeed);
                if (fired)
                {
                    laser1SE.Play();
                }
            }
            else if (actionTimeDiff >= 51 && actionTimeDiff < 58)
            {
                RandomFire(ref lastRandomFire, randomFireFreq, randomBullet, randomBulletSpeed, randomBulletIncreaseSpeed, randomFireCount - 2, randomFireDistance, transform.position);
                bool fired = FixedPatternFire(ref lastnormalFire, normalFireFreq * 1.3f, normalPattern, normalBullet, normalBulletSpeed, normalBulletIncreaseSpeed);
                if (fired)
                {
                    laser3SE.Play();
                }
                fired = FixedPatternFire(ref lastVortexFire, vortexFireFreq * 1.6f, vortexPattern, vortexBullet1, vortexBulletSpeed, vortexBulletIncreaseSpeed);
                if (fired)
                {
                    laser1SE.Play();
                }
                fired = FixedPatternFire(ref lastRotateFire, rotateFireFreq * 1.3f, rotatePattern2, rotateBullet, rotateBulletSpeed * 0.6f, rotateBulletIncreaseSpeed);
                if (fired)
                {
                    laser2SE.Play();
                }
            }

            if (actionTimeDiff < 58)
            {
                moonShakeLoop.GenerateImpulse();
            }

            sr.color = Color.Lerp(Color.white, endPhaseColor, actionTimeDiff / 58.0f);

            if (actionTimeDiff >= 58)
            {
                if (loopSE.isPlaying)
                {
                    loopSE.Stop();
                }
                changePhaseTime      = Time.time;
                actionTime           = Time.time;
                currentEdgeMoveIndex = 0;
                explosionSE.Play();
                currentPhase = 5;
                haloEffect.StartScaleUp();
                moonShakeEnd.GenerateImpulse();
                whiteScreen.gameObject.SetActive(true);
                player.GetComponent <FightStatus>().isInvincible = true;
            }
        }
        else if (currentPhase == 5)
        {
            float actionTimeDiff = Time.time - actionTime;
            if (actionTimeDiff > 5)
            {
                transform.rotation = Quaternion.identity;
                launchPad.SetActive(true);
                sr.color = Color.white;
                endPhaseSound.Stop();
            }
        }
    }
Ejemplo n.º 4
0
 private void Update()
 {
     text.text = string.Format("HP: {0}/{1}", status.getHP(), status.maxHP);
 }