SetHealth() public method

public SetHealth ( int _cur, int _max ) : void
_cur int
_max int
return void
Beispiel #1
0
    private void Start()
    {
        stats = PlayerStats.instance;

        stats.curHealth = stats.maxHealth;

        if (statusIndicator == null)
        {
            Debug.LogError("No status indicator on player");
        }
        else
        {
            statusIndicator.SetHealth(stats.curHealth, stats.maxHealth);
        }

        // caching
        audioManager = AudioManager.instance;
        if (audioManager == null)
        {
            Debug.LogError("PANIC!!! No AudioManager found!!!");
        }

        GameMaster.gameMaster.onToggleUpgradeMenu += OnUpgradeMenuToggle;

        InvokeRepeating("RegenHealth", 1f / stats.healthRegenRate, 1f / stats.healthRegenRate);
    }
    void Start()
    {
        playerStats = PlayerStats.instance;

        playerStats.curHealth = playerStats.maxHealth;

        if (statusIndicator == null)
        {
            Debug.LogError("No status indicator referenced on Player");
        }
        else
        {
            statusIndicator.SetHealth(playerStats.curHealth, playerStats.maxHealth);
        }

        GameMaster.gm.onToggleUpgradeMenu += OnUpgradeMenuToggle;

        audioManager = AudioManager.instance;
        if (audioManager == null)
        {
            Debug.Log("Error");
        }

        InvokeRepeating("RegenHealth", 1f / playerStats.healthRegenRate, 1f / playerStats.healthRegenRate);
    }
Beispiel #3
0
    void Start()
    {
        stats           = PlayerStats.instance;
        stats.curHealth = stats.maxHealth;

        if (statusIndicator == null)
        {
            Debug.LogError("No status indicator reference on player.");
        }
        else
        {
            statusIndicator.SetHealth(stats.curHealth, stats.maxHealth);
        }

        audioManager = AudioManager.instance;
        if (audioManager == null)
        {
            Debug.Log("No AudioManager in scene.");
        }

        GameMaster.gm.onToggleStoreMenu += OnStoreMenuToggle;
        //makes player modifyable from the gm toggle store method.

        InvokeRepeating("RegenHealth", 1f / stats.healthRegenRate, stats.healthRegenRate);
    }
Beispiel #4
0
    void Start()
    {
        stats = PlayerStats.instance;

        stats.currentHealth = stats.maxHealth;

        if (statusIndicator == null)
        {
            Debug.LogError("No StatusIndicator referenced on player!");
        }
        else
        {
            statusIndicator.SetHealth(stats.currentHealth, stats.maxHealth);
        }

        GameMaster.gm.onToggleUpgradeMenu += OnUpgradeMenuToggle;

        audioManager = AudioManager.instance;
        if (audioManager == null)
        {
            Debug.LogError("PANIC! No audioManager in scene");
        }

        InvokeRepeating("RegenHealth", 1f / stats.healthRegenRate, 1f / stats.healthRegenRate);
    }
Beispiel #5
0
    void Start()
    {
        playerStats = PlayerStats.instance;

        // When player dies and respawns, new Player clone is created but no where it says the currHP to maxHP
        // Hence we need to add this line (or else shows as 0/100 when respawned).
        playerStats.currHealth = playerStats.maxHealth;
        if (statusIndicator == null)
        {
            Debug.LogError("No statusIndicator referenced on Player!");
        }
        else
        {
            statusIndicator.SetHealth(playerStats.currHealth, playerStats.maxHealth);
        }

        // caching
        audioManager = AudioManager.instance;
        if (audioManager == null)
        {
            Debug.LogError("No AudioManager instance found in Main Scene!");
        }
        //Subscribing to the delegate event from GM class
        GameMaster.gm.onToggleUpgradeMenu += OnUpgradeMenuToggle;

        InvokeRepeating("RegenHealth", 1f / playerStats.healthRegenRate, 1f / playerStats.healthRegenRate);
    }
