예제 #1
0
    void Update()
    {
        // 材质动画
        float offset = Time.time * spd;

        m.SetTextureOffset("BASE", new Vector2(offset, 0));

        // BOSS战特殊演出
        if (BattleMgr.bossPhase == 3)
        {
            if (isLeft)
            {
                transform.position = new Vector3(transform.position.x - 0.05f, transform.position.y, transform.position.z);
            }
            else
            {
                transform.position = new Vector3(transform.position.x + 0.05f, transform.position.y, transform.position.z);
            }
            return;
        }
        // BOSS战特殊演出
        if (BattleMgr.bossPhase == 1)
        {
            if (!BattleMgr.gamePause)
            {
                bossCount1 += Time.deltaTime;
            }
            if (bossCount1 > 3f)
            {
                if (isLeft)
                {
                    if (transform.position.x < -10)
                    {
                        transform.position = new Vector3(transform.position.x + accspd, transform.position.y, transform.position.z);
                        accspd            += Time.deltaTime / 2;
                    }
                    else
                    {
                        if (!shaked)
                        {
                            GetComponent <Renderer>().material = mat2;
                            cam.ShakeSmall();
                            shaked = true;
                        }
                        accspd = 0;
                    }
                }
                else
                {
                    if (transform.position.x > 10)
                    {
                        transform.position = new Vector3(transform.position.x - accspd, transform.position.y, transform.position.z);
                        accspd            += Time.deltaTime / 2;
                    }
                    else
                    {
                        if (!shaked)
                        {
                            GetComponent <Renderer>().material = mat2;
                            cam.ShakeSmall();
                            shaked = true;
                        }
                        accspd = 0;
                    }
                }
            }
        }
        // BOSS战特殊演出
        else if (BattleMgr.bossPhase == 2)
        {
            if (!BattleMgr.gamePause)
            {
                bossCount2 += Time.deltaTime;
            }
            if (bossCount2 > 0.5f)
            {
                if (isLeft)
                {
                    float x = transform.position.x;
                    x += (-15 - x) / 40f;
                    transform.position = new Vector3(x, transform.position.y, transform.position.z);
                }
                else
                {
                    float x = transform.position.x;
                    x += (15 - x) / 40f;
                    transform.position = new Vector3(x, transform.position.y, transform.position.z);
                }
            }
        }
    }
예제 #2
0
    // 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;
            }
        }
    }