Esempio n. 1
0
    void Start()
    {
        fullHealthInt = health;
        health        = 1;
        //isBuilding = false;
        spriteMaterial = GetComponent <SpriteRenderer>();
        healthScript   = GetComponent <healthBarControlled>();
        healthScript.SetHealth(health / fullHealthInt);

        //InvokeRepeating("callsBuilder", 1f, 1f);
    }
Esempio n. 2
0
 //------------------------------------- interface
 public bool HealingBuilding()
 {
     //Debug.Log("HealingBuilding");
     _health += Time.deltaTime;
     if (_health > 1 && health < fullHealthInt)
     {
         health++;
         healthScript.SetHealth(health / fullHealthInt);
         _health = 0;
         if (health >= fullHealthInt)
         {
             health = (int)fullHealthInt;
             return(false);
         }
         return(true);
     }
     if (health >= fullHealthInt)
     {
         health = (int)fullHealthInt;
         return(false);
     }
     return(true);
 }
    public void GetDamage(int hit)
    {
        //Debug.Log("Enemy Get Damage\n"+ ((float)_healthEnemy / (float)_fullHealthEnemy));
        _healthEnemy -= hit;

        if (_healthEnemy <= 0)
        {
            Destroy(gameObject);
        }
        else
        {
            _setHealthBarHealth.SetHealth(((float)_healthEnemy / _fullHealthEnemy));
        }
        //OnSetHealth.Invoke();
    }
Esempio n. 4
0
    public void TakeDamage(int hit, bool _bool)
    {
        rigidbody2DHuman.velocity = Vector3.zero;
        transform.position        = new Vector3(transform.position.x, transform.position.y + 0.2f, transform.position.z);
        Vector3 attackFence = new Vector3(3 * (_bool ? (1) : (-1)), 2f, 0);

        rigidbody2DHuman.AddForce(attackFence, ForceMode2D.Impulse);
        //transform.GetComponent<BoxCollider2D>().enabled = false;

        sprite.material = whiteMaterial;
        StartCoroutine(returnMaterial());
        health -= hit;

        //BarFilled.sizeDelta = new Vector2(fullSizeHealthBar * health / fullHealthInt, BarFilled.sizeDelta.y);
        healthScript.SetHealth(health / fullHealthInt);
        if (health <= 0)
        {
            Death();
        }
    }
Esempio n. 5
0
    //------------------------------------- interface
    public void TakeDamage(int hit, bool _bool)
    {
        rigidbody2Denemy.velocity = Vector3.zero;
        transform.position        = new Vector3(transform.position.x, transform.position.y + 0.2f, transform.position.z);
        Vector3 attackFence = new Vector3(3 * (_bool ? (1) : (-1)), 2f, 0);

        rigidbody2Denemy.AddForce(attackFence, ForceMode2D.Impulse);
        isAttackFence = false;

        StartCoroutine(resetBoolRun(1f));

        sprite.material = whiteMaterial;
        StartCoroutine(returnMaterial());
        health -= hit;

        healthScript.SetHealth(health / fullHealthInt);
        if (health <= 0)
        {
            Death();
        }
    }