void Start()
    {
        _data            = GetComponent <UnitData>();
        _rb2D            = GetComponent <Rigidbody2D>();
        _state           = GetComponent <UnitStateBehaviour>();
        _animator        = GetComponent <Animator>();
        _attackBehaviour = GetComponent <UnitAttackBehaviour>();
        _box2D           = GetComponent <BoxCollider2D>();
        _direction       = transform.right;
        _rayDistance     = Mathf.Abs(_box2D.offset.x) + (_box2D.size.x) + 20f;

        if (isRange)
        {
            _rayDistance *= 5f;
        }

        switch (_data.side)
        {
        case Side.RIGHT:
            GetComponent <SpriteRenderer>().flipX = true;
            _direction    = -transform.right;
            _box2D.offset = new Vector2(-_box2D.offset.x, _box2D.offset.y);
            break;

        case Side.LEFT:
            _direction = transform.right;
            break;
        }
    }
Beispiel #2
0
 void Start()
 {
     _state        = GetComponent <UnitStateBehaviour>();
     _animator     = GetComponent <Animator>();
     _healthSystem = GetComponent <UnitHealthBehaviour>();
 }