Esempio n. 1
0
    private void GunShot()
    {
        // Shot sound
        SoundManager soundManager = SoundManager.SharedInstance;

        soundManager.PlayOneShot(soundManager.playerShotSFX, audioSource);

        // Animation
        animator.SetTrigger(shotCommand);

        // Projectile
        GameObject bullet = BulletPool.SharedInstance.GetPooledObject();

        bullet.transform.position = spawnBulletPoint.transform.position;
        bullet.transform.rotation = mainCameraTransform.rotation;

        bullet.tag   = GameManager.playerTag;
        bullet.layer = LayerMask.NameToLayer(GameManager.enemyTag);

        // Projectile color
        Renderer bulletRenderer = bullet.GetComponent <Renderer>();

        int currentColor = colorChanger.GetCurrentColor();

        Bullet bulletScript = bullet.GetComponent <Bullet>();

        bulletScript.SetBulletColor(currentColor);
        bulletScript.SetDamage(data.damage);
    }
Esempio n. 2
0
    public override void TakeDamage(float damage, int bulletColorIndex)
    {
        if (bulletColorIndex == colorChanger.GetCurrentColor())
        {
            currentHealth -= damage;
        }

        if (currentHealth <= 0)
        {
            Death();
        }

        Debug.Log(currentHealth);

        healthBar.sizeDelta = new Vector2(defaultSize.x / data.maxHealth * currentHealth
                                          , defaultSize.y);
    }