Exemplo n.º 1
0
 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;
 }
    private void Awake()
    {
        m_Motor       = GetComponent <CharacterMotor2D>();
        m_InputDriver = GetComponent <BaseInputDriver>();

        if (m_InputDriver == null)
        {
            Debug.LogWarning("An InputDriver is needed for a BasicCharacterController2D");
        }
    }
Exemplo n.º 3
0
    public ContactInfo(CharacterMotor2D motor, float contactRatio, EdgeCollider2D edge, int edgePoint, bool side, bool isEdgeContact, float angle)
    {
        this.motor = motor;

        this.contactRatio = contactRatio;
        this.edge         = edge;
        this.edgePoint    = edgePoint;
        this.side         = side;

        this.isEdgeContact = isEdgeContact;
        this.angle         = angle;
    }
Exemplo n.º 4
0
    protected virtual void Initialization()
    {
        _controller = GetComponent <CController>();
        _character  = GetComponent <CharacterMotor2D>();//
        _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement>();
        _health        = GetComponent <Health>();
        _startPosition = transform.position;
        _direction     = _character.IsFacingRight ? Vector2.right : Vector2.left;

        _initialDirection = _direction;
        _initialScale     = transform.localScale;
        WalkBehaviour     = WalkBehaviours.MoveOnSight;
    }
Exemplo n.º 5
0
    // Initialization
    void Start()
    {
        // Get character motor object for handling movement
        characterMotor = GetComponent <CharacterMotor2D> ();

        // calculate gravity and jump velocity from jumpHeight and timeToJumpApex
        // this is because those types of variables are easier for fiddling with and such for game feel
        gravity      = calculateGravity();
        jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;

        // Debug information
        print("Gravity: " + gravity + " Jump Velocity: " + jumpVelocity);
    }
    void Start()
    {
        motor = GetComponent <CharacterMotor2D> ();
        motor.setPrimaryCallback(new TightPrimaryCallback());

        direction  = Direction.free;
        speed      = Vector2.zero;
        leftSpeed  = 0;
        rightSpeed = 0;

        leaped     = false;;
        leapFrame  = 0;
        leapNormal = Vector2.zero;
    }
Exemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        SpriteRenderer   sprite    = GetComponent <SpriteRenderer> ();
        CharacterMotor2D character = GetComponent <CharacterMotor2D> ();
        float            dir       = character.velocity.x;

        if (dir < 0)
        {
            sprite.flipX = true;
        }
        else if (dir > 0)
        {
            sprite.flipX = false;
        }
    }
Exemplo n.º 8
0
    /// <summary>
    /// On Update, we make sure we have a controller and a live character, and if we do, we apply a force to it
    /// </summary>
    protected virtual void Update()
    {
        if (_controller == null)
        {
            return;
        }

        if (_character.ConditionState.CurrentState == CharacterStates.CharacterConditions.Dead)
        {
            _character  = null;
            _controller = null;
            return;
        }

        _controller.AddHorizontalForce(AddedForce.x);
        _controller.AddVerticalForce(Mathf.Sqrt(2f * AddedForce.y * -_controller.Parameters.Gravity));
    }
    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));
    }
 void Start()
 {
     motor = GetComponent <CharacterMotor2D>();
 }
Exemplo n.º 11
0
 /// <summary>
 /// On trigger exit, we lose all reference to the controller and character
 /// </summary>
 /// <param name="collision"></param>
 protected virtual void OnTriggerExit2D(Collider2D collision)
 {
     _controller = null;
     _character  = null;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Triggered when a CorgiController collides with the surface
 /// </summary>
 /// <param name="collider">Collider.</param>
 public virtual void OnTriggerStay2D(Collider2D collider)
 {
     _controller = collider.gameObject.GetComponentNoAlloc <CController>();
     _character  = collider.gameObject.GetComponentNoAlloc <CharacterMotor2D>();
 }
 private void Awake()
 {
     motor = GetComponent <CharacterMotor2D>();
 }