revival/game/Assets/Scripts/Character/Glove.cs

71 lines
2.0 KiB
C#
Raw Normal View History

2021-04-16 20:30:49 +02:00
using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using NaughtyAttributes.Test;
2021-05-11 02:48:24 +02:00
using TMPro;
2021-04-16 20:30:49 +02:00
using UnityEngine;
public class Glove : MonoBehaviour
{
[SerializeField] private GameObject[] _cylinders;
[SerializeField] private Transform _graphics;
private TrailRenderer[] _trails;
private Renderer[] _renderers;
// TODO: refactor to settings object
[SerializeField] private float _baseTrailTime;
[SerializeField] private float _blinkTrailTime;
[SerializeField] private float _pulseTime;
[SerializeField] private Material _trailMat;
[SerializeField] private float _emissionScale;
[SerializeField] private float _rotationSpeed;
[SerializeField] private float _scaleFactor;
2021-05-18 16:28:41 +02:00
[SerializeField] private Light _light;
[SerializeField] private float _lightIntensity;
2021-04-16 20:30:49 +02:00
private const string EMISSION_COLOR = "_EmissionColor";
private void Start()
{
_trails = GetComponentsInChildren<TrailRenderer>();
_renderers = GetComponentsInChildren<Renderer>();
foreach (var trail in _trails)
{
trail.time = _baseTrailTime;
}
2021-05-18 16:28:41 +02:00
_lightIntensity = 0;
2021-04-16 20:30:49 +02:00
}
private void LateUpdate()
{
_graphics.Rotate(Vector3.up * (Time.deltaTime * _rotationSpeed));
}
public void Pulse()
{
_graphics.transform.localScale = Vector3.one * _scaleFactor;
_graphics.DOScale(Vector3.one, _pulseTime);
foreach (var trail in _trails)
{
trail.time = _blinkTrailTime;
trail.DOTime(_baseTrailTime, _pulseTime);
}
2021-05-18 16:28:41 +02:00
_light.intensity =
// var baseEmission = _trailMat.GetColor(EMISSION_COLOR);
// var pulseEmission = baseEmission * _emissionScale;
// foreach (var renderer in _renderers)
// {
// renderer.material.SetColor(EMISSION_COLOR, pulseEmission);
// renderer.material.DOColor(baseEmission, _pulseTime);
// }
2021-04-16 20:30:49 +02:00
}
}