Inheritance: MonoBehaviour
 protected virtual void Initialization()
 {
     _character  = GetComponent <CharacterMotor2D>();
     _controller = GetComponent <CController>();
     _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement>();
     _characterGravity            = GetComponent <CharacterGravity>();
     _spriteRenderer = GetComponent <SpriteRenderer>();
     _health         = GetComponent <Health>();
     //BindAnimator();
     //_sceneCamera = _character.SceneCamera;
     _inputManager = _character.LinkedInputManager;
     _state        = _character.CharacterState;
     if (GetComponent <InputManager>() == null)
     {
         _character.LoadStates(_movement); _character.LoadCondition(_condition);
     }
     else
     {
         _movement = _character.MovementState; _condition = _character.ConditionState;
     }
     AbilityPermitted = true;
     if (_character.MovementState == null)
     {
         print("");
     }
     _abilityInitialized = true;
 }
    // Start is called before the first frame update
    void Start()
    {
        _controller    = GetComponent <CharacterController>();
        _gravityScript = GetComponent <CharacterGravity>();
        _cameraScript  = GetComponent <PlayerCamera>();
        _povScript     = GetComponent <ChangePOV>();

        _playerRef         = transform.Find("Player");
        _thirdPersonCamera = _cameraScript.ThirdPersonCamera;

        StopMovement();
    }
Exemple #3
0
    protected virtual void OnTriggerEnter2D(Collider2D collider)
    {
        CharacterGravity characterGravity = collider.gameObject.GetComponentNoAlloc <CharacterGravity>();

        if (characterGravity == null)
        {
            return;
        }
        else
        {
            characterGravity.ReverseHorizontalInputWhenUpsideDown = false;
        }
    }
    public override void Awake()
    {
        base.Awake();
        _motor   = GetComponent <CharacterMotor2D>();
        _gravity = GetComponent <CharacterGravity>();

        OnCollisionGroundEvent = _motor.OnCollision
                                 .Where(x => x.IsGroundCollision(60f));

        OnLandOnGroundEvent = OnCollisionGroundEvent
                              .Where(x => !Ground.IsOn);

        OnCollisionWallLeftEvent = _motor.OnCollision
                                   .Where(x => x.IsWallLeftCollision(30f));

        OnCollisionWallRightEvent = _motor.OnCollision
                                    .Where(x => x.IsWallRightCollision(30f));
    }
    protected virtual void Initialization()
    {
        _transform              = transform;
        _boxCollider            = (BoxCollider2D)GetComponent <BoxCollider2D>();
        _originalColliderSize   = _boxCollider.size;
        _originalColliderOffset = _boxCollider.offset;

        if ((_boxCollider.offset.x != 0) && (Parameters.DisplayWarnings))
        {
            Debug.LogWarning("The boxcollider for " + gameObject.name + " should have an x offset set to zero. Right now this may cause issues when you change direction close to a wall.");
        }

        _contactList = new List <RaycastHit2D>();
        State        = new CControllerState();

        _platformMaskSave = PlatformMask;
        PlatformMask     |= OneWayPlatformMask;
        PlatformMask     |= MovingPlatformMask;
        PlatformMask     |= MovingOneWayPlatformMask;
        PlatformMask     |= MidHeightOneWayPlatformMask;

        _sideHitsStorage  = new RaycastHit2D[NumberOfHorizontalRays];
        _belowHitsStorage = new RaycastHit2D[NumberOfVerticalRays];
        _aboveHitsStorage = new RaycastHit2D[NumberOfVerticalRays];

        CurrentWallCollider = null;
        State.Reset();
        SetRaysParameters();

        if (AutomaticGravitySettings)
        {
            CharacterGravity characterGravity = this.gameObject.GetComponentNoAlloc <CharacterGravity>();
            if (characterGravity == null)
            {
                this.transform.rotation = Quaternion.identity;
            }
        }
    }
Exemple #6
0
 // Use this for initialization
 void Start()
 {
     rb = GetComponent<Rigidbody> ();
     characterGrav = GetComponent<CharacterGravity> ();
     gravityCanon = FindObjectOfType<TransferGravity> ();
 }
 // Use this for initialization
 void Start()
 {
     anim = GetComponent<Animator>();
     rb = GetComponent<Rigidbody> ();
     characterGrav = GetComponent<CharacterGravity> ();
     gravityCanon = FindObjectOfType<TransferGravity> ();
     moveLeft = false;
     moveRight = false;
     crouching = false;
 }
Exemple #8
0
 // Start is called before the first frame update
 void Start()
 {
     FactorVector = Vector3.one;
     _GChecker    = GetComponent <GroundChecker>();
     _cGrav       = GetComponent <CharacterGravity>();
 }
 // Start is called before the first frame update
 void Start()
 {
     gravityModule = GetComponent <CharacterGravity>();
     ccModule      = GetComponent <UnityEngine.CharacterController>();
 }
Exemple #10
0
 // Use this for initialization
 void Start()
 {
     rb = GetComponent<Rigidbody> ();
     characterGrav = GetComponent<CharacterGravity> ();
     gravityCanon = FindObjectOfType<TransferGravity> ();
 }