Categories
Uncategorised

FMP_v2.5_Fake life bar

I can make it

in order not to obscure players’ view of watching the story; do not spend player’s too much time on knowing their current life values, and avoid the repeat experience of the game. I create a fake life display that looks like meta UIs.

As players miss targets, the game view would become redder.

I use sciptable post-processing component to make this function.

In URP, the post-processing component is accomplished by “Volume”

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEngine.Rendering.Universal;
using UnityEngine.Rendering;

public class GameManager : MonoBehaviour
{
    public int score;
    public bool isGameActive;

    public TextMeshProUGUI lifeScoreText;
    public Image gameOverCanvas;

    // post processing
    public Volume m_Volume;
    private Bloom b;
    private ColorAdjustments colorOverlay;

    public L_Target LtargetScript;
    public float metaIndensity = 2;
    // Start is called before the first frame update
    void Start()
    {
        UpdateLifeScore(0);
        isGameActive = true;

        // post processing start
        m_Volume = GetComponent<Volume>();
        m_Volume.profile.TryGet(out b);
        b.dirtIntensity.value = 0;
    }

    // Update is called once per frame
    void Update()
    {
       /* if(LtargetScript.destoryedTarget == true)
        {
            FakeLifeBar(metaIndensity);
        }*/
    }

    public void UpdateLifeScore(int scoreToAdd)
    {
        score += scoreToAdd;
        lifeScoreText.text = "Score: " + score;
    }

    public void GameOver()
    {
        gameOverCanvas.gameObject.SetActive(true);
        isGameActive = false;
    }

    public void RestartGame()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    }

    public void FakeLifeBar(float updateFakeIndensity)
    {
        b.dirtIntensity.value += updateFakeIndensity ;
    }

}

Leave a Reply

Your email address will not be published. Required fields are marked *