using UnityEngine;
using UnityEngine.AI;
public class WolfControl : MonoBehaviour
{
Transform Hero;
public int iTakeDamage =
0;
bool isTakeDamage =
false;
NavMeshAgent agent;
Animation ani;
int count =
0;
void Start()
{
Hero = GameObject.Find(
"[CameraRig]").transform;
agent = GetComponent<NavMeshAgent>();
ani = GetComponent<Animation>();
}
void Update()
{
wolfMove();
}
void wolfMove()
{
float dist = Vector3.Distance(transform.position, Hero.position);
if (dist >
20)
{
if (iTakeDamage !=
2)
{
agent.destination = Hero.position;
}
if (iTakeDamage ==
0)
{
ani.Play(
"Wolf-Walk");
}
else if (iTakeDamage ==
1 && isTakeDamage ==
false)
{
count++;
ani.Play(
"Wolf-Damage1");
if (count >
10)
{
isTakeDamage =
true;
iTakeDamage =
0;
}
else if (iTakeDamage ==
2)
{
ani.Play(
"Wolf-Death");
Destroy(gameObject,
2);
}
}
}
else if (dist <=
20)
{
if (iTakeDamage ==
0)
{
ani.Play(
"Wolf-Attack1");
}
else if (iTakeDamage ==
1 && isTakeDamage ==
false)
{
count++;
ani.Play(
"Wolf-Damage1");
if (count >
10)
{
isTakeDamage =
true;
iTakeDamage =
0;
}
else if (iTakeDamage ==
2)
{
ani.Play(
"Wolf-Death");
Destroy(gameObject,
2);
}
}
}
}
}
using UnityEngine;
public class AK_47Shoot : MonoBehaviour
{
public GameObject bullet;
public Transform pos;
SteamVR_TrackedController stc;
void Start()
{
stc = GetComponent<SteamVR_TrackedController>();
stc.TriggerUnclicked += OnTriggerUnclicked;
}
void Update()
{
}
void OnTriggerUnclicked(
object sender, ClickedEventArgs e)
{
GameObject obj = Instantiate(bullet, pos.position, pos.rotation);
Rigidbody r = obj.GetComponent<Rigidbody>();
r.velocity = -pos.forward *
30;
Destroy(obj,
2);
}
}
using UnityEngine;
public class OnCliiton : MonoBehaviour {
int count =
0;
void Start()
{
}
void OncollisionEnter(Collision orther)
{
if (orther.gameObject.name.Equals(
"WolfNormal(Clone)"))
{
count++;
if(count >
2)
{
return;
}
WolfControl move = orther.gameObject.GetComponent<WolfControl>();
if (move !=
null)
{
move.iTakeDamage = count;
}
}
}
}