Beispiel #6
0
    private StatusIndicator statusIndicator;     // health bar for player

    void Start()
    {
        // initialize PlayerStats
        stats = PlayerStats.instance;
        stats.InitHealth();

        // startup health bar GUI
        if (statusIndicator == null)         // check if indicator is there
        {
            Debug.LogError("PLAYER: no statusIndicator reference on player");
        }
        else
        {
            statusIndicator.SetHealth(stats.currentHealth, stats.maxHealth);              // update GUI
        }
        // binding the Player's callback OnUpgradeMenuToggle to the onToggleUpgradeMenu event cast by GM
        GameMaster.gm.onToggleUpgradeMenu += OnUpgradeMenuToggle;

        // initialize audio reference
        audioManager = AudioManager.instance;
        if (audioManager == null)
        {
            Debug.LogError("No audio manager found");
        }

        // start regeneration: every 1/regenRate seconds, call RegenHealth which add 1 life
        InvokeRepeating("RegenHealth", 1f / stats.regenRate, 1f / stats.regenRate);
    }
    private void Start()
    {
        stats = PlayerStats.Instance;
        stats.CurrentHealth = stats.m_MaxHealth;

        if (statusIndicator == null)
        {
            StatusIndicator ind = GameObject.Find("PlayerHP").GetComponentInChildren <StatusIndicator>();
            if (ind != null)
            {
                statusIndicator = ind;
            }
        }

        statusIndicator.SetHealth(stats.CurrentHealth, stats.m_MaxHealth);

        if (m_Anim == null)
        {
            m_Anim = GetComponent <Animator>();
        }

        m_AudioManager = AudioManager.instance;
        if (m_AudioManager == null)
        {
            Debug.LogError("No audioManager found in " + this.name);
        }
    }
Beispiel #8
0
    public void TakeDamage(int damage, float enemyRotation)
    {
        if (_curInvincibilityCountdown <= 0)
        {
            curHealth -= damage;
            _curInvincibilityCountdown = invincibilityTime;
            camShake.Shake(1f);

            if (_curHealth <= 0)
            {
                statusInd.SetHealth(curHealth, maxHealth);
                Die();
            }
            else
            {
                this.GetComponent <PlayerController2D>().canMove = false;
                if (enemyRotation == 0)
                {
                    m_Rigidbody2D.AddForce(new Vector2(-1f, 0), ForceMode2D.Impulse);
                }
                else
                {
                    m_Rigidbody2D.AddForce(new Vector2(1f, 0), ForceMode2D.Impulse);
                }

                statusInd.SetHealth(curHealth, maxHealth);

                animator.SetBool("hasBeenDamaged", true);
                StartCoroutine(DamageEndAnimation());
            }
        }
    }
Beispiel #9
0
    void Start()
    {
        stats           = PlayerStats.instance;
        stats.curHealth = stats.maxHealth;

        if (statusIndicator == null)
        {
            Debug.LogError("StatusIndicator: No status indicator object referenced");
        }
        else
        {
            statusIndicator.SetHealth(stats.curHealth, stats.maxHealth);
        }

        GameMaster.gm.onToggleUpgradeMenu += OnUpgradeMenuToggle;

        audioManager = AudioManager.instance;
        if (audioManager == null)
        {
            Debug.LogError("AudioManager: No AudioManager found in the scene.");
        }
        else
        {
            audioManager.PlaySound(spawnSound);
        }

        InvokeRepeating("RegenHealth", stats.healthRegenRate, stats.healthRegenRate);
    }
Beispiel #10
0
 void Start()
 {
     stats           = PlayerStats.instance;
     stats.curHealth = stats.maxHealth;
     if (statusIndicator == null)
     {
         Debug.LogError(this);
     }
     else
     {
         statusIndicator.SetHealth(stats.curHealth, stats.maxHealth);
     }
     GameMaster.gm.onTogglePauseGame += OnPauseGameToggle;
     soundManager = SoundManager.instance;
     if (soundManager == null)
     {
         Debug.LogError("No SoundManager found");
     }
     weaponstats = WeaponStats.instance;
     if (weaponstats == null)
     {
         Debug.LogError("No WeaponStats found");
     }
     pistol         = GameObject.Find("Arm").transform.GetChild(0).GetComponent <Weapon>();
     pistol.damage  = weaponstats.pistolDMG;
     rifle          = GameObject.Find("Arm").transform.GetChild(1).GetComponent <Weapon>();
     rifle.damage   = weaponstats.rifleDMG;
     rifle.fireRate = weaponstats.rifleFR;
     InvokeRepeating("RegenHealth", 1f, 0.5f);
 }
