示例#1
0
 // Use this for initialization
 void Start()
 {
     // Finds the player and its script
     player = GameObject.FindGameObjectWithTag("Player");
     dc     = player.GetComponent <damageController>();
     // Initializes the health bar
     HealthBar            = GetComponent <Image>();
     HealthBar.fillAmount = dc.getHealth();
 }
示例#2
0
 // Called on colission
 void OnTriggerEnter2D(Collider2D collision)
 {
     // If it collided with the player give the player helth and destroys itself
     if (collision.CompareTag("Player"))
     {
         // Get the player script
         damageController dc = collision.gameObject.GetComponent <damageController>();
         // If the player isn't at max health
         if (dc.getHealth() != dc.getMaxHealth())
         {
             // Gives the player health and then self destructs
             dc.giveHealth(amount);
             GameObject H1 = Instantiate(heal1, transform.position, Quaternion.identity);
             GameObject H2 = Instantiate(heal2, transform.position, Quaternion.identity);
             Destroy(this.gameObject);
         }
     }
 }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        stamina    = pc.getStamina();
        maxStamina = pc.getMaxStamina();
        health     = dc.getHealth();
        maxHealth  = dc.getMaxHealth();

        ChromaticAberrationModel.Settings CAS = normal.chromaticAberration.settings;
        float temp = 1 - (stamina / maxStamina);

        CAS.intensity = temp * 2;
        normal.chromaticAberration.settings = CAS;

        float healthPC = health / maxHealth;

        if (healthPC <= 0.5f)
        {
            UserLutModel.Settings ULS = normal.userLut.settings;
            temp                    = (healthPC / 0.5f);
            ULS.contribution        = 1 - Mathf.Clamp(temp, 0, 1);
            normal.userLut.settings = ULS;
        }
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        if (coList.Count != 0)
        {
            parent.numAlliesNear = coList.Count;
            alliesNeedHeal       = false;
            foreach (GameObject x in coList)
            {
                damageController xdc = x.GetComponent <damageController>();
                if (xdc.getHealth() < xdc.getMaxHealth())
                {
                    alliesNeedHeal = true;
                }
            }

            if (alliesNeedHeal)
            {
                if (!parent.wait && !parent.isHealing)
                {
                    parent.wait = true;
                    StartCoroutine(parent.Heal());
                    //GetComponent<SpriteRenderer>().enabled = true;
                }
            }
            else
            {
                if (!parent.wait && parent.isHealing)
                {
                    parent.wait = true;
                    StartCoroutine(parent.Move());
                    //GetComponent<SpriteRenderer>().enabled = false;
                }
            }
        }
        else
        {
            parent.numAlliesNear = 0;
        }


        if (parent.isHealing)
        {
            secondCount += healFactor * Time.deltaTime;
            if (secondCount >= 1f)
            {
                secondCount -= 1f;
                foreach (GameObject x in coList)
                {
                    x.GetComponent <damageController>().giveHealth(1);
                }
            }
            if (!parent.wait)
            {
            }

            frameCount++;
            if (frameCount == 9)
            {
                var clone1 = Instantiate(gas1, transform.position, Quaternion.identity);
            }
            else if (frameCount >= 18)
            {
                frameCount = 0;
                var clone2 = Instantiate(gas2, transform.position, Quaternion.identity);
            }
        }
        else
        {
            moveLoc = new Vector3(0f, 0f, 0f);
            foreach (GameObject x in coList)
            {
                moveLoc += x.transform.position;
            }
            moveLoc /= coList.Count;

            if (coList.Count != 0)
            {
                parent.MoveTo(moveLoc);
            }
            else
            {
                parent.RunAway();
            }
        }
    }
示例#5
0
 // Update is called once per frame
 void Update()
 {
     // Sets the fill of the bar to be equal to the % of health
     HealthBar.fillAmount = (float)dc.getHealth() / dc.getMaxHealth();
 }