예제 #1
0
    void ThrownMovement()
    {
        floorAttachingMovement.MoveSideWays(throwMomentum);

        if (throwMomentum == 0 && floorAttachingMovement.isGrounded)
        {
            state = ThrowableState.Recovering;
            StartRecovery();

            return;
        }

        if (throwMomentum < 0.5f && throwMomentum > -0.5f)
        {
            throwMomentum = 0;
        }

        if (floorAttachingMovement.isGrounded)
        {
            bounceDown();
        }

        if (floorAttachingMovement.topAngle.detect)
        {
            bounceUp();
        }

        if (floorAttachingMovement.isBumping)
        {
            bounceSide();
        }

        directionFloatX = Mathf.Sign(throwMomentum);
        ChangeDirection();
    }
예제 #2
0
 void StartRecovery()
 {
     disableAttackBoxes();
     state           = ThrowableState.Recovering;
     RecoveryRoutine = Recovering();
     StartCoroutine(RecoveryRoutine);
 }
예제 #3
0
 public void Drop()
 {
     m_currentObjectState = ThrowableState.Inactive;
     m_rb.isKinematic     = false;
     m_objectToFollow     = null;
     m_pickable           = true;
     m_rb.velocity        = Vector2.zero;
 }
예제 #4
0
    //************************//
    //    Public Functions    //
    //************************//

    public void PickUp(Transform _target, float _speed, float _targetReachedTolerance)
    {
        m_rb.velocity        = Vector2.zero;
        m_objectToFollow     = _target;
        m_currentObjectState = ThrowableState.TravellingToPlayer;
        m_speed = _speed;
        m_targetReachedTolerance = _targetReachedTolerance;
        m_rb.isKinematic         = true;
    }
예제 #5
0
 public override void OnPlayerTouch(PlayerScript player)
 {
     if (state == ThrowableState.Free || state == ThrowableState.Recovering)
     {
         player.HoldObject(this);
         state              = ThrowableState.Carried;
         carrier            = player;
         verticalCalulation = 0;
     }
 }
예제 #6
0
 private void SetInactive()
 {
     m_okb.IsLethal(false);
     m_rb.velocity        = Vector2.zero;
     m_rb.gravityScale    = 1f;
     m_currentObjectState = ThrowableState.Inactive;
     //GetComponent<SpriteRenderer>().color = Color.blue;
     m_pickable = true;
     ResetRotation();
     SubstractDurability();
 }
예제 #7
0
 public void getThrown(float DirectionX)
 {
     transform.parent = null;
     carrier          = null;
     if (RecoveryRoutine != null)
     {
         StopCoroutine(RecoveryRoutine);
     }
     state = ThrowableState.Thrown;
     enableAttackBoxes();
     throwMomentum = DirectionX * throwForce;
 }
예제 #8
0
 public void Throw(Vector2 _velocity, bool _isLethal, float _customSpeedMultiplier = -1, bool _pickableInAir = false) // nur ein parameter
 {
     if (_customSpeedMultiplier < 0)
     {
         _customSpeedMultiplier = m_speedMultiplier;
     }
     m_rb.velocity        = _velocity * _customSpeedMultiplier;
     m_rb.gravityScale    = 1 * Mathf.Pow(_customSpeedMultiplier, 2);
     m_currentObjectState = ThrowableState.Thrown;
     m_rb.isKinematic     = false;
     m_hitGround          = false;
     m_pickable           = _pickableInAir;
     m_okb.IsLethal(_isLethal);
     AdjustSprite(_velocity);
 }
예제 #9
0
    // Update is called once per frame
    void FixedUpdate()
    {
        switch (currentObjectState)
        {
        case ThrowableState.TravellingToPlayer:
        {
            CorrectRotation(180);
            Vector2 objectVelocity = (m_objectToFollow.transform.position - transform.position).normalized * m_speed;
            m_rb.velocity = objectVelocity;
            if (Vector2.Distance(transform.position, m_objectToFollow.transform.position) < m_targetReachedTolerance)
            {
                m_currentObjectState = ThrowableState.PickedUp;
            }
            break;
        }

        case ThrowableState.PickedUp:
        {
            m_rb.MovePosition(m_objectToFollow.GetComponent <Rigidbody2D>().position);
            break;
        }

        case ThrowableState.Inactive:
        {
            if (m_actor.contacts.any)
            {
                m_rb.velocity = Vector2.zero;     //könnte das object dadurch an der decke kleben?
                if (m_hitGround == false)         //facotored den drop nicht mit ein / schlimm?
                {
                    SubstractDurability();
                    m_hitGround = true;
                }
            }
            break;
        }

        case ThrowableState.Thrown:
        {
            CorrectRotation();
            //GetComponent<SpriteRenderer>().color = Color.yellow;
            if (m_actor.contacts.any)
            {
                SetInactive();         //abbprallen bei den leben mit einberechnen
            }
            break;
        }
        }
    }
예제 #10
0
    IEnumerator Recovering()
    {
        yield return(new WaitForSeconds(recoveryTime));

        state = ThrowableState.Free;
    }