Ejemplo n.º 1
0
 /// <summary>
 /// Updates the virus shader to match the current health of the player
 /// </summary>
 private void SetHealth()
 {
     if (virus)
     {
         IHealthObject player = Player.GetComponent <IHealthObject>();
         virus.virusMat.SetFloat("_Cutoff", Mathf.Lerp(virus.virusMat.GetFloat("_Cutoff"), 1 - (player.Health / player.MaxHealth), 0.2f));
     }
 }
Ejemplo n.º 2
0
 public override void OnLevelLoad(bool state)
 {
     healthObj = GetComponent <IHealthObject>();
     if (state)
     {
         healthObj.FullHeal();
     }
     else
     {
         healthObj.Damage(healthObj.MaxHealth);
     }
 }
Ejemplo n.º 3
0
    protected override void Awake()
    {
        base.Awake();
        healthObj = GetComponent <IHealthObject>();

        //make sure the indicator has a heartbeat indicator
        if ((HbIndicator = indicator.GetComponent <HeartbeatIndicator>()) == null)
        {
            HbIndicator = indicator.AddComponent <HeartbeatIndicator>();
        }
        zone   = GetComponent <BoxCollider2D>();
        anim   = GetComponent <Animator>();
        render = GetComponent <SpriteRenderer>();
    }
Ejemplo n.º 4
0
    private void Start()
    {
        //get the player's health and maxHealth
        playerHealth = Player.GetComponent <IHealthObject>();

        GameObject tick;

        //fill the healthbar with ticks
        for (int i = 0; i < numTicks; i++)
        {
            tick      = Instantiate(tickPrefab, transform);
            tick.name = "healthBarTick" + i;
            tick.GetComponent <SpriteRenderer>().sprite = (i < 5 || (i > 5 && i < 8) || i > 62) ? tick1 : tick2; //custom design
            tick.transform.position = transform.position + new Vector3(2.0625f + (i * 0.125f), 0);               //needs modifying to be more generalized <<<
        }
        //healthbar should always start filled
        SetActive();
    }