예제 #1
0
        // When the step is done - switch free and fixed ends references,
        // so the step cycle becomes smaller twice

        void SwitchEnds()
        {
            GameObject temp0 = freeEnd;
            ChainEnd   temp1 = free;

            freeEnd  = fixedEnd;
            fixedEnd = temp0;

            free = fixd;
            fixd = temp1;
        }
예제 #2
0
        public static Vector2 normalVector = Vector2.up; // Platform orientation, will be changed, if you trig to vertical platform

        void Start()
        {
            free = freeEnd.GetComponent <ChainEnd>();
            fixd = fixedEnd.GetComponent <ChainEnd>();

            InputHandler.OnTap         += StartMovingUp;
            InputHandler.OnTap2        += ToFall;
            InputHandler.OnTap3        += ChangeDirection;
            ChainEnd.OnPull            += PullFixedEnd;
            ChainEnd.OnRestoreDefaults += RestoreDefaults;
            ChainEnd.OnGameOver        += GameOver;
        }
예제 #3
0
        IEnumerator Fall(ChainEnd end)
        {
            // Adds a kinematic "gravity" to free end when it's already kicked, relative to platform orientation

            while (Mathf.Abs(Vector2.SignedAngle(end.Rigidbody.velocity, normalVector)) > 10f)
            {
                end.Rigidbody.velocity += -normalVector * 0.5f + Vector2.Perpendicular(normalVector) * 0.1f;
                yield return(null);
            }

            end.Rigidbody.velocity = -normalVector * end.Rigidbody.velocity.magnitude;
        }