private void Update() { if (health.getHealth() > 0) { if (Input.GetButtonDown("Jump") && IsGrounded()) { jump = true; } if (IsGrounded() == false) { jump = false; } GetInput(); if (Input.GetMouseButtonDown(0) && playerGun._canShoot) { playerGun.ShootBullet(); } } if (health.getHealth() > 0) { LookAt(); } }
// Update is called once per frame void Update() { sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, (health.getHealth() / health.getMaxHealth()) / 2 + 0.5f); if (health.getHealth() <= 0) { Destroy(gameObject); } if (chaser) { if (target == null) { PlayerUnit[] foundObjs = FindObjectsOfType <PlayerUnit>(); Vector3 nearestDist = new Vector3(float.MaxValue, float.MaxValue); foreach (PlayerUnit unit in foundObjs) { Vector3 dist = unit.transform.position - transform.position; if (dist.magnitude < nearestDist.magnitude) { nearestDist = dist; target = unit.gameObject; } } } movement.SetMovementAxisValues(target.transform.position.x - transform.position.x, target.transform.position.y - transform.position.y); } }
void Update() { setClampPositions(); if (health.getHealth() <= 0) { Destroy(gameObject); } }
//Update is called once per frame void Update() { { healthBar.maxValue = healthScript.getMaxHealth(); healthBar.value = healthScript.getHealth(); healthTxt.text = "Health:" + healthScript.getHealth(); } }
// Update is called once per frame void Update() { // Health betwen full and 3/4 if (playerHealth.getHealth() <= playerHealth.getMaxHealth() && playerHealth.getHealth() > 3 * playerHealth.getMaxHealth() / 4) { healthIndex = 4; } // Health between 3/4 and 1/2 else if (playerHealth.getHealth() <= 3 * playerHealth.getMaxHealth() / 4 && playerHealth.getHealth() > playerHealth.getMaxHealth() / 2) { healthIndex = 3; } // Health between 1/2 and 1/4 else if (playerHealth.getHealth() <= playerHealth.getMaxHealth() / 2 && playerHealth.getHealth() > playerHealth.getMaxHealth() / 4) { healthIndex = 2; } // Health between 1/4 and 0 else if (playerHealth.getHealth() <= playerHealth.getMaxHealth() / 4 && playerHealth.getHealth() > 0) { healthIndex = 1; } // Health equals or less to 0 else if (playerHealth.getHealth() <= 0) { healthIndex = 0; } GetComponent <Image>().overrideSprite = HPState [healthIndex]; }
// Update is called once per frame void Update() { for (int i = playerHealth.getHealth(); i < playerHealth.getMaxHealth(); i++) { hearts[i].SetActive(false); } for (int i = 0; i < playerHealth.getHealth(); i++) { hearts[i].SetActive(true); } }
void Start() { GameManager manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>(); healthBar = manager.playerHealth; healthTxt = manager.playerHealthTxt; scoreNum = manager.score; timeNum = manager.timeTxt; healthBar.maxValue = healthScript.getMaxHealth(); healthBar.value = healthScript.getHealth(); healthTxt.text = healthScript.getHealth().ToString(); StartCoroutine("updateUI"); }
// Update is called once per frame void Update() { if (!crashed && janus && (janus.isActiveAndEnabled || dontCheckActive) && janus.getHealth() <= janus.maxHealth * landPercentage) { StartCoroutine(Land()); } }
private void Update() { if (health) { SetHealth(health.getHealth() / health.getMaxHealth()); } }
private void Update() { if (health.getHealth() <= 0) { Destroy(this.gameObject); } }
public void InitializeUIController(GameObject pl) { decksize = -1; //this.cardcount = cardcount; currentPlayer = pl; //DeckTest a = (DeckTest) GameObject.FindGameObjectWithTag ("DeckTest").GetComponent("DeckTest"); //currentDeck = a.startingDeck; currentDeck = pl.GetComponent <PlayerMulti> ().currentDeck; playerHealth = pl.GetComponent <Health>(); maxHealth = playerHealth.getHealth(); maxCards = currentDeck.DeckCount(); crl = (CardResourceLoader)GameObject.Find("CardResourceLoader").GetComponent("CardResourceLoader"); cards = new ArrayList(); int count = 0; handColor = hand.color; foreach (string cardname in currentDeck.GetHand()) { GameObject current = (GameObject)Instantiate(cardobject, new Vector2(STARTING_POSITION_X + CARD_VARIANCE * count, STARTING_POSITION_Y), Quaternion.identity); current.transform.SetParent(canvas.transform, false); current.GetComponent <Image>().sprite = Sprite.Create(crl.Get2DCardReference(cardname), CARD_SIZE, Vector2.zero); Texture2D currentTexture = crl.Get2DCardReference(cardname); current.GetComponent <Image>().sprite = Sprite.Create(currentTexture, new Rect(0, 0, currentTexture.width, currentTexture.height), Vector2.zero); cards.Add(current); count++; } //GameObject selection = cards[currentDeck.GetSelectedCard()] as GameObject; //StartCoroutine(SelectedCardControl(selection, 20f)); }
private void updateHealth() { float fractionHealth = playerHealth.getHealth() / (float)playerHealth.getMaxHealth(); healthNumberText.text = System.Math.Round(fractionHealth * 100, 0).ToString() + "%"; healthBar.transform.localScale = new Vector3(fractionHealth, 1.0F, 1.0F); }
void Start() { // This section of the script imports to the GameManager and allows the UI to function effectively. healthScript = GetComponent <Health>(); GameManager manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>(); healthBar = manager.playerHealth; healthTxt = manager.playerHealthTxt; scoreNum = manager.score; timeNum = manager.timeTxt; healthBar.maxValue = healthScript.getMaxHealth(); healthBar.value = healthScript.getHealth(); healthTxt.text = "Health: " + healthScript.getHealth(); StartCoroutine("updateUI"); }
// Update is called once per frame void Update() { if (behavior != null) { behavior.run(); } else { BuildBehaviorTree(); } isPlayerNear(); //chasePlayer(); if (isShotByPlayer) { chaseDownTimer(); } //patrol(); if (myHealth.getHealth() <= 0) { Debug.Log("Dead"); } }
// Update is called once per frame void Update() { if (BossAI.getHealth() <= 0 && hasEnded == false) { //winOrLose.text = "You Win!"; print("you win!"); result = won; timeOfEvent = timerText.getTime(); AudioSource.PlayClipAtPoint(victory, Camera.main.transform.position); hasEnded = true; } else if (Health.getHealth() <= 0 && hasEnded == false) { //winOrLose.text = "You Lose!"; timeOfEvent = timerText.getTime(); AudioSource.PlayClipAtPoint(loss, Camera.main.transform.position); result = lost; hasEnded = true; } else if (hasEnded == false) { winOrLose.text = " "; } if (hasEnded == true) { winOrLose.text = result; StartCoroutine("DelayStart"); print("loading menu"); } }
// Update is called once per frame void Update() { if (healthObjective) { if (healthComponent.getHealth() <= healthTreshold) { lossMenu.transform.parent.gameObject.SetActive(true); lossMenu.SetActive(true); lossMenu.GetComponentInChildren <Text>().text = healthStr; Time.timeScale = 0; } } if (pointsObjective) { if (pointsComponent.getPoints() <= pointsCount) { lossMenu.transform.parent.gameObject.SetActive(true); lossMenu.SetActive(true); lossMenu.GetComponentInChildren <Text>().text = pointsStr; Time.timeScale = 0; } } if (timeObjective) { if (Time.timeSinceLevelLoad >= timeInSeconds) { lossMenu.transform.parent.gameObject.SetActive(true); lossMenu.SetActive(true); lossMenu.GetComponentInChildren <Text>().text = timeStr; Time.timeScale = 0; } } }
// Update is called once per frame void Update() { if (h.getHealth() <= 0) { StartCoroutine(Hide()); } }
// Update is called once per frame void Update() { healthBar.maxValue = healthScript.getMaxHealth(); healthBar.value = healthScript.getHealth(); healthText.text = "Health: " + healthScript.getHealth(); timeNum.text = "" + (int)Time.time; scoreNum.text = score + ""; if (healthScript.IsDead) { youLoseCanvas.SetActive(true); Time.timeScale = 0; } }
// Update is called once per frame private void FixedUpdate() { bar.game.JorgeHP = health.getHealth(); if (Input.GetKey("d")) { transform.eulerAngles = new Vector3(0, 0, 0); rb.velocity = new Vector2(6, rb.velocity.y); } else if (Input.GetKey("a")) { transform.eulerAngles = new Vector3(0, -180, 0); rb.velocity = new Vector2(-6, rb.velocity.y); } if (Input.GetKey("w") && grounded) { rb.velocity = new Vector2(rb.velocity.x, 20); grounded = false; onWall = false; } else if (Input.GetKey("w") && onWall && direction.rotation.y == 0) { transform.eulerAngles = new Vector3(0, -180, 0); rb.velocity = new Vector2(-6, 20); onWall = false; } else if (Input.GetKey("w") && onWall && direction.rotation.y != 0) { transform.eulerAngles = new Vector3(0, 0, 0); rb.velocity = new Vector2(6, 20); onWall = false; } }
public void updateHealthBar(Health health) { Color c; int hp = health.getHealth(); if (hp > 50) { c = this.healthGreen; } else if (hp > 25) { c = this.healthOrange; } else { c = this.healthRed; } this.healthSliderImage.color = c; this.healthSlider.value = hp / 100f; /* * this.healthImage.color = c; * this.healthImage.fillAmount = hp / 100f; */ }
void Start() { spriteR = gameObject.GetComponent <SpriteRenderer>(); preSprite = spriteR.sprite; health = gameObject.GetComponent <Health>(); preHealth = health.getHealth(); shoot = gameObject.GetComponent <shooting>(); }
// Update is called once per frame void Update() { if (hp.getHealth() == 0) { Destroy(gameObject); //TODO: Fancy death animations } }
// Update is called once per frame void Update() { sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, (health.getHealth() / health.getMaxHealth()) / 2 + 0.5f); if (health.getHealth() <= 0 && !dead) { if (ID != 0) { PlayerCommander.instance.unitDeath(ID == 1); dead = true; } else { Destroy(gameObject); dead = true; } } }
//collision method private void OnCollisionEnter2D(Collision2D collision) { //Lose health when colliding with player projectile if (collision.gameObject.tag == "Player Projectile") { health.subtractHealth(collision.gameObject.GetComponent <BProjectile>().damage); Debug.Log(health.getHealth()); } }
public void publish() { float percentage = 100 * (float)npcHealth.getHealth() / (float)npcHealth.getMaxHealth(); if (percentage <= 20) { convert(); flight(); } }
// Update is called once per frame void Update() { if (healthScript.getHealth() < 25) { currBehaviour = Behaviours.Heal; } RunBehaviours(); //agent.SetDestination(points[destPoint].transform.position); }
/* * private void Start() * { * healthBar = GetComponent<Image>(); * } */ // Update is called once per frame private void damageUpdateOnHealthBar(Health healthProperties) { float health = healthProperties.getHealth(); //float maxHealth = healthProperties.maxHealth; // float ratio = health / maxHealth; setFillAmount((int)health); }
// Update is called once per frame void Update() { if (!healing && thisHealth.getHealth() <= 0) { StartCoroutine(HealBoss()); healing = true; } if (!funcCalled && bossHealth.getHealth() <= 0) { if (bcEnable) { bcEnable.enabled = true; } if (bcDisable) { bcDisable.enabled = false; } funcCalled = true; } }
//collision method private void OnCollisionEnter2D(Collision2D collision) { //take damage if hit by projectile and is not invincible, flash for damage and initiate invincibility if (collision.gameObject.tag == "Projectile" && !invincible) { playerHP.subtractHealth(collision.gameObject.GetComponent <BProjectile>().damage); Debug.Log(playerHP.getHealth()); StartCoroutine(collideFlash(1f)); StartCoroutine(invinciblePhase(1f)); } }
void Update() { target = cc.getTarget(); if (target) { healthComponent = target.GetComponent <Health> (); int healthCount; healthCount = healthComponent.getHealth(); healthText.text = healthCount.ToString(); } }