Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (!_oscillating)
     {
         return;
     }
     if (_factorGrowing)
     {
         if (_powerFactor + (float)(Time.deltaTime * 1.5) > _factorUpperBound)
         {
             _powerFactor   = _factorUpperBound;
             _factorGrowing = false;
         }
         else
         {
             _powerFactor += (float)(Time.deltaTime * 1.5);
         }
         // print(_powerFactor);
         healthbar.SetHealth(GetPercentage(_powerFactor));
     }
     else
     {
         if (_powerFactor - (float)(Time.deltaTime * 1.5) < _factorLowerBound)
         {
             _powerFactor   = _factorLowerBound;
             _factorGrowing = true;
         }
         else
         {
             _powerFactor -= (float)(Time.deltaTime * 1.5);
         }
         // print(_powerFactor);
         healthbar.SetHealth(GetPercentage(_powerFactor));
     }
 }
Exemplo n.º 2
0
 private void Start()
 {
     data.isAlive = true;
     healthbar.SetMaxHealth(data.maxHealth);
     healthbar.SetHealth(data.health);
     StartCoroutine(ShootingCoroutine());
     if (data.boolSettings["SwipeMovement"])
     {
         inputLayer.OnBeginDragAction += StartOffsetMovement;
         inputLayer.OnDragAction      += DoOffsetMovement;
     }
     else
     {
         inputLayer.OnPointerDownAction += MouseFollowMovement;
         inputLayer.OnDragAction        += MouseFollowMovement;
     }
     transform.localScale *= data.scaling;
     //if (!data.boolSettings["PlayMusic"])
     //{
     //    audioSourceMusic.volume = 0;
     //}
     particleSystemFire1.Play();
     particleSystemFire2.Play();
     SetVolumes();
     SetPlayerColor();
 }
Exemplo n.º 3
0
 void TakeDamage(int damge)
 {
     currentHealth -= damge;
     if (currentHealth < minHealth)
     {
         currentHealth = minHealth;
     }
     healthBar.SetHealth(currentHealth);
 }
Exemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     isRateIncreasing = true;
     quarantineTraker.SetMaxHealth(deathTreshold);
     lastIncreaseTime  = Time.time;
     quarantineEnabled = false;
     virusCount        = 0;
     quarantineTraker.SetHealth(virusCount);
 }
Exemplo n.º 5
0
 public void Heal(int amount)
 {
     currentHealth += amount;
     if (currentHealth > maxHealth)
     {
         currentHealth = maxHealth;
     }
     healthbar.SetHealth(currentHealth);
 }
    public void HealToFull()
    {
        health = info.maxHealth;

        if (healthbar == null && _terrainInfo != null)
        {
            return;
        }

        healthbar.SetHealth(health, info.maxHealth);
    }
Exemplo n.º 7
0
    void TakeDamage(int damage)
    {
        if (currentHealth > 0)
        {
            currentHealth -= damage;
            healthbar.SetHealth(currentHealth);

            //Sets our animator to show "damage taken"
            animator.SetTrigger("playerHurt");
        }
    }
Exemplo n.º 8
0
    public void RecieveDamage(float damageTaken)
    {
        health -= Mathf.FloorToInt(damageTaken);

        healthBar.SetHealth(health);

        if (health <= 0f)
        {
            Death();
        }
    }
Exemplo n.º 9
0
    void UpdateFood()
    {
        if (foodLvl.health > 0)
        {
            foodLvl.SetHealth(foodLvl.health - 10);
        }

        if (foodLvl.health <= 0)
        {
            healthLvl.SetHealth(healthLvl.health - 25f);
        }
    }
Exemplo n.º 10
0
 void TakeDamage(int damage)
 {
     Animator.SetBool("hurt", true);
     currentHealth -= damage;
     Healthbar.SetHealth(currentHealth);
     StartCoroutine(AnimationDisableCoroutine());
 }
Exemplo n.º 11
0
 private void Electrocute()
 {
     m_Healthbar.SetHealth(0);
     m_Animator.SetTrigger("Electrocuted");
     m_Rigidbody2D.velocity     = new Vector2(0, 0);
     m_Rigidbody2D.gravityScale = 0;
 }
