示例#1
0
    public void Update()
    {
        if (Enum_CurrectLevel == enum_Level.GameStart)          //遊戲開始狀態
        {
            Enum_CurrectLevel = enum_Level.Level_01;
        }
        else if (Enum_CurrectLevel == enum_Level.Level_01)      //第一關關卡
        {
            flo_Currect_Time -= Time.deltaTime;
            Obj_UiTime[2].GetComponent <Image>().fillAmount = (flo_Currect_Time / flo_MaxTime);

            if (Obj_UiTime[2].GetComponent <Image>().fillAmount > 0.0f)
            {
                if (bool_LowHp)
                {
                    Obj_UiTime[2].GetComponent <Image>().color = Color.Lerp(Obj_UiTime[2].GetComponent <Image>().color, new Color(1, 1, 1, 0.1f), 1.5f * Time.deltaTime);
                    if (Obj_UiTime[2].GetComponent <Image>().color.a <= 0.15f)
                    {
                        bool_LowHp = false;
                    }
                }
                else
                {
                    Obj_UiTime[2].GetComponent <Image>().color = Color.Lerp(Obj_UiTime[2].GetComponent <Image>().color, new Color(1, 1, 1, 1), 1.5f * Time.deltaTime);
                    if (Obj_UiTime[2].GetComponent <Image>().color.a >= 0.8f)
                    {
                        bool_LowHp = true;
                    }
                }
            }
        }
    }
示例#2
0
    public void Update()
    {
        if (Enum_CurrectLevel == enum_Level.GameStart)          //遊戲開始狀態
        {
            Enum_CurrectLevel = enum_Level.Level_01;
        }
        else if (Enum_CurrectLevel == enum_Level.Level_01)      //第一關關卡
        {
            flo_Currect_Time -= Time.deltaTime;
            Obj_UiTime[2].GetComponent <Image>().fillAmount = (flo_Currect_Time / flo_MaxTime);

            if (Obj_UiTime[2].GetComponent <Image>().fillAmount > 0.0f)
            {
                if (bool_LowHp)
                {
                    Obj_UiTime[2].GetComponent <Image>().color = Color.Lerp(Obj_UiTime[2].GetComponent <Image>().color, new Color(1, 1, 1, 0.1f), 1.5f * Time.deltaTime);
                    if (Obj_UiTime[2].GetComponent <Image>().color.a <= 0.15f)
                    {
                        bool_LowHp = false;
                    }
                }
                else
                {
                    Obj_UiTime[2].GetComponent <Image>().color = Color.Lerp(Obj_UiTime[2].GetComponent <Image>().color, new Color(1, 1, 1, 1), 1.5f * Time.deltaTime);
                    if (Obj_UiTime[2].GetComponent <Image>().color.a >= 0.8f)
                    {
                        bool_LowHp = true;
                    }
                }

                if (Obj_UiTime[2].GetComponent <Image>().fillAmount <= 0.5f)
                {
                    Obj_ScreenEffect.SetActive(true);                   //打開遊戲背景
                    if (bool_ScreenColor)
                    {
                        Obj_ScreenEffect.GetComponent <Image>().color = Color.Lerp(Obj_ScreenEffect.GetComponent <Image>().color, new Color(1, 0, 0, 0.05f), Time.deltaTime);
                        if (Obj_ScreenEffect.GetComponent <Image>().color.a <= 0.06f)
                        {
                            bool_ScreenColor = false;
                        }
                    }
                    else
                    {
                        Obj_ScreenEffect.GetComponent <Image>().color = Color.Lerp(Obj_ScreenEffect.GetComponent <Image>().color, new Color(1, 0, 0, 0.2f), Time.deltaTime);
                        if (Obj_ScreenEffect.GetComponent <Image>().color.a > 0.18f)
                        {
                            bool_ScreenColor = true;
                        }
                    }
                }
            }
            else
            {
                Debug.Log("遊戲失敗");
                Enum_CurrectLevel = enum_Level.GameEnd;                 //遊戲失敗
            }
        }
    }