示例#1
0
    // Use this for initialization
    protected virtual void Awake()
    {
        _key_shoot_sound = -1;
        _soundManager = SoundManager.Instance;
        _camera = transform.FindChild("Camera");
        _base = transform.FindChild("Base");
        _tourelle = _base.FindChild("Tourelle");
        _head = _tourelle.FindChild("Head");

        if (_head != null)
            _cannon = _head.FindChild("Cannon");
        else
            _cannon = _tourelle.FindChild("Cannon");

        if (_cannon != null)
            _shoot = _cannon.FindChild("Shoot");

        Transform p = _tourelle.FindChild("Particle");

        if (p == null && _head != null)
            p = _head.FindChild("Particle");
        if (p == null && _cannon != null)
            p = _cannon.FindChild("Particle");

        if(p != null)
        {
            _particle = p.GetComponent<ParticleSystem>();

            Transform tmp = p.FindChild("Smoke");
            if(tmp != null)
                _smoke = tmp.GetComponent<ParticleSystem>();

            tmp = p.FindChild("Sparks");
            if(tmp != null)
                 _sparkles = p.FindChild("Sparks").GetComponent<ParticleSystem>();
        }

        watcher = _base.GetComponent<EnemyWatcher>();

        if(watcher != null)
        {
            watcher.Init(this, Range);
        }

        Transform c = transform.FindChild("Canvas");
        if(c != null)
            _canvas = c.gameObject;

        _direction = new Vector3();
        _angleRotation = 0f;
        _fire = false;
        _allowFire = true;
        Auto = true;
        Level = 1;
        _targets = new ArrayList();
        FireRate = Mathf.Abs(FireRate);
        if (FireRate == 0f)
            FireRate = 1f;

        if (Bullet != null && BulletsSize > 0)
        {
            _bullets = ScriptableObject.CreateInstance<PullManager>();
            _bullets.Init(Bullet, BulletsSize);
        }
        else
            _bullets = null;

        if (Node != null && NodesSize > 0)
        {
            _nodes = ScriptableObject.CreateInstance<PullManager>();
            _nodes.Init(Node, NodesSize);
        }
        else
            _nodes = null;

        EmitParticle(false);
        Move();
    }