155 lines
3.2 KiB
C#
155 lines
3.2 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2020-09-02
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "Ef_thump" company="Kimch"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace G
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 重击
|
|||
|
/// </summary>
|
|||
|
public class Ef_thump : MonoBehaviour
|
|||
|
{
|
|||
|
public Transform rising_fire;
|
|||
|
public Transform rising_fire2;
|
|||
|
|
|||
|
private Transform _cha1;
|
|||
|
|
|||
|
private BoxCollider _collider;
|
|||
|
|
|||
|
private Renderer _renderer;
|
|||
|
|
|||
|
private float _showTime = 1.5f;
|
|||
|
|
|||
|
private float _distance;
|
|||
|
|
|||
|
private Color _originTintcolor;
|
|||
|
|
|||
|
private bool _collidsionOn;
|
|||
|
|
|||
|
private bool _showOn;
|
|||
|
|
|||
|
Vector3 _sourceSize;
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
_collider = this.GetComponent<BoxCollider>();
|
|||
|
_renderer = this.transform.Find("Quad").GetComponent<Renderer>();
|
|||
|
_sourceSize = _collider.size;
|
|||
|
}
|
|||
|
|
|||
|
private void Start()
|
|||
|
{
|
|||
|
_cha1 = EntityMainPlayer.Instance.transform;
|
|||
|
_renderer.enabled = false;
|
|||
|
_collider.enabled = false;
|
|||
|
rising_fire.gameObject.SetActive(false);
|
|||
|
if (rising_fire2)
|
|||
|
rising_fire2.gameObject.SetActive(false);
|
|||
|
|
|||
|
_originTintcolor = _renderer.material.GetTintColor();
|
|||
|
this.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
public void SetType(int type)
|
|||
|
{
|
|||
|
if (type == 3)
|
|||
|
{
|
|||
|
rising_fire.gameObject.SetActive(false);
|
|||
|
if (rising_fire2)
|
|||
|
rising_fire2.gameObject.SetActive(true);
|
|||
|
Vector3 tmpSize = _sourceSize;
|
|||
|
tmpSize.x *= 2f;
|
|||
|
_collider.size = tmpSize;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
rising_fire.gameObject.SetActive(true);
|
|||
|
if (rising_fire2)
|
|||
|
rising_fire2.gameObject.SetActive(false);
|
|||
|
_collider.size = _sourceSize;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void SplashOn(bool col, float distance, float delay)
|
|||
|
{
|
|||
|
_collidsionOn = col;
|
|||
|
_showTime = 1.5f;
|
|||
|
_renderer.material.SetTintColor(_originTintcolor);
|
|||
|
|
|||
|
_distance = distance;
|
|||
|
Invoke(nameof(ShowOn), delay);
|
|||
|
}
|
|||
|
|
|||
|
public void SplashOff()
|
|||
|
{
|
|||
|
if (_collider.enabled)
|
|||
|
{
|
|||
|
_collider.enabled = false;
|
|||
|
}
|
|||
|
this.gameObject.SetActive(false);
|
|||
|
CancelInvoke(nameof(ShowOn));
|
|||
|
}
|
|||
|
|
|||
|
public void ShowOn()
|
|||
|
{
|
|||
|
this.gameObject.SetActive(true);
|
|||
|
this.transform.SetPositionAndRotation(_cha1.TransformPoint(new Vector3(0f, 0.02f, _distance)), _cha1.rotation);
|
|||
|
|
|||
|
rising_fire.gameObject.SetActive(true);
|
|||
|
|
|||
|
_renderer.enabled = true;
|
|||
|
if (_collidsionOn)
|
|||
|
{
|
|||
|
_collider.enabled = true;
|
|||
|
}
|
|||
|
_showOn = true;
|
|||
|
}
|
|||
|
|
|||
|
private void Update()
|
|||
|
{
|
|||
|
if (!_showOn)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
_showTime -= Time.deltaTime;
|
|||
|
if (_showTime > 1.2f)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
else if (_showTime > 0.5f)
|
|||
|
{
|
|||
|
if (_collider.enabled)
|
|||
|
{
|
|||
|
_collider.enabled = false;
|
|||
|
}
|
|||
|
}
|
|||
|
else if (_showTime > 0f)
|
|||
|
{
|
|||
|
if (_collider.enabled)
|
|||
|
{
|
|||
|
_collider.enabled = false;
|
|||
|
}
|
|||
|
var tintColor = _renderer.material.GetTintColor();
|
|||
|
var transColor = Color.Lerp(tintColor, Color.clear, Time.deltaTime * 14f);
|
|||
|
_renderer.material.SetTintColor(transColor);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.gameObject.SetActive(false);
|
|||
|
this.transform.position = Vector3.up * 100f;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|