|
|
@@ -1,4 +1,5 @@
|
|
|
-using System.Collections;
|
|
|
+using System;
|
|
|
+using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
|
|
|
@@ -176,7 +177,9 @@ public class Player : MonoBehaviour
|
|
|
public Transform gunTransform;
|
|
|
public Rigidbody bulletPrefab;
|
|
|
public Light muzzleLight;
|
|
|
+ public Light headLight;
|
|
|
public Transform gauge;
|
|
|
+ public DayTimeManager dayTimeManager;
|
|
|
|
|
|
private Vector3 inputDirection;
|
|
|
private float speed;
|
|
|
@@ -195,6 +198,7 @@ public class Player : MonoBehaviour
|
|
|
speed = startSpeed;
|
|
|
cameraOffset = Camera.main.transform.position - transform.position;
|
|
|
lightIntensity = muzzleLight.intensity;
|
|
|
+ muzzleLight.intensity = 0;
|
|
|
var joystickNames = Input.GetJoystickNames();
|
|
|
useMouseLook = joystickNames.Length == 0 || string.IsNullOrEmpty(joystickNames[0]);
|
|
|
//if (useMouseLook)
|
|
|
@@ -240,12 +244,26 @@ public class Player : MonoBehaviour
|
|
|
if (shooting)
|
|
|
{
|
|
|
Shoot();
|
|
|
- muzzleLight.intensity = Random.Range(.5f, 2f) * lightIntensity;
|
|
|
+ StartCoroutine(FlashMuzzle());
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ headLight.intensity =
|
|
|
+ (dayTimeManager.dayTimeLabel == DayTimeLabel.Night || dayTimeManager.dayTimeLabel == DayTimeLabel.Evening)
|
|
|
+ ? .5f
|
|
|
+ : 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ private IEnumerator FlashMuzzle()
|
|
|
+ {
|
|
|
+ float start = .1f;
|
|
|
+ float initial = UnityEngine.Random.Range(.5f, 2f) * lightIntensity;
|
|
|
+
|
|
|
+ for (float left = start; left > 0; left -= Time.deltaTime)
|
|
|
{
|
|
|
- muzzleLight.intensity = 0;
|
|
|
+ muzzleLight.intensity = Mathf.Lerp(initial, 0, left / start);
|
|
|
+ yield return null;
|
|
|
}
|
|
|
+ muzzleLight.intensity = 0;
|
|
|
}
|
|
|
|
|
|
public float fidgetSpin = 30.0f;
|