You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.5 KiB
58 lines
1.5 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
//Author: ZCG
|
||
|
public class AnimatorControl_ZJ : MonoBehaviour
|
||
|
{
|
||
|
private Animator anim;
|
||
|
/// <summary>固定支架</summary>
|
||
|
public bool control_ZJ = false;
|
||
|
|
||
|
private LineamentEvent _LineamentEvent;
|
||
|
private AgentControl _AgentControl;
|
||
|
private void Start()
|
||
|
{
|
||
|
anim = GetComponent<Animator>();
|
||
|
_LineamentEvent = GetComponent<LineamentEvent>();
|
||
|
_AgentControl = GetComponent<AgentControl>();
|
||
|
}
|
||
|
private bool down;
|
||
|
private void Update()
|
||
|
{
|
||
|
control_ZJ = _LineamentEvent.ControlJuBi;//是否固定支架
|
||
|
AnimatorControl();
|
||
|
}
|
||
|
#region Explain
|
||
|
private bool switchZj;
|
||
|
private void AnimatorControl()
|
||
|
{
|
||
|
//anim.SetFloat("AD", Input.GetAxis("Horizontal"));
|
||
|
//anim.SetFloat("WS", Input.GetAxis("Vertical"));
|
||
|
if (/*Input.GetKeyDown(KeyCode.U)*/
|
||
|
control_ZJ && !down && anim.speed != 0)
|
||
|
{
|
||
|
down = true;
|
||
|
}
|
||
|
if (control_ZJ)
|
||
|
{
|
||
|
_AgentControl.enabled = false;
|
||
|
switchZj = true;
|
||
|
}
|
||
|
|
||
|
if(!control_ZJ&& switchZj)
|
||
|
{
|
||
|
_AgentControl.enabled = true;
|
||
|
switchZj = !switchZj;
|
||
|
}
|
||
|
|
||
|
anim.SetBool("ZJ", down);
|
||
|
if (/*Input.GetKeyDown(KeyCode.L)*/!control_ZJ)
|
||
|
anim.speed = 1;
|
||
|
}
|
||
|
public void AnimStopEvent()
|
||
|
{
|
||
|
anim.speed = 0;
|
||
|
anim.SetBool("ZJ", false);
|
||
|
down = false;
|
||
|
}
|
||
|
#endregion
|
||
|
}
|