Example #1
0
    void Update()
    {
        // 终局
        if (BattleMgr.bossPhase == 4)
        {
            transform.position = Vector3.zero;
            return;
        }

        // Gameover自爆
        if (BattleMgr.gameOver && !BattleMgr.gameRealOver)
        {
            gameoverCnt -= Time.unscaledDeltaTime;
            if (seCnt04 <= 0)
            {
                se04.Play();
                seCnt04 = 0.1f;
            }
            else
            {
                seCnt04 -= Time.unscaledDeltaTime;
            }
            if (gameoverCnt <= 0)
            {
                Time.timeScale      = 1f;
                Time.fixedDeltaTime = 0.02f;
                body.SetActive(false);
                back.SetActive(false);
                se03.Play();
                BattleMgr.gameRealOver = true;
                camctrl.Shake2();
            }
            return;
        }


        ScreenClearBomb();
        MainProcess();
    }
    // BOSS战流程
    private void Act10()
    {
        if (dead)
        {
            if (BattleMgr.bossPhase >= 3)
            {
                GameObject.Find("BGM").GetComponent <AudioSource>().volume -= 0.01f;
                FianlScreen.color = new Color(FianlScreen.color.r, FianlScreen.color.g, FianlScreen.color.b, FianlScreen.color.a - 0.002f);
                if (FianlScreen.color.a <= 0.01f)
                {
                    FianlScreen.color      = new Color(FianlScreen.color.r, FianlScreen.color.g, FianlScreen.color.b, FianlScreen.color.a + 0.01f);
                    BattleMgr.gameRealOver = true;
                }
                return;
            }
        }
        else
        {
            if (BattleMgr.bossPhase < 3)
            {
                BossCount += Time.deltaTime;
            }
            else
            {
                FianlScreen.color = new Color(FianlScreen.color.r, FianlScreen.color.g, FianlScreen.color.b, FianlScreen.color.a - 0.005f);
                BossCount        += Time.unscaledDeltaTime;
            }
            var c = hpbar.localScale;
            c.x = (float)hp / maxhp;
            hpbar.localScale = c;

            switch (BattleMgr.bossPhase)
            {
            // 第一阶段
            case -1:
                if (BattleMgr.turn == 2)
                {
                    BossCount = 0;
                    BattleMgr.bossPhase++;
                }
                else
                {
                    if (BattleMgr.turnTimer < 20)
                    {
                        if (!AtkMae.gameObject.activeSelf)
                        {
                            AtkMae.gameObject.SetActive(true);
                        }
                    }
                }
                break;

            // 第二阶段
            case 0:
                if (hp <= 0)
                {
                    Destroy(AtkMae.gameObject);
                    BattleMgr.turnTimer = 8f;
                    mainBody1.SetActive(true);
                    mainBody2.SetActive(true);
                    BossLeftArm.SetActive(true);
                    BossRightArm.SetActive(true);
                    for (int i = 0; i < AtkB.Length; i++)
                    {
                        AtkB[i].SetActive(false);
                    }
                    GetComponent <SphereCollider>().radius = 0.3f;
                    B1.Play();
                    cam.Shake3();
                    Destroy(BodyOne);
                    BodyOneExplow.Play();
                    hp        = maxhp;
                    BossCount = 0;
                    BattleMgr.bossPhase++;
                }
                else
                {
                    if (transform.position.y > 3f)
                    {
                        transform.position = new Vector3(transform.position.x, transform.position.y - 0.01f, transform.position.z);
                    }

                    if (BossCount > 3f && BossCount < 6f)
                    {
                        for (int i = 0; i < AtkB.Length; i++)
                        {
                            AtkB[i].SetActive(true);
                            var line = AtkB[i].GetComponent <LineRenderer>();
                            if (line.GetPosition(1).x < 8)
                            {
                                line.SetPosition(1, new Vector3((line.GetPosition(1).x + 0.08f), 0, 0));
                            }
                        }
                        AtkBBody.transform.Rotate(0, 0, 6f - BossCount);
                    }
                    if (BossCount > 6f)
                    {
                        for (int i = 0; i < AtkB.Length; i++)
                        {
                            var ps = AtkB[i].GetComponent <ParticleSystem>();
                            ATKBcount[i]--;
                            if (ATKBcount[i] <= 0)
                            {
                                ATKBcount[i] = Random.Range(120, 180);
                                ps.Emit(100);
                                AtkBSE.Play();
                            }
                        }
                    }
                }
                break;

            // 第三阶段
            case 1:
                if (hp <= 0)
                {
                    BattleMgr.turnTimer += 10f;
                    for (int i = 0; i < AtkB.Length; i++)
                    {
                        AtkB[i].SetActive(true);
                        AtkB[i].GetComponent <SelfRotation>().enabled = true;
                        AtkB[i].GetComponent <SelfRotation>().spd     = i;
                    }
                    Destroy(WaveObject);
                    Destroy(botAtk.gameObject);
                    B1.Play();
                    Destroy(BossLeftArm);
                    Destroy(BossRightArm);
                    hp        = maxhp = 35000;
                    BossCount = 0;
                    BattleMgr.bossPhase++;
                }
                else
                {
                    Vector3 lpos = BossLeftHand.transform.position;
                    Vector3 rpos = BossRightHand.transform.position;
                    if (BossCount > 1f && BossCount < 3f)
                    {
                        lpos.x += (-7 - lpos.x) / 10f;
                        rpos.x += (7 - rpos.x) / 10f;
                        if (lpos.x < -6.9f)
                        {
                            if (!shake)
                            {
                                WallHandSE.Play();
                                cam.ShakeSmall();
                                shake = true;
                            }
                            cam.ShakeSmall();
                        }
                    }
                    else if (BossCount > 3f && BossCount < 5f)
                    {
                        if (rpos.x > -1 && lpos.x < 1)
                        {
                            if (rpos.x < 0.4 && shake)
                            {
                                WallSE.Play();
                                cam.Shake2();
                                cam.Shake3();
                                shake = false;
                            }
                            rpos.x += -accspd;
                            lpos.x += accspd;
                            accspd += Time.deltaTime / 2;
                        }
                        rpos.y += (0.75f - rpos.y) / 15f;
                        lpos.y += (0.75f - lpos.y) / 15f;
                    }
                    else if (BossCount > 5f && BossCount < 8f)
                    {
                        rpos.x += (1.75f - rpos.x) / 20f;
                        lpos.x += (-1.75f - lpos.x) / 20f;
                        rpos.y += (4f - rpos.y) / 20f;
                        lpos.y += (4f - lpos.y) / 20f;
                    }
                    if (BossCount > 12f)
                    {
                        if (!botAtk.gameObject.activeSelf)
                        {
                            botAtk.gameObject.SetActive(true);
                            botAtk.Play();
                        }
                    }
                    BossLeftHand.transform.position  = lpos;
                    BossRightHand.transform.position = rpos;
                }
                break;

            // 第四阶段
            case 2:
                if (hp <= 0)
                {
                    FianlScreen.color   = Color.red;
                    Time.timeScale      = 0.1f;
                    Time.fixedDeltaTime = 0.1f * 0.02f;
                    Destroy(AtkBBody);
                    B1.Play();
                    atk1.Stop();
                    Destroy(atk1.gameObject);
                    BossCount = 0;
                    holeHpBar.gameObject.SetActive(false);
                    GetComponent <SelfRotation>().enabled = false;
                    BattleMgr.bossPhase++;
                }
                else
                {
                    if (BossCount < 0.5f)
                    {
                        cam.Shake3();
                    }
                    if (BossCount > 2f)
                    {
                        if (!atk1.isPlaying)
                        {
                            atk1.Play();
                        }
                    }
                    cam.gameObject.GetComponent <Camera>().backgroundColor = new Color((75 + Mathf.Sin(Time.time * 3) * 25) / 255, 0, 0, 255);
                    BossWing.SetActive(true);
                    if (BossCount > 8f)
                    {
                        for (int i = 0; i < AtkB.Length; i++)
                        {
                            var ps = AtkB[i].GetComponent <ParticleSystem>();
                            ATKBcount[i]--;
                            if (ATKBcount[i] <= 0)
                            {
                                int iii = (int)BossCount;
                                iii          = 180 - iii < 60 ? 60 : 180 - iii;
                                ATKBcount[i] = Random.Range(iii, 240);
                                ps.Emit(100);
                                AtkBSE.Play();
                            }
                        }
                    }
                }
                break;

            // 击破后演出
            case 3:
                BattleMgr.turnTimer = 999f;
                transform.position  = new Vector3(transform.position.x, transform.position.y + (0 - transform.position.y) / 100f, transform.position.z);
                GameObject.Find("BGM").GetComponent <AudioSource>().volume -= 0.0005f;
                if (BossCount < 2)
                {
                    cam.ShakeSmall();
                }
                else
                {
                    if (deadPhase < 2 && BossCount > 4)
                    {
                        if (sasasaCnt > 0)
                        {
                            sasasaCnt -= Time.unscaledDeltaTime;
                        }
                        else
                        {
                            sasasaCnt = 0.2f;
                            sasasasa.Play();
                        }
                    }
                }
                if (BossCount > 4 && BossCount < 9)
                {
                    if (deadPhase == 0)
                    {
                        FianlScreen.color = Color.white;
                        Dead.gameObject.SetActive(true);
                        Dead.Play();
                        deadPhase++;
                    }
                }
                else if (BossCount > 9)
                {
                    if (deadPhase == 1)
                    {
                        cam.StartFinalEffect();
                        var dt = Dead.main;
                        var st = DeadSon.main;
                        dt.simulationSpeed -= 0.01f;
                        st.simulationSpeed -= 0.01f;

                        if (dt.simulationSpeed < 0.1f)
                        {
                            deadPhase++;
                        }
                    }
                }
                if (deadPhase == 2)
                {
                    BattleMgr.controlable = false;
                    WallSE.Play();
                    sasasasaBB.Play();
                    sasasasaCC.Play();
                    FinalPos.gameObject.SetActive(true);
                    cam.gameObject.GetComponent <Camera>().backgroundColor = new Color(0.7f, 0.7f, 0.7f);
                    Destroy(Dead.gameObject);
                    FianlScreen.color = Color.white;
                    Destroy(BossWing.gameObject);
                    cam.Shake2();
                    Time.timeScale      = 1f;
                    Time.fixedDeltaTime = 0.02f;
                    dead = true;
                    BattleMgr.bossPhase++;
                    mainBody1.SetActive(false);
                    mainBody2.SetActive(false);
                }
                break;
            }
        }
    }