Advertisement
Wolvenspud

EW - emuScript

Nov 5th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class emuScript : MonoBehaviour {
  5.  
  6.     public float speed = 1;
  7.     public int hp = 10;
  8.     public GameObject self;
  9.     public int yield = 30;
  10.  
  11.     bool move = true;
  12.     bool OkieDokie = false;
  13.  
  14.     float okieTimer = 0;
  15.  
  16.     public void Update()
  17.     {
  18.         if (move)
  19.         {
  20.             transform.Translate(Vector3.forward * Time.deltaTime * speed);
  21.         }
  22.  
  23.         if (OkieDokie)
  24.         {
  25.             okieTimer += Time.deltaTime;
  26.             if (okieTimer > 0.05f)
  27.             {
  28.                 move = true;
  29.                 okieTimer = 0;
  30.                 OkieDokie = false;
  31.             }
  32.         }
  33.     }
  34.  
  35.     public void OnTriggerEnter(Collider other)
  36.     {
  37.         if (other.tag == "proj1")
  38.         {
  39.             hp -= 1;
  40.             if (hp > 1)
  41.             {
  42.                 globalValues.alterMoney(yield);
  43.                 Destroy(self);
  44.             }
  45.         }
  46.         if (other.tag == "unit3")
  47.         {
  48.             hp -= 8;
  49.             if (hp > 1)
  50.             {
  51.                 globalValues.alterMoney(yield);
  52.                 Destroy(self);
  53.             }
  54.         }
  55.         if (other.tag == "goal")
  56.         {
  57.             Destroy(self);
  58.         }
  59.     }
  60.  
  61.     public void OnTriggerStay(Collider other)
  62.     {
  63.         if (other.tag == "emu" || other.tag == "unit1" || other.tag == "unit2" || other.tag == "unit3" || other.tag == "unit4")
  64.         {
  65.             move = false;
  66.            
  67.             //anim state
  68.         }
  69.  
  70.         else
  71.         {
  72.             move = true ;
  73.         }
  74.     }
  75.  
  76.     public void Move()
  77.     {
  78.         OkieDokie = true;
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement