Beispiel #1
0
        void Update()
        {
            if (ringData.GetBoolValue("grabbed"))
            {
                if (!grabbed) // grab just started
                {
                    grabbed     = true;
                    oldPosition = transform.position.ToVector2() + ringData.GetVec2Value("grabOffset");
                }

                GetDeltaPos(gm.input.GetPosition());

                StartCoroutine(RecordSpeedCO());

                if (ringData.GetBoolValue("pinned"))                // The ring is in the pin
                {
                    float translationValue = deltaPosition.y;

                    if (ringData.GetCollisionList().Count > 0)      // The ring is colliding with another ring
                    {
                        foreach (RingColor cl in ringData.GetCollisionList())
                        {
                            if (cl < ringData.GetColorValue())
                            {
                                translationValue = Mathf.Max(0.02f, deltaPosition.y);  // The value 0.02 allows a small bump downward
                                break;
                            }
                        }
                    }

                    // Move using Physics
                    rb.MovePosition(transform.position.ToVector2() + (translationValue * speed * Time.deltaTime) * Vector2.up);

                    speedVec.Set(0, speedVec.y);
                }
                else
                {
                    // Move without using Physics for better response in safe conditions
                    transform.Translate(deltaPosition.x * speed * Time.deltaTime, deltaPosition.y * speed * Time.deltaTime, 0);
                }

                oldPosition = transform.position.ToVector2() + ringData.GetVec2Value("grabOffset");
            }
            else  // ring not currently grabbed
            {
                if (grabbed) // grab just finished
                {
                    grabbed = false;

                    rb.AddForce(speedVec * inertia);
                }
            }
        }
        private void Update()
        {
            if (ringData.GetBoolValue("grabbed") && !glowActive)
            {
                glowActive = true;
                SetGlowActive(true);
            }

            else if (glowActive && !ringData.GetBoolValue("grabbed"))
            {
                glowActive = false;
                SetGlowActive(false);
            }
        }
Beispiel #3
0
        void Update()
        {
            if (ringData.GetBoolValue("pinned") && !ringData.GetBoolValue("pinCorrect") && !ringData.GetBoolValue("grabbed") && // ring left in the wrong position
                !unPinCOActive)
            {
                unPinCOActive = true;
                StartCoroutine(UnPinCO());
            }

            if (unPinCOActive && ringData.GetBoolValue("grabbed"))
            {
                unPinCOActive = false;
            }
        }
        void StopGrabbing()
        {
            isGrabbing = false;
            ringData.SetDataValue("grabbed", false);

            if (ringData.GetBoolValue("pinned") && !ringData.GetBoolValue("pinCorrect"))
            {
                ringData.SetDataValue(RingExpression.WORRIED);
            }
            else
            {
                ringData.SetDataValue(RingExpression.HAPPY);
            }
        }
Beispiel #5
0
        void Update()
        {
            if (ringData.GetBoolValue("grabbed") && gravityActive)
            {
                rb.gravityScale = 0f;
                gravityActive   = false;

                rb.velocity = Vector2.zero;
            }

            if (!gravityActive && !ringData.GetBoolValue("grabbed"))
            {
                rb.gravityScale = gravityScale;
                gravityActive   = true;
            }
        }