Exemplo n.º 12
0
    IEnumerator Init()
    {
        yield return(new WaitForSeconds(0.5f));

        oxygenLvl   = GameObject.Find("oxygenValue").GetComponent <Healthbar>();
        healthLvl   = GameObject.Find("healthValue").GetComponent <Healthbar>();
        powerLvl    = GameObject.Find("powerValue").GetComponent <Healthbar>();
        suitTempLvl = GameObject.Find("suitTempValue").GetComponent <Healthbar>();
        foodLvl     = GameObject.Find("hungerValue").GetComponent <Healthbar>();

        tempText        = GameObject.Find("tempValue").GetComponent <Text>();
        playerAstronaut = GameObject.Find("Player_Astronaut");

        InvokeRepeating(nameof(UpdateOxygen), 4, 4.0f);
        InvokeRepeating(nameof(UpdatePower), 60, 180);
        InvokeRepeating(nameof(UpdateTemp), 0, 5.0f);
        InvokeRepeating(nameof(UpdateSuitTemp), 0, 5.0f);
        InvokeRepeating(nameof(UpdateFood), 120, 120);

        oxygenLvl.SetHealth(100);
        healthLvl.SetHealth(100);
        powerLvl.SetHealth(100);
        foodLvl.SetHealth(100);
        temp = 100f;
    }
Exemplo n.º 13
0
 private void Awake()
 {
     enemy = GetComponent <Enemy>();
     healthbar.maximumHealth = enemy.Hp;
     healthbar.health        = enemy.Hp;
     enemy.OnHpChanged      += (hp) => healthbar.SetHealth(hp);
 }
Exemplo n.º 14
0
 void onUpdate(GameObject obj, Healthbar bar)
 {
     if (inspector.setScriptsFrom(obj))
     {
         bar.SetHealth(inspector.getLives());
     }
 }
Exemplo n.º 15
0
 void Start()
 {
     currentHealth = maxHealth / 2;
     currentArmor  = 0f;
     gasOn         = false;
     if (SaveManager.instance.hasLoaded)
     {
         currentHealth = SaveManager.instance.activeSave.health;
         currentArmor  = SaveManager.instance.activeSave.armor;
         gasOn         = SaveManager.instance.activeSave.gasOn;
     }
     healthBar.SetMaxHealth(maxHealth);
     healthBar.SetHealth(currentHealth);
     armorBar.SetMaxArmor(maxArmor);
     armorBar.SetArmor(currentArmor);
 }
Exemplo n.º 16
0
    void Update()
    {
        staminaBar.SetHealth((int)stamina);
        staminaText.text = (int)stamina + "/" + (int)maxStamina;

        timer     += Time.deltaTime;
        movement.x = joystick.Horizontal;
        movement.y = joystick.Vertical;

        if (movement.x != 0)
        {
            memoryMovementX = movement.x;
        }

        if (movement.x == 0 && movement.y == 0)
        {
            resetNeeded = false;
        }

        if (joystick.Direction.sqrMagnitude >= distanceFromCenterToRun && stamina > 0 && !resetNeeded)
        {
            isRunning = true;
            animator.SetBool("isRunning", true);
        }
        else if (joystick.Direction.sqrMagnitude >= distanceFromCenterToRun && stamina == 0)
        {
            resetNeeded = true;
            isRunning   = false;
            animator.SetBool("isRunning", false);
        }
        else
        {
            isRunning = false;
            animator.SetBool("isRunning", false);
        }

        if (memoryMovementX < 0)
        {
            GetComponent <SpriteRenderer>().flipX = true;
        }
        else
        {
            GetComponent <SpriteRenderer>().flipX = false;
        }

        if (timer >= 1)
        {
            if (isRunning)
            {
                stamina -= staminaLostOnRun;
            }
            if (!isRunning && stamina < maxStamina)
            {
                stamina += staminaGainedOnRest;
            }
            timer = 0;
        }

        animator.SetFloat("Speed", joystick.Direction.sqrMagnitude);
    }
Exemplo n.º 17
0
 // Update is called once per frame
 void Update()
 {
     healthText = playerCombat.currentHealth + "/" + playerCombat.maxHealth;
     setHpText(healthText);
     playerHealthbar.SetHealth(playerCombat.currentHealth);
     attackSpeedBarUpdate();
 }
