示例#1
0
    // changes the energy from the player
    // also notifies the UI (if present)
    public void ModifyHealth(int amount)
    {
        Debug.Log("AddAmount" + amount);
        //avoid going over the maximum health by forcin
        if (health + amount > maxHealth)
        {
            amount = maxHealth - health;
            Debug.Log("ture: " + maxHealth + "health: " + health);
        }

        health += amount;
        Debug.Log("Health" + amount);
        // Notify the UI so it will change the number in the corner
        if (ui != null &&
            playerNumber != -1)
        {
            ui.ChangeHealth(amount, playerNumber);
        }

        //DEAD
        if (health <= 0)
        {
            deathEffect.transform.position = this.transform.position;
            deathEffect = Instantiate(deathEffect);
            deathEffect.Play();

            if (hiddenItemBool)
            {
                hiddenItem.transform.position = this.transform.position;
                hiddenItem.SetActive(true);
            }

            Destroy(gameObject);
        }
    }
示例#2
0
    // changes the energy from the player
    // also notifies the UI (if present)
    public void ModifyHealth(int amount)
    {
        //avoid going over the maximum health by forcin
        if (health + amount > maxHealth)
        {
            amount = maxHealth - health;
        }

        health += amount;

        // Notify the UI so it will change the number in the corner
        if (userInterface != null &&
            playerNumber != -1)
        {
            userInterface.ChangeHealth(amount, playerNumber);
        }

        //
        if (amount < 0)
        {
            if (GetComponent <SpriteRenderer>() != null)
            {
                GetComponent <SpriteRenderer>().color = hitColor;
                Invoke("BackToColor", 0.1f);
            }
        }

        //DEAD
        if (health <= 0)
        {
            // AGREGAR ALGO ANTES DE MORIR
            userInterface.AddPoints(0, score);
            Destroy(gameObject);
        }
    }
示例#3
0
    // changes the energy from the player
    // also notifies the UI (if present)
    public void ModifyHealth(int amount)
    {
        //avoid going over the maximum health by forcin
        if (health + amount > maxHealth)
        {
            amount = maxHealth - health;
        }

        health += amount;

        // Notify the UI so it will change the number in the corner
        if (ui != null &&
            playerNumber != -1)
        {
            ui.ChangeHealth(amount, playerNumber);
        }

        //DEAD
        if (health <= 0)
        {
            Debug.Log("NO NYT ON RITARI VOITETTU!!! : ");
            //SceneManager.UnloadScene("MiekkaTaistelu");
            SceneManager.LoadScene("Skene1");
            Destroy(gameObject);
        }
    }
示例#4
0
    // changes the energy from the player
    // also notifies the UI (if present)
    public void ModifyHealth(int amount)
    {
        //avoid going over the maximum health by forcin
        if (health + amount > maxHealth)
        {
            amount = maxHealth - health;
        }

        // Notify the UI so it will change the number in the corner
        if (ui != null &&
            playerNumber != -1)
        {
            ui.ChangeHealth(amount, playerNumber);
        }

        animator.SetTrigger("damage");
        health += amount;
        //DEAD
        if (health <= 0)
        {
            animator.SetBool("dead", true);
            GetComponent <Move>().enabled = false;
            animator.ResetTrigger("damage");
            this.enabled = false;
        }
    }
    // changes the energy from the player
    // also notifies the UI (if present)
    public void ModifyHealth(int amount)
    {
        //avoid going over the maximum health by forcin
        if (health + amount > maxHealth)
        {
            amount = maxHealth - health;
        }

        health += amount;

        // Notify the UI so it will change the number in the corner
        if (ui != null &&
            playerNumber != -1)
        {
            ui.ChangeHealth(amount, playerNumber);
        }

        //DEAD
        if (health <= 0 && playerNumber == 0) //pelaaja häviää
        {
            Debug.Log("NO NYT ON RITARI VOITETTU!!! : " + playerNumber);
            //SceneManager.UnloadScene("MiekkaTaistelu");
            //foreach (var root in SceneRoots)
            //{
            //    Debug.Log(root);
            //    root.SetActive(true);
            //}
            //SceneManager.UnloadSceneAsync("MiekkaTaistelu");
            //SceneManager.LoadScene("Lopetus");
            Destroy(gameObject);
        }

        if (health <= 0 && playerNumber == 1) //vastustaja häviää
        {
            Debug.Log("Onnittelut, vastustaja voitettu!!! : " + playerNumber);
            //SceneManager.UnloadScene("MiekkaTaistelu");
            //foreach (var root in SceneRoots)
            //{
            //    Debug.Log(root);
            //    if (root != null)
            //    {
            //        root.SetActive(true);
            //        if (root.tag == "Player2") { Destroy(root); }
            //    }
            //}
            //SceneManager.UnloadSceneAsync("MiekkaTaistelu");
            //SceneManager.LoadScene("Skene1");
            Destroy(gameObject);
        }
    }
    // changes the energy from the player
    // also notifies the UI (if present)
    public void ModifyHealth(int amount)
    {
        //avoid going over the maximum health by forcin
        if (health + amount > maxHealth)
        {
            amount = maxHealth - health;
        }

        health += amount;

        // Notify the UI so it will change the number in the corner
        if (ui != null &&
            playerNumber != -1)
        {
            ui.ChangeHealth(amount, playerNumber);
        }
    }
    // changes the energy from the player
    // also notifies the UI (if present)
    public void ModifyHealth(int amount)
    {
        //avoid going over the maximum health by forcin
        if (health + amount > maxHealth)
        {
            amount = maxHealth - health;
        }

        health += amount;

        // Notify the UI so it will change the number in the corner
        if (ui != null && playerNumber != -1)
        {
            ui.ChangeHealth(amount, playerNumber);
        }

        //DEAD
        if (health <= 0)
        {
            //FloatingTextController.CreateFloatingText(amount.ToString(), transform);
            Destroy(gameObject);
        }
    }
示例#8
0
    // changes the energy from the player
    // also notifies the UI (if present)
    public bool ModifyHealth(int amount)
    {
        //Invincible time
        if (isInvincible())
        {
            return(false);
        }

        //avoid going over the maximum health by forcin
        if (health + amount > maxHealth)
        {
            amount = maxHealth - health;
        }

        health += amount;

        // Notify the UI so it will change the number in the corner
        if (ui != null &&
            playerNumber != -1)
        {
            ui.ChangeHealth(amount, playerNumber);
        }

        //DEAD
        if (health <= 0)
        {
            Destroy(gameObject);
        }

        //ChangeSpriteColor
        if (amount < 0)
        {
            DamageSpriteShining();
            return(true);
        }
        return(false);
    }