using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// boss攻擊玩家產生的震動方法
/// 掛載到主攝像機上
/// </summary>
public class Shake : MonoBehaviour {
private float cameraShake = 2;//震動係數
public GameObject UI;//紅色的背景圖片
void Update () {
if (Gun.Instance.bossAttack)
{
UI.SetActive(true);
//X,Y軸震動
transform.position = new Vector3((Random.Range(0f, cameraShake)) - cameraShake*0.5f, transform.position.y, transform.position.z);
//Z軸震動
transform.position = new Vector3(transform.position.x, transform.position.y, (Random.Range(0f, cameraShake)) - cameraShake * 0.5f);
cameraShake = cameraShake / 1.05f;
if (cameraShake<0.05f)
{
cameraShake= 0;
UI.SetActive(false);
Gun.Instance.bossAttack = false;
}
}
else
{
cameraShake = 5;
}
}
}