public void UnHighlight() { ItemDrag dragItem = GetComponent <ItemDrag>(); if (dragItem != null) { dragItem.SetActualPositionRotationToTarget(); } SetShaderNormal(); State = ItemState.Attached; Root.ItemHighlightList.Remove(this); }
public void SetAllActualPositionToTarget() { System.Action <Item> action = delegate(Item item) { ItemDrag dragItemMod = item.GetComponent <ItemDrag>(); if (dragItemMod != null) { dragItemMod.SetActualPositionRotationToTarget(); } }; CallDelegateAll(action); }
private void OnPointerExitAttached(PointerEventData data) { #if LOG Debug.Log("OnPointerExitAttached " + this.name); #endif if (data.pointerPress != null) { GetComponent <Item>().SetShaderNormal(); if (ItemDragEnteredThis != null) { ItemDragEnteredThis.AccessoryRendererState = false; ItemDragEnteredThis = null; } } }
private void OnPointerUpInstantiate(PointerEventData data) { #if LOG Debug.Log("OnPointerUpAttachedHighlighted " + this.name); #endif VisualizationUI plannerUI = FindObjectOfType <VisualizationUI>(); Item instantiatedItem = plannerUI.InstantiateSelectedItem(data); ItemDrag instantiatedItemDrag = instantiatedItem.GetComponent <ItemDrag>(); ItemDrop itemDrop = GetComponent <ItemDrop>(); if (itemDrop != null) { instantiatedItemDrag.ThisEnteredDropItem = itemDrop; instantiatedItemDrag.ParentItemDrop = itemDrop; ItemSnap itemSnap = instantiatedItemDrag.NearestItemSnap(data); instantiatedItemDrag.ParentItemSnap = itemSnap; Ray ray = itemSnap.Snap(instantiatedItem, data); instantiatedItemDrag.SetTargetPositionRotation(ray.origin, ray.direction); //set to outline and normal to get rid of quirk where instantied shader isn't immediately properly lit instantiatedItem.SetShaderOutline(_itemSettings.InstantiateOutlineColor); instantiatedItem.SetShaderNormal(); instantiatedItem.State = ItemState.NoInstantiate; //TODO this should always be able to attach, why are we checking? if (itemDrop.CanAttach(instantiatedItem.TagArray)) { SetShaderOutline(_itemSettings.InstantiateOutlineColor); } else { SetShaderNormal(); State = ItemState.NoInstantiate; } } ItemColor itemColor = GetComponent <ItemColor>(); if (itemColor != null) { Item item = GetComponent <Item>(); item.SetBlendMaterial(instantiatedItem.MaterialArray[0].mainTexture); SetShaderNormal(); State = ItemState.NoInstantiate; StartCoroutine(instantiatedItem.DestroyItemCoroutine()); } }
private void OnPointerEnterAttached(PointerEventData data) { #if LOG Debug.Log("OnPointerEnterAttached " + this.name); #endif if (data.pointerPress != null) { Item item = data.pointerPress.GetComponent <Item>(); if (item != null && CanAttach(item.TagArray) || item != null && ContainsItem(item)) { GetComponent <Item>().SetShaderOutline(_itemSettings.DropOutlineColor); ItemDragEnteredThis = item.GetComponent <ItemDrag>(); ItemDragEnteredThis.AccessoryRendererState = true; } } }
public override Ray Snap(Item item, PointerEventData data) { ItemDrag dragItem = item.GetComponent <ItemDrag>(); if (dragItem.AttachPointArray != null && dragItem.AttachPointArray.Length > 0) { for (int i = 0; i < dragItem.AttachPointArray.Length; ++i) { if (ItemUtility.TestTagArrays(dragItem.AttachPointArray[i].TagArray, ChildTagArray)) { return(new Ray(transform.position - dragItem.AttachPointArray[i].transform.localPosition, -transform.forward)); } } return(new Ray(transform.position, -transform.forward)); } else { return(new Ray(this.transform.position, -transform.forward)); } }