public string GetHoverText(InteractionPoint ip) { if(ShouldUseHandAction(ip)) return "take"; else return "examine"; }
public Texture2D GetCursorHover(InteractionPoint ip) { if(ShouldUseHandAction(ip)){ return handCursorOpen; } else{ return examineCursor; } }
public bool CanSelect(InteractionPoint ip) { if(ShouldUseHandAction(ip)){ return true; } else{ return ip != null; } }
public Texture2D GetCursorActive(InteractionPoint ip) { if(ShouldUseHandAction(ip)){ return handCursorClosed; } else{ return examineCursor; } }
public void UseOn(InteractionPoint ip) { if(ShouldUseHandAction(ip)){ ip.OnMouseExit(); ip.gameObject.SetActive (false); Static.Inventory.InsertAtFirstAvailableSlot(ip.GetComponent<Examinable>()); } else if(ip){ Static.TextConsole.SetCommandText(ip.GetComponent<Examinable>().description); } }
public void UseOn(InteractionPoint ip) { var thrown = Instantiate(throwableObject, launchPoint.transform.position.ReplaceZ(0), Quaternion.identity) as GameObject; thrown.SetActive(true); Vector3 mouse = MouseHelper.MouseToWorld(Mathf.Abs(Camera.main.transform.position.z)).ReplaceZ(0); Vector3 diff = (mouse - launchPoint.transform.position); float time = Mathf.Abs(diff.x / throwSpeed); float dy = diff.y; float accG = Physics.gravity.y; float impulseY = (dy - 0.5f*accG*time*time) / time; thrown.rigidbody.isKinematic = false; thrown.rigidbody.AddForce(new Vector3(Mathf.Sign(diff.x)*throwSpeed,impulseY,0),ForceMode.VelocityChange); Debug.Log(throwSpeed + ","+impulseY); throwableObject = null; Static.InteractionController.overrideTool = null; }
public void addPoint(InteractionPoint point) { _kabsch.addPoint(point.globalReferencePosition, point.globalPosition, 1.0f); _shouldDoMovementSolve = true; }
public InteractionHand() { for (int i = 0; i < 6; i++) { _basisPoints[i] = new InteractionPoint(); } }
public Texture2D GetCursorHover(InteractionPoint ip) { return icon; }
public Texture2D GetCursorActive(InteractionPoint ip) { return icon; }
public bool CanSelect(InteractionPoint ip) { return true; }
/// <summary> /// Sets the interaction point to follow pinch. /// </summary> public void SetInteractionPointPinch() { currentInteractionPoint = InteractionPoint.Pinch; }
/// <summary> /// Sets the interaction point to follow pointer. /// </summary> public void SetInteractionPointPointer() { currentInteractionPoint = InteractionPoint.Pointer; }
public Frame[] GetFrames(Tile[,] t16SP12, Tile[,] t16SP34, Tile[,] t8SP12, Tile[,] t8SP34) { int l = 0; if (Hitboxes != null) { l = Hitboxes.Length; } HitBox[] hbs = new HitBox[l]; for (int i = 0; i < l; i++) { hbs[i] = Hitboxes[i].ToHitBox(); } l = 0; if (InteractionPoints != null) { l = InteractionPoints.Length; } InteractionPoint[] ips = new InteractionPoint[l]; for (int i = 0; i < l; i++) { ips[i] = (InteractionPoint)InteractionPoints[i].ToHitBox(); } Frame[] frs = new Frame[Frames.Length]; for (int i = 0; i < Frames.Length; i++) { frs[i] = new Frame() { MidX = Frames[i].MidX, MidY = Frames[i].MidY, Name = Frames[i].Name }; for (int j = 0; j < Frames[i].TileMasks.Length; j++) { frs[i].AddTile(Frames[i].TileMasks[j].ToTileMask(t16SP12, t16SP34, t8SP12, t8SP34)); } for (int j = 0; j < Frames[i].HitboxesNames.Length; j++) { for (int q = 0; q < hbs.Length; q++) { if (hbs[q].Name == Frames[i].HitboxesNames[j]) { frs[i].HitBoxes.Add(hbs[q]); } } } for (int j = 0; j < Frames[i].InteractionPointsNames.Length; j++) { for (int q = 0; q < ips.Length; q++) { if (ips[q].Name == Frames[i].InteractionPointsNames[j]) { frs[i].InteractionPoints.Add(ips[q]); } } } } Match m; foreach (HitBox hb in hbs) { m = Regex.Match(hb.Name, startNumbsPattern); hb.Name = hb.Name.Substring(m.Length); } foreach (HitBox hb in ips) { m = Regex.Match(hb.Name, startNumbsPattern); hb.Name = hb.Name.Substring(m.Length); } return(frs); }
public string GetHoverText(InteractionPoint ip) { return "throw "+throwableObject.name + "at"; }
private bool ShouldUseHandAction(InteractionPoint ip) { var player = grabOrigin.position; var mousePos = MouseHelper.MouseToWorld(Camera.main.transform.position.z); return ip && ip.canPickup && Vector3.Distance(player, mousePos) < grabRange; }
public void updateInfo(Hand hand) { _lastTimeUpdated = Time.time; _leapHand = hand; foreach (Finger finger in hand.Fingers) { Dictionary<Finger.FingerJoint, InteractionPoint> fingerPoints; if (!_fingerPointMap.TryGetValue(finger.Type, out fingerPoints)) { fingerPoints = new Dictionary<Finger.FingerJoint, InteractionPoint>(); _fingerPointMap[finger.Type] = fingerPoints; } for (int i = 0; i < 4; i++) { Finger.FingerJoint jointType = (Finger.FingerJoint)i; Vector3 jointPosition = HandInfo.unityPos(finger.JointPosition(jointType)); InteractionPoint point; if (!fingerPoints.TryGetValue(jointType, out point)) { point = new InteractionPoint(); fingerPoints[jointType] = point; } point.update(jointPosition); } } Vector3 palmPoint = HandInfo.unityPos(hand.PalmPosition); Matrix basis = hand.Basis; Vector3 xBasis = HandInfo.unityDir(basis.xBasis) * PALM_BASIS_WEIGHT; Vector3 yBasis = HandInfo.unityDir(basis.yBasis) * PALM_BASIS_WEIGHT; Vector3 zBasis = HandInfo.unityDir(basis.zBasis) * PALM_BASIS_WEIGHT; _basisPoints[0].update(palmPoint + xBasis); _basisPoints[1].update(palmPoint + yBasis); _basisPoints[2].update(palmPoint + zBasis); _basisPoints[3].update(palmPoint - xBasis); _basisPoints[4].update(palmPoint - yBasis); _basisPoints[5].update(palmPoint - zBasis); _closeObjects.Clear(); Collider[] colliders = Physics.OverlapSphere(palmPoint, HandInfo.unityLength(0.25f), InteractionController.instance.grabbableLayer); foreach (Collider c in colliders) { _closeObjects.Add(c.gameObject); } }