Exemple #1
0
    public bool ChangeHealth(float amount, DamageType type, string reason)
    {
        // Change damage amount if obstacle was hit
        if (type == DamageType.Obstacle && cooldown <= 0.0f)
        {
            amount   = obstacleDamage;
            cooldown = DamageCooldown;
        }
        else if (type != DamageType.Enemy)
        {
            Debug.Log("Still on damage cooldown!");
            return(false);
        }

        if (shieldUp && type == DamageType.Enemy)
        {
            FindObjectOfType <ItemController>().TryUseItem(Item.ItemType.Shield);
            StrangeParticles shield = FindObjectOfType <StrangeParticles>();
            if (shield != null)
            {
                AudioManager.Instance.Play("ShieldHit");
                shield.Burst();
            }
            Debug.Log("No damage b/c shield up!");
            return(false);
        }

        // Invurnable
        if (isInvurnable)
        {
            return(isDead = false);
        }

        Debug.Log("Reducing by " + amount + " because of " + reason);

        // Adjust damage / visuals
        health -= amount;
        if (healthBar != null)
        {
            healthBar.fillAmount = health / startHealth;
        }

        // Play sound effect
        AudioManager.Instance.PlayRandom(new string[] { "DeathRoblox", "HurtMinecraft" });

        // Blood effect
        FindObjectOfType <ItemController>().GetComponentInChildren <BloodExplosion>().DeathExplode();

        if (health <= 0)
        {
            return(isDead = true);
        }
        else
        {
            return(isDead = false);
        }
    }
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            StrangeParticles myScript = (StrangeParticles)target;

            if (GUILayout.Button("Burst Particles"))
            {
                myScript.Burst();
            }
        }