示例#1
0
        /// <summary>
        /// Grabs the weapon component, initializes the angle values
        /// </summary>
        protected virtual void Initialization()
        {
            _weapon = GetComponent <Weapon> ();
            if (_weapon.Owner != null)
            {
                _characterGravity = _weapon.Owner.GetComponent <CharacterGravity> ();
            }

            if (RotationMode == RotationModes.Strict4Directions)
            {
                _possibleAngleValues     = new float[5];
                _possibleAngleValues [0] = -180f;
                _possibleAngleValues [1] = -90f;
                _possibleAngleValues [2] = 0f;
                _possibleAngleValues [3] = 90f;
                _possibleAngleValues [4] = 180f;
            }
            if (RotationMode == RotationModes.Strict8Directions)
            {
                _possibleAngleValues     = new float[9];
                _possibleAngleValues [0] = -180f;
                _possibleAngleValues [1] = -135f;
                _possibleAngleValues [2] = -90f;
                _possibleAngleValues [3] = -45f;
                _possibleAngleValues [4] = 0f;
                _possibleAngleValues [5] = 45f;
                _possibleAngleValues [6] = 90f;
                _possibleAngleValues [7] = 135f;
                _possibleAngleValues [8] = 180f;
            }
            _initialRotation = transform.rotation;
            InitializeReticle();
        }
示例#2
0
        /// <summary>
        /// Sets the weapon's owner
        /// </summary>
        /// <param name="newOwner">New owner.</param>
        public virtual void SetOwner(Character newOwner, CharacterHandleWeapon handleWeapon)
        {
            Owner = newOwner;
            if (Owner != null)
            {
                CharacterHandleWeapon        = handleWeapon;
                _characterGravity            = Owner.GetComponent <CharacterGravity>();
                _characterHorizontalMovement = Owner.GetComponent <CharacterHorizontalMovement>();
                _controller = Owner.GetComponent <CorgiController>();

                if (CharacterHandleWeapon.AutomaticallyBindAnimator)
                {
                    if (CharacterHandleWeapon.CharacterAnimator != null)
                    {
                        _ownerAnimator = CharacterHandleWeapon.CharacterAnimator;
                    }
                    if (_ownerAnimator == null)
                    {
                        _ownerAnimator = CharacterHandleWeapon.gameObject.MMGetComponentNoAlloc <Character>().CharacterAnimator;
                    }
                    if (_ownerAnimator == null)
                    {
                        _ownerAnimator = CharacterHandleWeapon.gameObject.MMGetComponentNoAlloc <Animator>();
                    }
                }
            }
        }
示例#3
0
        protected virtual void OnTriggerEnter2D(Collider2D collider)
        {
            CharacterGravity characterGravity = collider.gameObject.GetComponentNoAlloc <CharacterGravity> ();

            if (characterGravity == null)
            {
                return;
            }
            else
            {
                characterGravity.ReverseHorizontalInputWhenUpsideDown = false;
            }
        }
 /// <summary>
 /// Gets and stores components for further use
 /// </summary>
 protected virtual void Initialization()
 {
     _character              = GetComponent <Character>();
     _controller             = GetComponent <CorgiController>();
     _characterBasicMovement = GetComponent <CharacterHorizontalMovement>();
     _characterGravity       = GetComponent <CharacterGravity> ();
     _spriteRenderer         = GetComponent <SpriteRenderer>();
     _health = GetComponent <Health> ();
     BindAnimator();
     _sceneCamera        = _character.SceneCamera;
     _inputManager       = _character.LinkedInputManager;
     _state              = _character.CharacterState;
     _movement           = _character.MovementState;
     _condition          = _character.ConditionState;
     _abilityInitialized = true;
 }
        /// <summary>
        /// Grabs the weapon component, initializes the angle values
        /// </summary>
        protected virtual void Initialization()
        {
            _weapon = this.gameObject.GetComponent <Weapon> ();
            if (_weapon.Owner != null)
            {
                _characterGravity = _weapon.Owner?.FindAbility <CharacterGravity> ();
            }

            if (RotationMode == RotationModes.Strict4Directions)
            {
                _possibleAngleValues     = new float[5];
                _possibleAngleValues [0] = -180f;
                _possibleAngleValues [1] = -90f;
                _possibleAngleValues [2] = 0f;
                _possibleAngleValues [3] = 90f;
                _possibleAngleValues [4] = 180f;
            }
            if (RotationMode == RotationModes.Strict8Directions)
            {
                _possibleAngleValues     = new float[9];
                _possibleAngleValues [0] = -180f;
                _possibleAngleValues [1] = -135f;
                _possibleAngleValues [2] = -90f;
                _possibleAngleValues [3] = -45f;
                _possibleAngleValues [4] = 0f;
                _possibleAngleValues [5] = 45f;
                _possibleAngleValues [6] = 90f;
                _possibleAngleValues [7] = 135f;
                _possibleAngleValues [8] = 180f;
            }
            _initialRotation = transform.rotation;
            InitializeReticle();
            _mainCamera = Camera.main;

            if ((_weapon.Owner.LinkedInputManager == null) && (AimControl == AimControls.PrimaryMovement))
            {
                Debug.LogError("You've set the WeaponAim on " + this.name + " to be driven by PrimaryMovement, yet it's either driven by an AI or doesn't have an associated InputManager. Maybe you meant to have a Script AimControl instead.");
            }
            if ((_weapon.Owner.LinkedInputManager == null) && (AimControl == AimControls.SecondaryMovement))
            {
                Debug.LogError("You've set the WeaponAim on " + this.name + " to be driven by SecondaryMovement, yet it's either driven by an AI or doesn't have an associated InputManager. Maybe you meant to have a Script AimControl instead.");
            }
        }
示例#6
0
        /// <summary>
        /// Sets the weapon's owner
        /// </summary>
        /// <param name="newOwner">New owner.</param>
        public virtual void SetOwner(Character newOwner)
        {
            Owner = newOwner;
            if (Owner != null)
            {
                CharacterHandleWeapon        = Owner.GetComponent <CharacterHandleWeapon>();
                _characterGravity            = Owner.GetComponent <CharacterGravity>();
                _characterHorizontalMovement = Owner.GetComponent <CharacterHorizontalMovement>();
                _controller = Owner.GetComponent <CorgiController>();

                if (CharacterHandleWeapon.AutomaticallyBindAnimator)
                {
                    if (CharacterHandleWeapon.CharacterAnimator != null)
                    {
                        _ownerAnimator = CharacterHandleWeapon.CharacterAnimator;
                    }
                }
            }
        }