示例#1
0
 protected override void Start()
 {
     base.Start();
     anim     = GetComponent <Animator>();
     movement = GetComponent <CharacterHorizontalMovement>();
     box      = GetComponent <BoxCollider2D>();
 }
示例#2
0
        ///
        protected override void Initialization()
        {
            if (LevelManager.Instance.Players.Count == 0)
            {
                Debug.LogError("No player found!");
                return;
            }

            if (_controller == null)
            {
                _controller   = this.gameObject.GetComponent <CorgiController>();
                thisCharacter = this.gameObject.GetComponent <Character>();
            }
            else
            {
                _controller   = this.gameObject.GetComponentInParent <CorgiController>();
                thisCharacter = this.gameObject.GetComponentInParent <Character>();
            }

            _characterHorizontalMovement = thisCharacter?.FindAbility <CharacterHorizontalMovement>();
            _characterRun  = thisCharacter?.FindAbility <CharacterRun>();
            _characterJump = thisCharacter?.FindAbility <CharacterJump>();
            _jetpack       = thisCharacter?.FindAbility <CharacterJetpack>();

            thisCharacter.MovementState.ChangeState(CharacterStates.MovementStates.Idle);
        }
示例#3
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>();
                    }
                }
            }
        }
 protected override void Start()
 {
     base.Start();
     health   = GetComponent <BaddieHealth>();
     anim     = GetComponent <Animator>();
     movement = GetComponent <CharacterHorizontalMovement>();
 }
 /// <summary>
 /// On init we grab our AI components
 /// </summary>
 public override void Initialization()
 {
     base.Initialization();
     downRay     = new RaycastHit2D();
     _controller = GetComponent <CorgiController>();
     _character  = LevelManager.Instance.PlayerPrefabs[0];
     _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement>();
 }
 /// <summary>
 /// On init we grab our AI components
 /// </summary>
 protected override void Initialization()
 {
     _controller = GetComponent <CorgiController>();
     _character  = GetComponent <Character>();
     _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement>();
     _characterJump = GetComponent <CharacterJump>();
     _direction     = _character.IsFacingRight ? Vector2.right : Vector2.left;
 }
 protected override void Start()
 {
     base.Start();
     _character            = GetComponent <Character>();
     _characterHMovement   = GetComponent <CharacterHorizontalMovement>();
     originalMovementSpeed = _characterHMovement.WalkSpeed;
     _animatorCharacter    = GetComponent <Animator>();
     _spriteRender         = GetComponent <SpriteRenderer>();
 }
 /// <summary>
 /// On Start() we reset our number of jumps
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     ResetNumberOfJumps();
     _characterWallJump           = GetComponent <CharacterWalljump>();
     _characterCrouch             = GetComponent <CharacterCrouch>();
     _characterButtonActivation   = GetComponent <CharacterButtonActivation>();
     _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement> ();
     _characterLadder             = GetComponent <CharacterLadder>();
 }
        /// <summary>
        /// Triggered when something exits the water
        /// </summary>
        /// <param name="collider">Something colliding with the water.</param>
        protected virtual void OnTriggerExit2D(Collider2D collider)
        {
            // we check that the object colliding with the water is actually a characterJump
            CharacterHorizontalMovement characterHorizontalMovement = collider.GetComponent <Character>()?.FindAbility <CharacterHorizontalMovement>();

            if (characterHorizontalMovement == null)
            {
                return;
            }
            characterHorizontalMovement.MovementSpeed = _previousMovementSpeed;
        }
        /// <summary>
        /// Triggered when something collides with the override zone
        /// </summary>
        /// <param name="collider">Something colliding with the override zone.</param>
        protected virtual void OnTriggerEnter2D(Collider2D collider)
        {
            // we check that the object colliding with the override zone is actually a characterJump
            CharacterHorizontalMovement characterHorizontalMovement = collider.GetComponent <CharacterHorizontalMovement>();

            if (characterHorizontalMovement == null)
            {
                return;
            }
            _previousMovementSpeed = characterHorizontalMovement.MovementSpeed;
            characterHorizontalMovement.MovementSpeed = MovementSpeed;
        }
        ///
        protected override void Initialization()
        {
            AgentFollowsPlayer = false;
            _target            = LevelManager.Instance.Players[0].transform;

            _controller             = GetComponent <CorgiController>();
            _targetCharacter        = GetComponent <Character>();
            _characterBasicMovement = GetComponent <CharacterHorizontalMovement>();
            _targetCharacter.MovementState.ChangeState(CharacterStates.MovementStates.Idle);
            _characterRun      = GetComponent <CharacterRun>();
            _characterJump     = GetComponent <CharacterJump>();
            _jetpack           = GetComponent <CharacterJetpack>();
            followSpeedStorage = followSpeed;
        }
