Beispiel #1
0
 public override int GetHashCode()
 {
     //unchecked
     {
         int hashCode = DropPieceSimple.GetHashCode();
         hashCode = (hashCode * 397) ^ (Positions?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (PositionLerp?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)CurrentState;
         hashCode = (hashCode * 397) ^ HoldTimer.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #2
0
 public bool Equals(DropPiece other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     if (Positions.SequenceEqual(other.Positions) &&
         PositionLerp.SequenceEqual(other.PositionLerp) &&
         CurrentState == other.CurrentState &&
         HoldTimer.Equals(other.HoldTimer))
     {
         return(this.DropPieceSimple.Equals(other.DropPieceSimple));
     }
     else
     {
         return(false);
     }
 }
Beispiel #3
0
    public override void OnPose(PoseEvent e, bool isNew, Vector3 position, Quaternion rotation)
    {
        // Check that the pose is within visible view
        Vector3 screenPos = Camera.main.WorldToViewportPoint(position);

        // Only detect if the OnPose object is detected where the display is
        if (screenPos.x >= -0.25f && screenPos.x <= 1.25f &&
            screenPos.y >= 0f && screenPos.y <= 1f)
        {
            CancelInvoke("LosePhysicalPose");

            if (fingerObject == null)
            {
                // New pose: create the rigidbody object for it
                fingerObject = Instantiate(fingerPrefab, Camera.main.transform);
                fingerObject.transform.position = position;
            }
            else
            {
                // Smooth the motion of the kinematic rigidbody to ensure better
                // collision with buttons
                PositionLerp positionLerp = fingerObject.GetComponent <PositionLerp>();
                if (positionLerp != null)
                {
                    positionLerp.SetTarget(position);
                }
            }
        }
        else
        {
            // Don't loose it too fast as it might come back...
            if (!IsInvoking("LosePhysicalPose"))
            {
                Invoke("LosePhysicalPose", 0.5f);
            }
        }
    }
Beispiel #4
0
 void Start()
 {
     _initialPosition = PhysicalButton.transform.position;
     _lerp            = PhysicalButton.gameObject.AddComponent <PositionLerp>();
     _canBePushed     = true;
 }