Beispiel #1
0
    public void ThrowToothInDirection(Vector2 forceVector)
    {
        toothState         = ToothState.Free;
        rigidBody.velocity = Vector3.zero;
        transform.position = player.TeethCarryPosition();
        rigidBody.AddForce(forceVector, ForceMode2D.Impulse);

        var rotationSpeed = Random.Range(throwMinRotationSpeed, throwMaxRotationSpeed);

        rigidBody.angularVelocity = rotationSpeed * ((Random.value <= 0.5f) ? -1f : 1f);
    }
Beispiel #2
0
    public void ThrowToothInDirection(Vector2 forceVector)
    {
        rigidBody.bodyType = RigidbodyType2D.Dynamic;
        toothState         = ToothState.Free;
        rigidBody.velocity = Vector3.zero;
        rigidBody.AddForce(forceVector, ForceMode2D.Impulse);
        // rigidBody.tim

        var rotationSpeed = Random.Range(throwMinRotationSpeed, throwMaxRotationSpeed);

        rigidBody.angularVelocity = rotationSpeed * ((Random.value <= 0.5f) ? -1f : 1f);
    }
Beispiel #3
0
    void DidFindFit()
    {
        var rb = GetComponent <Rigidbody2D>();

        // rb.constraints = RigidbodyConstraints2D.FreezeAll;
        rb.bodyType             = RigidbodyType2D.Kinematic;
        rb.velocity             = Vector3.zero;
        rb.angularVelocity      = 0f;
        frontImage.sortingOrder = sortOrderOnLock;
        backImage.sortingOrder  = sortOrderOnLock - 1;
        // var srList = GetComponentsInChildren<SpriteRenderer>();
        toothState          = ToothState.Anchored;
        manager.bonusScore += 1;
        // rb.bodyType = RigidbodyType2D.Kinematic;
    }
Beispiel #4
0
    void DidYankOut()
    {
        animator.SetBool("IsWarningLoose", false);
        Destroy(animator);
        armManager.DidYankTooth();
        head.angerLevel += ((isLooseTooth) ? looseAngerYank : toughAngerYank);
        gumController.GumSpotOpened(transform);

        playerController.DidGrabToothObject(gameObject);
        toothState = ToothState.Carried;


        rigidBody.constraints = RigidbodyConstraints2D.None;

        transform.position = playerController.TeethCarryPosition();

        toothFront.sortingOrder = carrySortOrderFront;
        toothBack.sortingOrder  = carrySortOrderBack;

        var zRot   = transform.rotation.eulerAngles.z;
        var newRot = zRot + (Random.Range(-carryInitialRotationNoise / 2f, carryInitialRotationNoise / 2f));

        transform.rotation = Quaternion.AngleAxis(newRot, Vector3.forward);
    }