示例#12
0
文件: AIWalk.cs 项目: andres-03/01
        protected virtual void Initialization()
        {
            // we get the CorgiController2D component
            _controller = GetComponent <CorgiController>();
            _character  = GetComponent <Character>();
            _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement>();
            _health = GetComponent <Health> ();
            // initialize the start position
            _startPosition = transform.position;
            // initialize the direction
            _direction = _character.IsFacingRight ? Vector2.right : Vector2.left;

            _initialDirection = _direction;
            _initialScale     = transform.localScale;
        }
 /// <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;
 }
示例#14
0
 /// <summary>
 /// Gets and stores components for further use
 /// </summary>
 protected virtual void Initialization()
 {
     _character              = GetComponent <Character>();
     _controller             = GetComponent <CorgiController>();
     _characterBasicMovement = GetComponent <CharacterHorizontalMovement>();
     _spriteRenderer         = GetComponent <SpriteRenderer>();
     _animator     = _character._animator;
     _sceneCamera  = _character.SceneCamera;
     _inputManager = _character.LinkedInputManager;
     _state        = _character.CharacterState;
     _movement     = _character.MovementState;
     _condition    = _character.ConditionState;
     if (_animator != null)
     {
         InitializeAnimatorParameters();
     }
 }
示例#15
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;
                    }
                }
            }
        }
示例#16
0
        /// <summary>
        /// Initialization
        /// </summary>
        protected virtual void Start()
        {
            if (LevelManager.Instance.Players.Count == 0)
            {
                return;
            }
            // we get the player
            _target = LevelManager.Instance.Players[0].transform;
            // we get its components
            _controller                  = GetComponent <CorgiController>();
            _targetCharacter             = GetComponent <Character>();
            _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement>();
            _characterRun                = GetComponent <CharacterRun>();
            _characterJump               = GetComponent <CharacterJump>();
            _jetpack = GetComponent <CharacterJetpack>();

            // we make the agent start following the player
            AgentFollowsPlayer = true;

            _targetCharacter.MovementState.ChangeState(CharacterStates.MovementStates.Idle);
        }
示例#17
0
 /// <summary>
 /// Grabs various components and inits stuff
 /// </summary>
 public virtual void Setup()
 {
     // filler if the WeaponAttachment has not been set
     if (WeaponAttachment == null)
     {
         WeaponAttachment = transform;
     }
     if (_animator != null)
     {
         _weaponIK = _animator.GetComponent <WeaponIK> ();
     }
     // we set the initial weapon
     if (InitialMeleeWeapon != null && (superPlasmaBladeObtained == false))
     {
         ChangeWeapon(InitialMeleeWeapon, null);
     }
     if (superPlasmaBladeObtained == true)
     {
         ChangeWeapon(UpgradedPlasmaBlade, null);
     }
     _character = gameObject.GetComponentNoAlloc <Character> ();
     _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement>();
 }
 /// <summary>
 /// On start, we store our characterJump component
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement>();
     _characterWallClinging       = GetComponent <CharacterWallClinging>();
 }
示例#19
0
 protected override void Initialization()
 {
     _horizontalMovement = this.gameObject.GetComponent <CharacterHorizontalMovement>();
     originalSpeed       = _horizontalMovement.WalkSpeed;
 }
 /// <summary>
 /// On init we grab our CharacterHorizontalMovement ability
 /// </summary>
 protected override void Initialization()
 {
     _characterHorizontalMovement = this.gameObject.GetComponent <CharacterHorizontalMovement>();
 }