Beispiel #11
0
    private void Start()
    {
        stats = PlayerStats.instance;

        stats.CurrentHealth = stats.maxHealth;
        pastRegenHealth     = stats.healthRegenRate;
        if (GameObject.FindObjectsOfType <Player>().Length > 1)
        {
            Debug.Log("Only one player can be instatiated");
            Destroy(this.transform.gameObject);
            return;
        }

        if (statusIndicator == null)
        {
            Debug.Log("No status indicator on Player");
        }
        else
        {
            statusIndicator.SetHealth(stats.CurrentHealth, stats.maxHealth);
        }

        GameMaster.gm.onToggleUpgrademenu += OnUpgradeMenuToggle;

        audioManager = AudioManager.instance;
        if (audioManager == null)
        {
            Debug.LogError("No audioManager found in Player");
        }

        InvokeRepeating("RegenHealth", 1f / stats.healthRegenRate, 1f / stats.healthRegenRate);
    }
Beispiel #12
0
    private void Start()
    {
        stats = PlayerStats.Instance;

        stats.CurHealth = stats.maxHealth;

        GameMaster.instance.onToggleUpgradeMenu += OnToggleUpgradeMenu;

        if (statusIndicator == null)
        {
            Debug.LogError("No status indicator referenced on Player");
        }
        else
        {
            statusIndicator.SetHealth(stats.CurHealth, stats.maxHealth);
        }

        audioManager = AudioManager.Instance;
        if (audioManager == null)
        {
            Debug.LogError("FREAK OUT! No AudioManager found in the scene");
        }

        InvokeRepeating("HealthRegen", 1f / stats.healthRegenRate, 1f / stats.healthRegenRate);
    }
Beispiel #13
0
    void Start()
    {
        stats = PlayerStats.instance;
        if (statusIndicator == null)
        {
            Debug.LogError("No status indicator referenced on Player");
        }
        else
        {
            statusIndicator.SetHealth(stats.curHealth, stats.maxHealth);
        }

        audioManager = AudioManager.instance;
        if (audioManager == null)
        {
            Debug.LogError("No Audio Manager found!");
        }

        // Subscribe pause method
        GameMaster.gm.onGamePause         += OnGamePauseToggle;
        GameMaster.gm.onToggleUpgradeMenu += OnGamePauseToggle;
        stats.curHealth = stats.maxHealth;

        InvokeRepeating("RegenHealth", 1f / stats.regenRate, 1f / stats.regenRate);
    }
Beispiel #14
0
    void Start()
    {
        playerStats = PlayerStats.instance;

        playerStats.curHealth = playerStats.maxHealth;


        audioManager = AudioManager.instance;
        if (audioManager == null)
        {
            Debug.Log("ENEMY: No audioManager found.");
        }


        if (statusIndicator == null)
        {
            Debug.LogError("No status indicator on player");
            statusIndicator = GameObject.FindGameObjectWithTag("StatusIndicator").GetComponent <StatusIndicator>();

            statusIndicator.SetHealth(playerStats.curHealth, playerStats.maxHealth);
        }
        else
        {
            statusIndicator.SetHealth(playerStats.curHealth, playerStats.maxHealth);
        }

        InvokeRepeating("RegenHealth", 1f / playerStats.healthRegenRate, 1f / playerStats.healthRegenRate);
    }
