Beispiel #1
0
        private void Start()
        {
            _cannonCollider = gameObject.transform.Find("HarpoonCannon").gameObject.GetComponent <BoxCollider2D>();
            _projectileObj  = gameObject.transform.Find("HarpoonCannon/HarpoonProjectile").gameObject;
            var ropeObj = gameObject.transform.Find("HarpoonCannon/HarpoonRope").gameObject;

            _crankController = gameObject.transform.Find("../../Wheel").gameObject.GetComponent <CrankController>();

            _inventory = gameObject.transform.Find("../../Inventory").gameObject.GetComponent <Inventory>();

            _rotatableHandler    = GetComponent <RotatableHandler>();
            _shotHandler         = GetComponent <HarpoonShotHandler>();
            _projectileCollision = _projectileObj.GetComponent <ProjectileCollision>();
            _movingProjectile    = _projectileObj.GetComponent <MovingProjectile>();
            _rope                   = ropeObj.GetComponent <HarpoonRope>();
            _windInProjectile       = _projectileObj.GetComponent <WindInProjectile>();
            _cannonCollider.enabled = false;
            _crankController.EnableController(false);

            _crankController.CrankRotationEvent += _windInProjectile.AddTravelDistance;
            _rotatableHandler.RotationEvent     += OnRotationEvent;
            _shotHandler.ShotEvent += OnShotEvent;
            _projectileCollision.CollisionEvent += ProjectileOnCollisionEvent;
            HookableObjectController.AddHarpoonController(this);
        }
Beispiel #2
0
        /**
         * Enables controller and its connected components
         *
         * @param status boolean, true => enable, false => disable controller
         */
        private void EnableController(bool status)
        {
            if (_rotatableHandler == null || _shotHandler == null || _crankController == null)
            {
                _rotatableHandler = GetComponent <RotatableHandler>();
                _shotHandler      = GetComponent <HarpoonShotHandler>();
                _crankController  = gameObject.transform.Find("../../Wheel").gameObject.GetComponent <CrankController>();
            }

            if (status == false)
            {
                _crankController.EnableController(false);
            }

            if (!_isWoundIn)
            {
                _rotatableHandler.enabled = status;
                _shotHandler.enabled      = status;
            }
            else
            {
                if (_projectileShot)
                {
                    _crankController.EnableController(status);
                }
            }
        }
 /**
  * enables MonoBehaviour for Controller
  *
  * @param status bool to enable (true) or disable (false) Controller
  */
 public void EnableController(bool status)
 {
     enabled = status;
     if (_rotatableHandler == null)
     {
         _rotatableHandler = GetComponent <RotatableHandler>();
     }
     _rotatableHandler.enabled = status;
 }
 private void Start()
 {
     _rotatableHandler = GetComponent <RotatableHandler>();
     _rotatableHandler.RotationEvent += OnRotationEvent;
 }