getHealth() private method

private getHealth ( ) : double
return double
コード例 #1
0
    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();
        }
    }
コード例 #2
0
    // 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);
        }
    }
コード例 #3
0
 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();
     }
 }
コード例 #5
0
ファイル: HUD.cs プロジェクト: npucci/IAT312_Assignment2
    // 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];
    }
コード例 #6
0
 // 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);
     }
 }
コード例 #7
0
    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");
    }
コード例 #8
0
 // Update is called once per frame
 void Update()
 {
     if (!crashed && janus && (janus.isActiveAndEnabled || dontCheckActive) && janus.getHealth() <= janus.maxHealth * landPercentage)
     {
         StartCoroutine(Land());
     }
 }
コード例 #9
0
 private void Update()
 {
     if (health)
     {
         SetHealth(health.getHealth() / health.getMaxHealth());
     }
 }
コード例 #10
0
 private void Update()
 {
     if (health.getHealth() <= 0)
     {
         Destroy(this.gameObject);
     }
 }
コード例 #11
0
    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));
    }
コード例 #12
0
    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");
    }
コード例 #14
0
ファイル: EnemyLevel1.cs プロジェクト: jtmckay2017/CS425Final
    // 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");
        }
    }
コード例 #15
0
ファイル: CheckWin.cs プロジェクト: jkmann/Tanks-Vs-Monsters
 // 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");
     }
 }
コード例 #16
0
 // 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;
         }
     }
 }
コード例 #17
0
 // Update is called once per frame
 void Update()
 {
     if (h.getHealth() <= 0)
     {
         StartCoroutine(Hide());
     }
 }
コード例 #18
0
ファイル: UIScript.cs プロジェクト: scadan/Zombie-Tutorial
    // 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;
        }
    }
コード例 #19
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;
        }
    }
コード例 #20
0
ファイル: HealthBarUI.cs プロジェクト: CodeShaper13/Office
    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;
         */
    }
コード例 #21
0
ファイル: possess.cs プロジェクト: Kayskip/ProjectParasite
 void Start()
 {
     spriteR   = gameObject.GetComponent <SpriteRenderer>();
     preSprite = spriteR.sprite;
     health    = gameObject.GetComponent <Health>();
     preHealth = health.getHealth();
     shoot     = gameObject.GetComponent <shooting>();
 }
コード例 #22
0
ファイル: CombatantDeath.cs プロジェクト: Codetroopa/Talisman
 // Update is called once per frame
 void Update()
 {
     if (hp.getHealth() == 0)
     {
         Destroy(gameObject);
         //TODO: Fancy death animations
     }
 }
コード例 #23
0
    // 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;
            }
        }
    }
コード例 #24
0
 //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());
     }
 }
コード例 #25
0
    public void publish()
    {
        float percentage = 100 * (float)npcHealth.getHealth() / (float)npcHealth.getMaxHealth();

        if (percentage <= 20)
        {
            convert();
            flight();
        }
    }
コード例 #26
0
    // Update is called once per frame
    void Update()
    {
        if (healthScript.getHealth() < 25)
        {
            currBehaviour = Behaviours.Heal;
        }
        RunBehaviours();

        //agent.SetDestination(points[destPoint].transform.position);
    }
コード例 #27
0
    /*
     * 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);
    }
コード例 #28
0
 // 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;
     }
 }
コード例 #29
0
 //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));
     }
 }
コード例 #30
0
 void Update()
 {
     target = cc.getTarget();
     if (target)
     {
         healthComponent = target.GetComponent <Health> ();
         int healthCount;
         healthCount     = healthComponent.getHealth();
         healthText.text = healthCount.ToString();
     }
 }