Example #1
0
    /// <summary>
    /// Initialize enemy
    /// </summary>
    /// <param name="_data"></param>
    /// <param name="owner"></param>
    public void Init(EnemyData _data, GameObject _owner = null)
    {
        data     = _data;
        _isStart = true;
        HPoints  = data.Hp;
        Owner    = _owner;
        GetComponent <SpriteRenderer>().sprite = data.MainSprite;

        gameObject.transform.localScale     = data.Size;
        GetComponent <BoxCollider2D>().size = data.ColliderSize;
        ;
        if (!IsBullet)
        {
            if (IsUfo)
            {
                var child = gameObject.transform.GetChild(0);
                if (child != null)
                {
                    point = child.gameObject.GetComponent <BulletSpawnPoint>();
                }

                Player = GameObject.Find("Player");
            }

            StartCoroutine(Move());
        }
    }
 // Start is called before the first frame update
 private void Start()
 {
     stats            = GetComponent <PlayerStats>();
     audioPlayer      = GetComponent <AudioPlayer>();
     bulletSpawnPoint = GetComponentInChildren <BulletSpawnPoint>();
     spriteRenderer   = GetComponentInChildren <SpriteRenderer>();
 }
Example #3
0
    /// <summary>
    /// Initialize GameObject component
    /// </summary>
    private void Start()
    {
        transform.position = startPosition;
        rb           = GetComponent <Rigidbody2D>();
        _animator    = GetComponent <Animator>();
        _audioSource = GetComponent <AudioSource>();
        LoadData();
        point = gameObject.transform.GetChild(0).gameObject.GetComponent <BulletSpawnPoint>();
        var bonusAudioSourceGO = GameObject.Find("BonusAudioSource");

        if (_bonusAudioSource != null)
        {
            this._bonusAudioSource = bonusAudioSourceGO.GetComponent <AudioSource>();
        }
    }