// Update is called once per frame
    public float Playertakedamage(float health)
    {
        health -= Se.EnemyDamage;
        healthBar.UpdateBar(health, maxhealth);

        return(health);
    }
예제 #2
0
    private void Update()
    {
        if (reloading == true)
        {
            if ((int)Time.time - reloadstarttimer == reloadtime)
            {
                reloading     = false;
                ammoleft      = ammocount;
                ammotext.text = ammoleft.ToString();
                ammoBar.UpdateBar(ammoleft, ammocount);
            }
        }
        if (Input.GetKey("space") && reloading == false)
        {
            if (playershooting.enabled == false)
            {
                ammoleft      = ammoleft - 1f;
                ammotext.text = ammoleft.ToString();
                ammoBar.UpdateBar(ammoleft, ammocount);
            }
            playershooting.enabled = true;

            if (ammoleft == 0f)
            {
                reloadstarttimer = (int)Time.time;
                reloading        = true;
            }
        }
        else
        {
            playershooting.enabled = false;
        }
    }
예제 #3
0
    // Update is called once per frame


    public void Start()
    {
        startingHealth = 100;
        currentHealth  = startingHealth;
        healthBar.UpdateBar(startingHealth, currentHealth);
        // A1=GetComponent<AudioSource>();
    }
예제 #4
0
        public void Init()
        {
            if (GetComponent <PlayerInput>().isActiveAndEnabled == false)
            {
                GetComponent <PlayerInput>().enabled = true;
            }

            if (GetComponent <PlayerController>().isActiveAndEnabled == false)
            {
                GetComponent <PlayerController>().enabled = true;
            }

            if (transform.GetComponentInChildren <PlayerAttack>().isActiveAndEnabled == false)
            {
                transform.GetComponentInChildren <PlayerAttack>().enabled = true;
            }

            _healthPoint = _maxHp;
            _manaPoint   = 100;

            _isPlayerDeath = false;
            _isDamageable  = true;

            _healthBar.UpdateBar(_healthPoint, _maxHp);
        }
예제 #5
0
    private void Attack()
    {
        var currTriggerList = attackCollider.TriggerList;

        foreach (var other in attackCollider.TriggerList)
        {
            if (other.gameObject.tag == "enemy")
            {
                Destroy(other.gameObject);
                FindObjectOfType <AudioManager>().Play("Kill");

                count2++;
            }
            else if (other.gameObject.tag == "shotgunGuy")
            {
                FindObjectOfType <AudioManager>().Play("Kill");
                Instantiate(healthPack, (Vector2)other.transform.position, Quaternion.identity);
                Destroy(other.gameObject);
            }
            else if (other.gameObject.tag == "bullet")
            {
                health += bulletHealthDecrease;
                healthBar.UpdateBar(health, 100f);
                Bullet bullet = other.gameObject.GetComponent <Bullet>();
                bullet.direction   = lookDir.normalized;
                bullet.isDeflected = true;
                FindObjectOfType <AudioManager>().Play("Deflect");
            }
        }
    }
예제 #6
0
    private void OnTriggerStay2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Pilot"))
        {
            if (Input.GetMouseButtonDown(1) && !Sc.GrabberOn)
            {
                if (Cp.food != Cp.initialFood && shipRes.food > 5)
                {
                    var diff = Cp.initialFood - Cp.food;
                    if (diff < 5)
                    {
                        incHealthEffect.Play();
                        Cp.food      += diff;
                        shipRes.food -= diff;
                        var current = shipRes.food;
                        var max     = shipRes.initialFood;
                        foodBar.UpdateBar(current, max);
                    }
                    else
                    {
                        incHealthEffect.Play();
                        shipRes.food -= 5;
                        var current = shipRes.food;
                        var max     = shipRes.initialFood;
                        foodBar.UpdateBar(current, max);
                        Cp.food += 5;
                    }
                }

                //Remove from shipRes

                //Debug.Log("minus ship res");
            }
        }
    }
