Пример #1
0
    public void TakeDamage(int damage)
    {
        currentHealth -= damage;
        healthBar.SetHealth(currentHealth);

        if (currentHealth <= 0)
        {
            SceneManager.LoadScene(1);
        }
    }
Пример #2
0
        private void OnCollisionStay2D(Collision2D collision)
        {
            if (collision.collider.CompareTag("Enemy"))
            {
                hitPoints -= EnemyDamage;
                healthBar.SetHealth(hitPoints);
            }
#pragma warning disable 4014
            CheckIfStillAlive();
#pragma warning restore 4014
        }
Пример #3
0
    // Start is called before the first frame update
    void Start()
    {
        playerHealthBar.SetMaxHealth(PlayerData.maxHealth);
        playerHealthBar.SetHealth(PlayerData.currentHealth);
        cooldownAttack.SetActive(false);
        cooldownSkill.SetActive(false);
        icon2X.SetActive(false);
        diePanal.SetActive(false);
        timeCooldownAttack = 0;
        timeCooldownSkill  = 0;


        socket = GetComponent <SocketIOComponent>();

        socket.On("SpawnMonster", SpawnMonster);
        socket.On("UpdateMonsterData", UpdateMonsterData);
        socket.On("MonsterAttack", MonsterAttack);
        socket.On("Heal", Heal);
        socket.On("BuffAttack", BuffAttack);
        socket.On("Buffend", Buffend);
        socket.On("MonsterDie", MonsterDie);
    }
Пример #4
0
    private void Update()
    {
        Attacking();
        Countdowns();

        healthBar.SetHealth(currentHealth);

        //Checks if player has died
        if (currentHealth == 0)
        {
            Respawn();
        }
    }
Пример #5
0
    private void Awake()
    {
        PlayerData data = SaveSystem.LoadSave();

        if (data != null && SceneManager.GetActiveScene().name != "TutorialScene") // If save file exists AND its not a tutorial level
        {
            maxHealth          = data.maxHealth;
            currentHealth      = data.currentHealth;
            playerDamage       = data.playerDamage;
            playerRangedDamage = data.playerRangedDamage;
            playerRangedSpeed  = data.playerRangedSpeed;
            defence            = data.defence;
            numberOfJumps      = data.numberOfJumps;
            movementSpeed      = data.movementSpeed;
            money = data.money;
            Debug.Log("File succsessfully loaded");
        }
        else // if save file is not found, assing defaul values
        {
            SetDefaultStats();
        }

        text.text = money.ToString();
        playerHealthBar.SetMaxHealth(maxHealth);

        if (SceneManager.GetActiveScene().name == "HubScene")
        {
            currentHealth = maxHealth;
        }

        playerHealthBar.SetHealth(currentHealth);

        pauseUI      = GameObject.Find("Canvas").transform.Find("DeathScreen").gameObject;
        audioManager = GameObject.Find("AudioManager").gameObject;
        audio        = audioManager.GetComponent <AudioManager>();
    }
Пример #6
0
    public void TakeDamage(int damageTaken)
    {
        if (block)
        {
            damageTaken = 0;
        }
        currentHealth -= damageTaken;
        healthBar.SetHealth(currentHealth);
        if (damageTaken > 0)
        {
            tint.SetTintColor();
        }
        Debug.Log("You took " + damageTaken + " damage.");
        //play hurt animation

        if (currentHealth <= 0)
        {
            animate.SetBool("Dead", true);
            GetComponent <Collider2D>().enabled     = false;
            GetComponent <PlayerMovement>().enabled = false;
            this.enabled = false;
        }
    }
Пример #7
0
 public void TakeDamage(int health)
 {
     currentHealth -= health;
     healthBar.SetHealth(currentHealth);
 }