初期コミット
This commit is contained in:
71
Assets/Yurowm/Demo/Scripts/Actions.cs
Normal file
71
Assets/Yurowm/Demo/Scripts/Actions.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
[RequireComponent (typeof (Animator))]
|
||||
public class Actions : MonoBehaviour {
|
||||
|
||||
private Animator animator;
|
||||
|
||||
const int countOfDamageAnimations = 3;
|
||||
int lastDamageAnimation = -1;
|
||||
|
||||
void Awake () {
|
||||
animator = GetComponent<Animator> ();
|
||||
}
|
||||
|
||||
public void Stay () {
|
||||
animator.SetBool("Aiming", false);
|
||||
animator.SetFloat ("Speed", 0f);
|
||||
}
|
||||
|
||||
public void Walk () {
|
||||
animator.SetBool("Aiming", false);
|
||||
animator.SetFloat ("Speed", 0.5f);
|
||||
}
|
||||
|
||||
public void Run () {
|
||||
animator.SetBool("Aiming", false);
|
||||
animator.SetFloat ("Speed", 1f);
|
||||
}
|
||||
|
||||
public void Attack () {
|
||||
Aiming ();
|
||||
animator.SetTrigger ("Attack");
|
||||
}
|
||||
|
||||
public void Death () {
|
||||
if (animator.GetCurrentAnimatorStateInfo (0).IsName ("Death"))
|
||||
animator.Play("Idle", 0);
|
||||
else
|
||||
animator.SetTrigger ("Death");
|
||||
}
|
||||
|
||||
public void Damage () {
|
||||
if (animator.GetCurrentAnimatorStateInfo (0).IsName ("Death")) return;
|
||||
int id = Random.Range(0, countOfDamageAnimations);
|
||||
if (countOfDamageAnimations > 1)
|
||||
while (id == lastDamageAnimation)
|
||||
id = Random.Range(0, countOfDamageAnimations);
|
||||
lastDamageAnimation = id;
|
||||
animator.SetInteger ("DamageID", id);
|
||||
animator.SetTrigger ("Damage");
|
||||
}
|
||||
|
||||
public void Jump () {
|
||||
animator.SetBool ("Squat", false);
|
||||
animator.SetFloat ("Speed", 0f);
|
||||
animator.SetBool("Aiming", false);
|
||||
animator.SetTrigger ("Jump");
|
||||
}
|
||||
|
||||
public void Aiming () {
|
||||
animator.SetBool ("Squat", false);
|
||||
animator.SetFloat ("Speed", 0f);
|
||||
animator.SetBool("Aiming", true);
|
||||
}
|
||||
|
||||
public void Sitting () {
|
||||
animator.SetBool ("Squat", !animator.GetBool("Squat"));
|
||||
animator.SetBool("Aiming", false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user