예제 #7
0
    public void AddPlayerHealthPoint(int hurtDamage, int caseHeal)
    {
        if (caseHeal == 0)
        {
            cameraController.StopAllCoroutines();
            cameraController.StartCoroutine(cameraController.ShakeCamera(0.1f, 0.05f));
            playerStatistics.AddCharactorHealthPoint(hurtDamage);

            if (playerStatistics.HP > 0)
            {
                CurPlayerStatus(PlayerState.Player_Hurt);
            }
            else if (playerStatistics.HP <= 0)
            {
                playerStatistics.HP = 0;
                playerDeath         = true;
                CurPlayerStatus(PlayerState.Player_Death);
                StartCoroutine(PlayerDeath());
            }
        }
        else if (caseHeal == 1)
        {
            playerStatistics.DrinkPotion(hurtDamage);
        }
        healthBar.UpdateBar(playerStatistics.HP, playerStatistics.hpMax);
        healthBar.transform.GetChild(0).GetComponent <Text>().text = playerStatistics.HP.ToString() + "/" + playerStatistics.hpMax.ToString();
    }
예제 #8
0
 // Start is called before the first frame update
 void Start()
 {
     currentHealth = 10f;
     //Remove later
     healthbar.UpdateBar(currentHealth, maxHealth);
     anim = this.GetComponent <Animator>();
 }
예제 #9
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (IsDead())
        {
            healthBar.UpdateBar(CurrentHealth, MaximumHealth);
            return;
        }
        isGrounded = IsGrounded();

        if (!control)
        {
            return;
        }

        if (CheckStun())
        {
            return;
        }

        HandleMovement();

        FlipPlayer();

        //Handle Attacks

        ResetValues();

        healthBar.UpdateBar(CurrentHealth, MaximumHealth);
    }
예제 #10
0
    void Start()
    {
        rb2d = GetComponent <Rigidbody2D>();

        currentLife = startLife;
        healthBar.UpdateBar(currentLife, maxHealth);
    }
예제 #11
0
 private void Start()
 {
     expBar.UpdateBar(_currExp, expToNextLevel);
     levelText.text = "Level: " + _level.ToString();
     health         = GetComponentInParent <Health>();
     playerAttack   = GetComponentInChildren <PlayerAttack>();
 }
예제 #12
0
 public void UpdateHealth()
 {
     healthBar.UpdateBar(health, maxHealth);
     if (health <= 0)
     {
         SceneManager.LoadScene("Dead");
     }
 }
예제 #13
0
파일: PlayerShip.cs 프로젝트: pecavi/TFG
 // Use this for initialization
 void Start()
 {
     maxShield     = maxHealth / 2;
     currentHealth = maxHealth;
     currentShield = maxShield;
     healthBar.UpdateBar(currentHealth, maxHealth);
     healthBar.UpdateBar(currentShield, maxShield);
 }
예제 #14
0
 // Use this for initialization
 void Start()
 {
     Cursor.lockState = CursorLockMode.None;
     Cursor.visible   = false;
     controller       = GameObject.FindObjectOfType <FirstPersonController>();
     dmgTaken         = false;
     healthBar2.UpdateBar(currentHealth, maxHealth);
 }
예제 #15
0
 // Use this for initialization
 void Start()
 {
     //MaxHp = getMaxHp();
     //Hp = getHp();
     gameObject.layer = LayerMask.NameToLayer("Ignore Raycast");
     fireSpawn        = transform.GetChild(0).GetChild(0).transform;
     healthBar.UpdateBar(Hp, MaxHp);
 }
예제 #16
0
    // Start is called before the first frame update
    void Start()
    {
        currentHealth = maxHealth;
        currentMana   = maxMana;

        healthBar.UpdateBar(currentHealth, maxHealth);
        manaBar.UpdateBar(currentMana, maxMana);
    }
예제 #17
0
        void Update()
        {
            // Run the CheckExitScreen function to see if the player has left the screen.
            CheckExitScreen();

            // If the user cannot control the player, then return.
            if (canControl == false)
            {
                return;
            }

            // Store the input positions
            rotation     = Input.GetAxis("Horizontal");
            acceleration = Input.GetAxis("Vertical");

            if (canShoot == true)
            {
                // If the shooting button is being used...
                if (Input.GetMouseButton(0))
                {
                    // If the gun is not overheated, then increase the timer.
                    if (overheatTimer < overheatTimerMax)
                    {
                        overheatTimer += Time.deltaTime;
                    }
                    // Else the gun has overheated, so start the overheat coroutine.
                    else
                    {
                        canShoot = false;
                        StartCoroutine("DelayOverheat");
                    }

                    if (shootingTimer <= 0)
                    {
                        // Then reset the timer and shoot a bullet.
                        shootingTimer = shootingCooldown;
                        CreateBullets();
                    }
                }
                else
                {
                    if (overheatTimer > 0)
                    {
                        overheatTimer -= Time.deltaTime * cooldownSpeed;
                    }
                }

                gunHeatBar.UpdateBar(overheatTimer, overheatTimerMax);
            }

            // If the shoot timer is above zero, reduce it.
            if (shootingTimer > 0)
            {
                shootingTimer -= Time.deltaTime;
            }

            Aiming();
        }
