using UnityEngine;
using System.Collections;

public class ShieldController : MonoBehaviour 
{
    private ParticleSystem _Shield = null;

    private MegaShoot _MegaShoot = null;

	void Start () 
    {
        Transform shield = transform.FindChild("ScudoPotere");

        if (shield != null)
        {
            _Shield = (ParticleSystem) shield.GetComponent(typeof(ParticleSystem));
        }

        _MegaShoot = (MegaShoot) GetComponent(typeof(MegaShoot));
	}
	
	void Update () 
    {
        if (_MegaShoot != null)
        {
            if (_MegaShoot.bCanShoot)
            {
                if (_Shield != null)
                {
                    _Shield.enableEmission = true;
                }
            }
            else
            {
                if (_Shield != null)
                {
                    _Shield.enableEmission = false;
                }
            }
        }
        else
        {
            if (_Shield != null)
            {
                _Shield.enableEmission = false;
            }
        }
	}
}
