private void OnTriggerStay2D(Collider2D collision) { if (collision.gameObject.CompareTag(TargetTag)) { if (Time.time >= nextShock) { HealthKeeper Hk = collision.GetComponent <HealthKeeper>(); if (Hk != null) { nextShock = Time.time + shockCooldown; anim.SetBool("active", true); Hk.Hurt(damage); } else { anim.SetBool("active", false); } } else { anim.SetBool("active", false); } } else { anim.SetBool("active", false); } }
void Die() { LevelManager manager = GameObject.Find("LevelManager").GetComponent <LevelManager>(); manager.LoadLevel("Win"); Destroy(gameObject); HealthKeeper.Reset(); }
// Use this for initialization void Start() { enemyScript = GetComponent <EnemyScript> (); rb = GetComponent <Rigidbody> (); coroutineRunning = false; healthKeeper = FindObjectOfType <HealthKeeper> (); upRotation = transform.rotation; }
void Start() { healthKeeper = GameObject.FindObjectOfType <HealthKeeper>(); float distance = transform.position.z - Camera.main.transform.position.z; Vector3 leftmost = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distance)); Vector3 rightmost = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, distance)); xmin = leftmost.x + padding; xmax = rightmost.x - padding; }
void Start() { GameObject playerHealthObject = GameObject.FindWithTag ("HealthKeeper"); if (playerHealthObject != null) { healthKeeper = playerHealthObject.GetComponent <HealthKeeper> (); } if (healthKeeper == null) { Debug.Log ("Can't find 'HealthKeeper' script"); } spawnerScript = GetComponent<SpawnerScript> (); PlayAgainButton (); }
private void Start() { // Distance between the camera and the playrt float zDistance = transform.position.z - Camera.main.transform.position.z; Vector3 leftMost = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, zDistance)); Vector3 rightMost = Camera.main.ViewportToWorldPoint(new Vector3(1, 1, zDistance)); xMin = leftMost.x + padding; xMax = rightMost.x - padding; // Set starting health healthKeeper = GameObject.FindObjectOfType <HealthKeeper>(); }
// Use this for initialization void Start() { float distance = transform.position.z - Camera.main.transform.position.z; Vector3 leftmost = Camera.main.ViewportToWorldPoint(new Vector3(0f, 0f, distance)); Vector3 rightmost = Camera.main.ViewportToWorldPoint(new Vector3(1F, 0f, distance)); //set the borders of the restains of movements xmin = leftmost.x + padding; xmax = rightmost.x - padding; //get current health from static variable health = maxHealth; healthKeeper = GameObject.Find("Health").GetComponent <HealthKeeper>(); healthKeeper.DisplayHealth(health); }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag(TargetTag)) { HealthKeeper hk = collision.gameObject.GetComponent <HealthKeeper>(); if (hk) { hk.Hurt(damage); } } if (effect) { Instantiate(effect, transform.position, transform.rotation); } Destroy(gameObject); }
// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); playerScript = player.GetComponent <PlayerScript> (); GameObject playerHealthObject = GameObject.FindWithTag("HealthKeeper"); if (playerHealthObject != null) { healthKeeper = playerHealthObject.GetComponent <HealthKeeper> (); } else { //Debug.Log ("Can't find 'HealthKeeper' script"); } //print ("Yay I'm alive hp boost"); Destroy(gameObject, 4f); }
/////////////////////////////////////////////////////////////////////////////// //Shoot by enemy public void OnTriggerEnter2D(Collider2D collider) { //Debug.Log(collider); Projectile missile = collider.gameObject.GetComponent <Projectile>(); if (missile) //missile exist { playerHealth -= missile.GetDamage(); HealthKeeper.HP(missile.GetDamage()); missile.Hit(); if (playerHealth <= 0) { Die(); } Debug.Log("Hit by enemy" + playerHealth + " " + gameObject.GetInstanceID()); } }
void Start() { PoolScript = thePool.GetComponent <thepool> (); GameObject playerHealthObject = GameObject.FindWithTag("HealthKeeper"); if (playerHealthObject != null) { healthKeeper = playerHealthObject.GetComponent <HealthKeeper> (); } if (healthKeeper == null) { //Debug.Log ("Can't find 'HealthKeeper' script"); } spawnerScript = GetComponent <SpawnerScript> (); //PlayAgainButton (); }
// Use this for initialization void Start() { healthKeeper = GameObject.Find("Health").GetComponent <HealthKeeper>(); }
public void SetTarget(HealthKeeper target) { this.target = target; }
private void Awake() { stats = new GenericStats(Random.Range(1, 3), Random.Range(1, 3)); healthKeeper = (HealthKeeper)FindObjectOfType <HealthKeeper>(); }
void Start() { levelManager = GameObject.FindObjectOfType<LevelManager>(); healthKeeper = GameObject.Find("Health").GetComponent<HealthKeeper>(); }
// Use this for initialization private void Start() { healthKeeper = FindObjectOfType <HealthKeeper>(); SetUpMoveBoundaries(); }