예제 #18
0
    public void Init(int max)
    {
        maxHealth     = max;
        currHealth    = max;
        displayHealth = max;

        healthBar.UpdateBar(currHealth, maxHealth);
        textMeshPro.text = currHealth + "/" + maxHealth;
    }
예제 #19
0
 public void HealthUpdate(float value)
 {
     if (health == maxHealth || health >= value)
     {
         health = value;
     }
     maxHealth = value;
     healthBar.UpdateBar(health, maxHealth);
 }
예제 #20
0
 virtual public void Start()
 {
     animator = GetComponentInChildren<Animator>();
     currhealth = maxHealth;
     if (hasHealthBar)
     {
         healthBar.UpdateBar(currhealth, maxHealth);
     }
 }
예제 #21
0
        void Start()
        {
            // Set the current health and shield to max values.
            currentHealth = maxHealth;
            currentShield = maxShield;

            // Update the Simple Health Bar with the updated values of Health and Shield.
            healthBar.UpdateBar(currentHealth, maxHealth);
            shieldBar.UpdateBar(currentShield, maxShield);
        }
예제 #22
0
    void Start()
    {
        //Initialize Player
        currentHealth = maxHealth;
        currentOxygen = maxOxygen;

        // Update Health Bar with the updated values of Health and Oxygen
        healthBar.UpdateBar(currentHealth, maxHealth);
        oxygenBar.UpdateBar(currentOxygen, maxOxygen);
    }
예제 #23
0
        void Start()
        {
            // PARA ESTABLECER LA VIDA MAXIMA Y EL ESCUDO
            currentHealth = maxHealth;
            Escudito      = maxEscudito;

            // SE van actualizando la vida y los escudos
            healthBar.UpdateBar(currentHealth, maxHealth);
            shieldBar.UpdateBar(Escudito, maxEscudito);
        }
 void UpdatePower()
 {
     m_CurrPower += m_AdjustSpeed * Time.deltaTime;
     m_CurrPower  = Mathf.Clamp(m_CurrPower, 0.0f, MAX_POWER);
     if (m_CurrPower == 0 || m_CurrPower == MAX_POWER)
     {
         m_AdjustSpeed = -m_AdjustSpeed;
     }
     m_SimpleBar.UpdateBar(m_CurrPower, MAX_POWER);
 }
예제 #25
0
    // Use this for initialization
    void Start()
    {
        playerRigidbody = GetComponent <Rigidbody2D>();

        currHealth = maxHealth;

        healthBar.UpdateBar(currHealth, maxHealth);

        specialAvailable = false;
    }
예제 #26
0
 public void attack()
 {
     if (currentEnergy > attackCost)
     {
         currentEnergy -= attackCost;
         energyBar.UpdateBar(currentEnergy, maxEnergy);
         rayo.SetActive(true);
         Invoke("apagaRayo", 0.5f);
     }
 }
예제 #27
0
파일: PlayerHealth.cs 프로젝트: bizyb/cs526
    void Start()
    {
        // Set the current health max
        currentHealth = maxHealth;

        // Update the Simple Health Bar with the updated value of Health
        healthBar.UpdateBar(currentHealth, maxHealth);
        //sheildBar.UpdateBar(currentHealth, maxHealth);
        game = GameManager.Instance;
    }
예제 #28
0
 void Start()
 {
     blockrend = holdingBlock.GetComponent <Renderer>();
     GlobalVariables.currentHP = 100;
     GlobalVariables.kills     = 0;
     GlobalVariables.coins     = 0;
     PlayerController          = GetComponent <CharacterController>();
     Cursor.visible            = false;
     healthBar.UpdateBar(currHp, maxHp);
     startRotSword = armsSword.transform.localRotation;
 }
    // Use this for initialization
    void Start()
    {
        playerRigidbody = GetComponent <Rigidbody2D>();

        currHealth = maxHealth;

        healthBar.UpdateBar(currHealth, maxHealth);

        specialAvailable = false;

        retryButton.SetActive(false);
    }
예제 #30
0
 public void GetAttacked(float decrease)
 {
     towerCurrentHealth -= decrease;
     if (towerCurrentHealth <= 0)
     {
         Die();
     }
     else
     {
         healthBar.UpdateBar(towerCurrentHealth, towerTotalHealth);
     }
 }