Exemplo n.º 18
0
    void TakeDamage(int damage)
    {
        currentHealth -= damage;
        healthbar.SetHealth(currentHealth);

        if (currentHealth == 10)
        {
            InvokeRepeating("Fire", 3, 5f);
        }

        if (currentHealth == 7)
        {
            // InvokeRepeating("Fire", 3, 5f);
            CancelInvoke();
        }

        if (currentHealth <= 5)
        {
            InvokeRepeating("Fire", 3, 5f);
        }

        if (currentHealth <= 0)
        {
            Destroy(bossone);
            Transform newExplosion = Instantiate(B1explosion, transform.position, transform.rotation);
            Destroy(newExplosion.gameObject, 6.5f);
        }
    }
Exemplo n.º 19
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag.Equals("Enemy"))
     {
         currenthealth = currenthealth - damage;
         healthbar.SetHealth(currenthealth);
     }
 }
Exemplo n.º 20
0
 void TakeDamage(int damage)
 {
     if (currentHealth > 0)
     {
         currentHealth -= damage;
         healthbar.SetHealth(currentHealth);
     }
 }
Exemplo n.º 21
0
 public virtual void Update()
 {
     if (healthbar)
     {
         healthbar.SetHealth(GetHealthPercentage());
         healthbar.transform.position = Camera.main.WorldToScreenPoint(transform.position + Vector3.right * width / 2f + Vector3.right);
     }
 }
Exemplo n.º 22
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.name == "NewPC")
     {
         PlayerHealth.SetHealth(PlayerHealth.CurrentValue - 10);
         LevelManager.RespawnPlayer();
     }
 }
Exemplo n.º 23
0
 //fall sem lætur leikmann fá damage
 void TakeDamage(int damage)
 {
     currentHealth -= damage;
     healthbar.SetHealth(currentHealth);
     if (currentHealth <= 0)
     {
         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
     }
 }
Exemplo n.º 24
0
    private void UpdateHealth()
    {
        if (currentHealth < 6)
        {
            currentHealth = 6;
        }

        healthbar.SetHealth(currentHealth, maxHealth);
    }
Exemplo n.º 25
0
    public void TakeDamage()
    {
        int damage = 10;

        health = Max(health - damage, 0);
        animator.SetInteger("Health", health);
        animator.SetTrigger("TookDamage");
        healthbar.SetHealth(health);
    }
Exemplo n.º 26
0
    public void TakeDamage(int damage)
    {
        //Increase the affection with the amount of damage the player takes
        currentAffection += damage;
        healthBar.SetHealth(currentAffection);

        //If affection reaches 10, player gets "stunned" by love
        if (currentAffection == maxAffection)
        {
            playerStunned     = true;
            movement2.enabled = false;
            Rigidbody2D rb = gameObject.GetComponent <Rigidbody2D>();
            rb.constraints = RigidbodyConstraints2D.FreezeAll;
            Debug.Log("Stunned");
            StartCoroutine("StunDuration");
            heartBig.SetActive(true);
            Destroy(gameObject);
        }
    }
Exemplo n.º 27
0
 //Getter und Setter
 public void TakeDamage(int damage)
 {
     currentHealth -= damage;
     healthbar.SetHealth(currentHealth);
     //if <= 0 do kill, gamehandler check ob alle units kill, then if yes win for other player
     if (currentHealth <= 0)
     {
         SetAlive(false);
     }
 }
Exemplo n.º 28
0
 public void AttackDamageRecieved(int damage)
 {
     // Takes damage when in a certain range
     if (InRange(100f))
     {
         health -= damage;
         healthBar.SetHealth(health);
         healthBar.gameObject.SetActive(true);
     }
 }
Exemplo n.º 29
0
    private void Start()
    {
        healthbar.maximumHealth = playerData.maxHp;
        healthbar.health        = playerData.maxHp;
        Enemy.OnAnyEnemyDie    += () => AddKillCount();

        PlayerData.inst.OnDamaged   += (dmg) => OnPlayerDamaged(dmg);
        PlayerData.inst.OnHpUpdated += (value) => healthbar.SetHealth(value);
        PlayerData.inst.OnDied      += () => OnPlayerDied();
    }
Exemplo n.º 30
0
    void Start()
    {
        gameMaster = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>();
        move       = GetComponent <MoveableObject>();
        live       = GetComponent <LiveThing>();
        anim       = GetComponent <Animator>();
        player     = gameMaster.GetPlayer();

        healthbar.SetMaxHealth(live.health.initValue);
        healthbar.SetHealth(live.health.initValue);
    }