Beispiel #15
0
    void Start()
    {
        stats = PlayerStats.instance;

        stats.curHealth = stats.maxHealth;

        if (statusIndicator == null)
        {
            Debug.LogError("no reference status indicator");
        }
        else
        {
            statusIndicator.SetHealth(stats.curHealth, stats.maxHealth);
        }

        GameMaster.gm.onToggleUpgradeMenu += OnUpgradeToggleMenu;

        audioManager = AudioManager.instance;
        if (audioManager == null)
        {
            Debug.LogError("no audiomanager found");
        }

        InvokeRepeating("RegenHealth", 1f / stats.healthRegenRate, 1f / stats.healthRegenRate);
    }
Beispiel #16
0
    // Use this for initialization
    void Start()
    {
        curHealth = maxHealth;

        statusIndicator.SetHealth(curHealth, maxHealth);

        InvokeRepeating("RegenHealth", 1f / healthRegenRate, 1f / healthRegenRate);
    }
Beispiel #17
0
 void Start()
 {
     Stats.Init();
     if (statusIndicator != null)
     {
         statusIndicator.SetHealth(Stats.curHealth, Stats.maxHealth);
     }
 }
Beispiel #18
0
    void Start()
    {
        stats.init();

        if (statusIndicator != null)
        {
            statusIndicator.SetHealth(stats.currHealth, stats.maxHealth);
        }
    }
Beispiel #19
0
    void Start()
    {
        playerStats.Init();

        if (statusIndicator != null)
        {
            statusIndicator.SetHealth(playerStats.currentHealth, playerStats.maxHealth);
        }
    }
    private void Start()
    {
        stats.Init();

        if (statusIndicator != null)
        {
            statusIndicator.SetHealth(stats.CurHealth, stats.maxHealth);
        }
    }
Beispiel #21
0
 void Start()
 {
     stats.Init();
     if (statusIndicator != null)
     {
         statusIndicator.SetHealth(stats.curHealth, stats.maxHealth);
     }
     GameMaster.gm.OnShowUpgradeMenu += OnUpgradeShowMenu;
 }
 void Start()
 {
     stats.Init();
     if (statusIndicator != null)
     {
         statusIndicator.SetHealth(stats.curHealth, stats.maxHealth);
     }
     GameMaster.gm.onToggleUpgradeMenu += OnUpgradeMenuToggle;
 }
Beispiel #23
0
    private void Start()
    {
        Init();

        if (statusIndicator != null)
        {
            statusIndicator.SetHealth(CurrentHealth, MaxHealth);
        }
    }
 private StatusIndicator statusIndicator; // a object of the class statusIndicator
 void Start()
 {
     stats.Init();
     if (statusIndicator != null)
     {
         statusIndicator.SetHealth(stats.currentHealth, stats.maxHealth);
     }
     ;                                                                     // The Ui of the enemy's properties
 }
Beispiel #25
0
    void Start()
    {
        enemyStat.Init();

        if (statusIndicator != null)
        {
            statusIndicator.SetHealth(enemyStat.currentHealth, enemyStat.MaxHP);
        }
    }
Beispiel #26
0
    private void Start()
    {
        enemyStats.Init();

        if (statusIndicator != null)
        {
            statusIndicator.SetHealth(enemyStats.currentHealth, enemyStats.MaxHealth);
        }
    }
Beispiel #27
0
    void Start()
    {
        stats.Init();

        if (statusIndicator != null)
        {
            statusIndicator.SetHealth(stats.curHealth, stats.maxhealth);
            statusIndicator.SetDank(stats.curDank, stats.maxDank);
        }
    }
Beispiel #28
0
    void Start()
    {
        enemyStats.Init();

        if (statusIndicator != null)
        {
            //  Debug.LogError("WE HAVE AN IDICATOR");
            statusIndicator.SetHealth(enemyStats.curHealth, enemyStats.maxHealth);
        }
    }
Beispiel #29
0
    void Start()
    {
        isDying = false;
        enemyStats.Init();

        if (statusIndicator != null)
        {
            statusIndicator.SetHealth(enemyStats.curHealth, enemyStats.maxHealth);
        }
    }
Beispiel #30
0
    void Start()
    {
        hitCd    = 1.5f;
        hitTimer = hitCd;
        stats.Init();

        if (statusIndicator != null)
        {
            statusIndicator.SetHealth(stats.currentHealth, stats.maxHealth);
        }
    }