void UpdateInteractorReferenceTransform() { if (interactor.referenceTransform == null) { interactor.referenceTransform = new GameObject(name + " interactor helper transform").transform; } TransformBehavior.AdjustTransform(interactor.referenceTransform, transform, interactorReferenceBehavior, 0); }
bool GetUpdatedEquippedVelocities(Inventory.InventorySlot equippedSlot, out Vector3 velocityTarget, out Vector3 angularTarget) { bool realNumbers = false; Vector3 localPosition; Quaternion localRotation; TransformBehavior.GetValues(equippedSlot.item.equipTransform, equipID, out localPosition, out localRotation); Vector3 targetItemPosition = transform.TransformPoint(localPosition); Vector3 positionDelta = (targetItemPosition - equippedSlot.sceneItem.rigidbody.position); velocityTarget = (positionDelta * VelocityMagic * Time.deltaTime); if (float.IsNaN(velocityTarget.x) == false && float.IsInfinity(velocityTarget.x) == false) { realNumbers = true; } else { velocityTarget = Vector3.zero; } Quaternion targetItemRotation = transform.rotation * localRotation; Quaternion rotationDelta = targetItemRotation * Quaternion.Inverse(equippedSlot.sceneItem.transform.rotation); float angle; Vector3 axis; rotationDelta.ToAngleAxis(out angle, out axis); if (angle > 180) { angle -= 360; } if (angle != 0 && float.IsNaN(axis.x) == false && float.IsInfinity(axis.x) == false) { angularTarget = angle * axis * AngularVelocityMagic * Time.deltaTime; realNumbers &= true; } else { angularTarget = Vector3.zero; } return(realNumbers); }
public static void GetValues(TransformBehavior equipBehavior, int settingIndex, out Vector3 localPosition, out Quaternion localRotation) { localPosition = Vector3.zero; localRotation = Quaternion.identity; if (equipBehavior == null) { Debug.LogWarning("Cant get values... transform behavior is null"); return; } equipBehavior.GetValues(settingIndex, out localPosition, out localRotation); }
public static void AdjustTransform(Transform transform, TransformBehavior equipBehavior, int settingIndex, Vector3 multiplier) { if (transform == null) { Debug.LogWarning("cant adjust, transform is null"); return; } if (equipBehavior == null) { Debug.LogWarning("Cant move :: " + transform.name + " equip behavior is null"); return; } equipBehavior.AdjustTransform(transform, settingIndex, multiplier); }
void SnapItemToPosition(int equipSlot) { Transform itemTransform = equippedSlots[equipSlot].sceneItem.transform; ItemBehavior item = equippedSlots[equipSlot].item; Transform oldParent = itemTransform.parent; TransformBehavior.AdjustTransform(itemTransform, equipPoints[equipSlot].transform, item.equipTransform, equipSlot); if (item.equipType != EquipType.Normal) { itemTransform.parent = oldParent; } }
public static void SetValues(TransformBehavior equipBehavior, int settingIndex, Transform transform) { if (equipBehavior == null) { Debug.LogWarning("Cant set values... transform behavior is null"); return; } if (transform == null) { Debug.LogWarning("Cant set values on " + equipBehavior.name + " ... transform is null"); return; } equipBehavior.SetValues(settingIndex, transform); }
private void OnTriggerEnter(Collider other) { enemyObj = other.GetComponent <TransformBehavior>(); enemyHealthBehavior = other.GetComponent <InstantiatedFloatDataBehavior>(); enemyHealthCheck = other.GetComponent <InstantiatedValueCheckBehavior>(); if (enemyObj == null || enemyHealthBehavior == null || enemyHealthCheck == null) { return; } enemyObj.KnockbackFloatArg(knockBackDistance.value); enemyHealthBehavior.dataObj.value -= playerDamage.value; enemyHealthCheck.CheckValue(0); }
void AdjustHints() { Vector3 textOffset = rightHand[0].textOffset; for (int i = 0; i < rightHand.Length; i++) { HintUIElement re = rightHand[i]; ControllerHintUIElement rElement = re.element; rElement.transform.localScale = Vector3.one * hintScale; rElement.text.transform.localScale = Vector3.one * textScale; rElement.text.transform.localPosition = textOffset;//rightHand[i].textOffset; TransformBehavior.AdjustTransform(rElement.transform, Player.instance.rightHand.transform, hintTransforms, i); leftHand[i].element.transform.localScale = Vector3.one * hintScale; leftHand[i].element.text.transform.localScale = Vector3.one * textScale; leftHand[i].element.text.transform.localPosition = textOffset;//leftHand[i].textOffset; TransformBehavior.AdjustTransform(leftHand[i].element.transform, Player.instance.leftHand.transform, hintTransforms, i, new Vector3(-1, 1, 1)); } }
void FixedUpdate() { if (equipID < 0 || equipID >= baseInventory.equippedSlots.Length) { Debug.LogError("Equip slot " + equipID + " is out of range on inventory " + baseInventory); return; } Inventory.InventorySlot slot = baseInventory.equippedSlots[equipID]; if (slot != null) { ItemBehavior item = slot.item; if (item.equipType == Inventory.EquipType.Physics) { UpdateAttachedVelocity(slot); } else if (item.equipType == Inventory.EquipType.Normal) { TransformBehavior.AdjustTransform(slot.sceneItem.transform, transform, item.equipTransform, equipID); } } }
void SaveLocalPositionAndRotation() { TransformBehavior.SetValues(item.itemBehavior.equipTransform, setIndex, item.transform); }
public static void AdjustTransform(Transform transform, Transform parent, TransformBehavior equipBehavior, int settingIndex) { AdjustTransform(transform, parent, equipBehavior, settingIndex, Vector3.one); }
void SetUpMessageCenter() { Transform handTransform = Player.instance.GetHand(messagesHand).transform; TransformBehavior.AdjustTransform(messageCenter.transform, handTransform, messagesEquip, 0); }
void OnInventoryUIOpen(InventoryUI.UIType type, UIElementHolder uiHolder) { SteamVR_Input_Sources hand; switch (type) { // quick inventory case InventoryUI.UIType.QuickInventory: hand = VRManager.Int2Hand(inventoryUI.quickInventoryInteractorID); StandardizedVRInput.MarkActionOccupied(QUICK_INVENTORY_CONSUME_ACTION, VRUIInput.GetUIHand()); StandardizedVRInput.instance.ShowHint(hand, QUICK_INVENTORY_CONSUME_ACTION, "Use"); TransformBehavior.AdjustTransform(uiHolder.baseObject.transform, Player.instance.GetHand(hand).transform, quickInventoryEquip, 0); VRUIInput.SetUIHand(hand); break; // full inventory case InventoryUI.UIType.FullInventory: StandardizedVRInput.MarkActionOccupied(FULL_INVENTORY_CONSUME_ACTION, SteamVR_Input_Sources.Any); StandardizedVRInput.MarkActionOccupied(FULL_INVENTORY_DROP_ACTION, SteamVR_Input_Sources.Any); // StandardizedVRInput.MarkActionOccupied(FULL_INVENTORY_FAVORITE_ACTION, SteamVR_Input_Sources.Any); StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.RightHand, FULL_INVENTORY_CONSUME_ACTION, "Use Right Hand"); StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.LeftHand, FULL_INVENTORY_CONSUME_ACTION, "Use Left Hand"); StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.Any, FULL_INVENTORY_DROP_ACTION, "Drop"); // StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.Any, FULL_INVENTORY_FAVORITE_ACTION, "Favorite"); VRUIInput.SetUIHand(SteamVR_Input_Sources.Any); break; // quick trade case InventoryUI.UIType.QuickTrade: hand = VRManager.Int2Hand(inventoryUI.quickTradeInteractorID); StandardizedVRInput.MarkActionOccupied(QUICK_TRADE_SINGLE_TRADE_ACTION, hand); StandardizedVRInput.MarkActionOccupied(QUICK_TRADE_TRADE_ALL_ACTION, hand); StandardizedVRInput.MarkActionOccupied(QUICK_TRADE_SWITCH_TO_FULL_TRADE_ACTION, hand); StandardizedVRInput.instance.ShowHint(hand, QUICK_TRADE_SINGLE_TRADE_ACTION, "Take Item"); StandardizedVRInput.instance.ShowHint(hand, QUICK_TRADE_TRADE_ALL_ACTION, "Take All"); StandardizedVRInput.instance.ShowHint(hand, QUICK_TRADE_SWITCH_TO_FULL_TRADE_ACTION, "Open Trade"); TransformBehavior.AdjustTransform(uiHolder.baseObject.transform, Player.instance.GetHand(hand).transform, quickTradeEquip, 0); VRUIInput.SetUIHand(hand); break; // full trade case InventoryUI.UIType.FullTrade: StandardizedVRInput.MarkActionOccupied(FULL_TRADE_CONSUME_ACTION, SteamVR_Input_Sources.Any); StandardizedVRInput.MarkActionOccupied(FULL_TRADE_TRADE_ALL_ACTION, SteamVR_Input_Sources.Any); StandardizedVRInput.MarkActionOccupied(FULL_TRADE_SINGLE_TRADE_ACTION, SteamVR_Input_Sources.Any); StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.RightHand, FULL_TRADE_CONSUME_ACTION, "Use Right Hand"); StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.LeftHand, FULL_TRADE_CONSUME_ACTION, "Use Left Hand"); StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.Any, FULL_TRADE_SINGLE_TRADE_ACTION, "Trade Item"); StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.Any, FULL_TRADE_TRADE_ALL_ACTION, "Trade All"); VRUIInput.SetUIHand(SteamVR_Input_Sources.Any); break; } }