Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class emuScript : MonoBehaviour {
- public float speed = 1;
- public int hp = 10;
- public GameObject self;
- public int yield = 30;
- bool move = true;
- bool OkieDokie = false;
- float okieTimer = 0;
- public void Update()
- {
- if (move)
- {
- transform.Translate(Vector3.forward * Time.deltaTime * speed);
- }
- if (OkieDokie)
- {
- okieTimer += Time.deltaTime;
- if (okieTimer > 0.05f)
- {
- move = true;
- okieTimer = 0;
- OkieDokie = false;
- }
- }
- }
- public void OnTriggerEnter(Collider other)
- {
- if (other.tag == "proj1")
- {
- hp -= 1;
- if (hp > 1)
- {
- globalValues.alterMoney(yield);
- Destroy(self);
- }
- }
- if (other.tag == "unit3")
- {
- hp -= 8;
- if (hp > 1)
- {
- globalValues.alterMoney(yield);
- Destroy(self);
- }
- }
- if (other.tag == "goal")
- {
- Destroy(self);
- }
- }
- public void OnTriggerStay(Collider other)
- {
- if (other.tag == "emu" || other.tag == "unit1" || other.tag == "unit2" || other.tag == "unit3" || other.tag == "unit4")
- {
- move = false;
- //anim state
- }
- else
- {
- move = true ;
- }
- }
- public void Move()
- {
- OkieDokie = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement