Esempio n. 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);
        }
Esempio n. 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);
                }
            }
        }