protected void setupDragIcon(CustomizerGestureModel currentGesture) { dragContainer.SetImage(Sprite.Create(dragTexture, new Rect(0f, 0f, dragTexture.width, dragTexture.height), default(Vector2))); (dragContainer.transform as RectTransform).anchoredPosition = currentGesture.TouchDownStartPos; setRelativeIconPostion(currentGesture.TouchDownStartPos); dragContainer.Show(); }
public override void EnterState(CustomizerGestureModel currentGesture) { decalChannelData.OriginalChannelRed = decalChannelData.ActualChannelRed; decalChannelData.OriginalChannelGreen = decalChannelData.ActualChannelGreen; decalChannelData.OriginalChannelBlue = decalChannelData.ActualChannelBlue; decalChannelData.OriginalRedUVOffset = decalChannelData.ActualRedUVOffset; decalChannelData.OriginalGreenUVOffset = decalChannelData.ActualGreenUVOffset; decalChannelData.OriginalBlueUVOffset = decalChannelData.ActualBlueUVOffset; decalChannelData.OriginalRedRenderer = decalChannelData.ActualRedRenderer; decalChannelData.OriginalGreenRenderer = decalChannelData.ActualGreenRenderer; decalChannelData.OriginalBlueRenderer = decalChannelData.ActualBlueRenderer; dragTexture = currentGesture.DragIconTexture; if (dragTexture != null) { CustomizationContext.EventBus.DispatchEvent(new CustomizerDragEvents.StartDragDecalButton(currentGesture)); CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.InputStateChange(isDown: true, isManipulator: false)); CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.InputOverChannel(CustomizationChannel.NONE)); setupDragIcon(currentGesture); EventManager.Instance.PostEvent("SFX/UI/ClothingDesigner/ItemSelect", EventAction.PlaySound); } else { CustomizationContext.EventBus.DispatchEvent(default(CustomizerDragEvents.EndDragDecalButton)); CustomizationContext.EventBus.DispatchEvent(default(CustomizerDragEvents.GestureComplete)); CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.InputStateChange(isDown: false, isManipulator: false)); } }
private CustomizerGestureModel processGesture(ITouch touch, CustomizerGestureModel gestureModel) { gestureModel.TouchDownStartPos = touch.position; if (isOverUI(touch)) { if (EventSystem.current.currentSelectedGameObject != null) { EquipmentIcon component = EventSystem.current.currentSelectedGameObject.GetComponent <EquipmentIcon>(); if (component != null) { gestureModel.TouchDownStartArea = AreaTouchedEnum.INVENTORY_BUTTON; gestureModel.DragIconTexture = component.GetIcon() as Texture2D; gestureModel.ItemId = component.EquipmentId; gestureModel.IsEquippable = component.IsEquippable; } } } else if (isTouchBlockedByUIControls(touch)) { gestureModel.TouchDownStartArea = AreaTouchedEnum.CLICK_BLOCKING_UI; } else { gestureModel.TouchDownStartArea = AreaTouchedEnum.PENGUIN_PREVIEW_ROTATION_AREA; } return(gestureModel); }
protected override void ProcessOneTouch(ITouch touch) { switch (touch.phase) { case TouchPhase.Began: currentGesture = processGesture(touch, currentGesture); break; case TouchPhase.Ended: case TouchPhase.Canceled: currentGesture = new CustomizerGestureModel(); break; case TouchPhase.Moved: switch (currentGesture.TouchDownStartArea) { case AreaTouchedEnum.INVENTORY_BUTTON: if (checkButtonDrag(touch.deltaPosition) && currentGesture.IsEquippable) { InventoryContext.EventBus.DispatchEvent(new InventoryDragEvents.DragInventoryButton(currentGesture)); } break; case AreaTouchedEnum.PENGUIN_PREVIEW_ROTATION_AREA: InventoryContext.EventBus.DispatchEvent(new InventoryDragEvents.RotatePenguinPreview(currentGesture)); break; } break; case TouchPhase.Stationary: break; } }
public override void EnterState(CustomizerGestureModel currentGesture) { templateData = currentGesture.TemplateData; dragTexture = currentGesture.DragIconTexture; if (dragTexture != null) { setupDragIcon(currentGesture); return; } Log.LogError(this, "Current gesture drag icon texture was null. Exiting drag template state."); ExitState(); CustomizationContext.EventBus.DispatchEvent(default(CustomizerDragEvents.GestureComplete)); }
public override void EnterState(CustomizerGestureModel currentGesture) { decalChannelData.OriginalRedUVOffset = decalChannelData.ActualRedUVOffset; decalChannelData.OriginalGreenUVOffset = decalChannelData.ActualGreenUVOffset; decalChannelData.OriginalBlueUVOffset = decalChannelData.ActualBlueUVOffset; decalChannelData.OriginalRedRenderer = decalChannelData.ActualRedRenderer; decalChannelData.OriginalGreenRenderer = decalChannelData.ActualGreenRenderer; decalChannelData.OriginalBlueRenderer = decalChannelData.ActualBlueRenderer; switch (currentGesture.Channel) { case CustomizationChannel.BLUE: decalChannelData.OriginalChannelRed = decalChannelData.ActualChannelRed; decalChannelData.OriginalChannelGreen = decalChannelData.ActualChannelGreen; decalChannelData.OriginalChannelBlue = null; decalChannelData.OriginalBlueRenderer = null; currentGesture.DragIconTexture = decalChannelData.ActualChannelBlue; startingChannel = CustomizationChannel.BLUE; break; case CustomizationChannel.GREEN: decalChannelData.OriginalChannelRed = decalChannelData.ActualChannelRed; decalChannelData.OriginalChannelBlue = decalChannelData.ActualChannelBlue; decalChannelData.OriginalChannelGreen = null; decalChannelData.OriginalGreenRenderer = null; currentGesture.DragIconTexture = decalChannelData.ActualChannelGreen; startingChannel = CustomizationChannel.GREEN; break; case CustomizationChannel.RED: decalChannelData.OriginalChannelGreen = decalChannelData.ActualChannelGreen; decalChannelData.OriginalChannelBlue = decalChannelData.ActualChannelBlue; decalChannelData.OriginalChannelRed = null; decalChannelData.OriginalRedRenderer = null; currentGesture.DragIconTexture = decalChannelData.ActualChannelRed; startingChannel = CustomizationChannel.RED; break; } if (currentGesture.DragIconTexture != null) { dragTexture = currentGesture.DragIconTexture; setupDragIcon(currentGesture); CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.InputStateChange(isDown: true, isManipulator: false)); CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.InputOverChannel(CustomizationChannel.NONE)); } else { CustomizationContext.EventBus.DispatchEvent(default(CustomizerDragEvents.GestureComplete)); CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.InputStateChange(isDown: false, isManipulator: false)); } }
public RotatePenguinPreview(CustomizerGestureModel gestureModel) { GestureModel = gestureModel; }
public DragInventoryButton(CustomizerGestureModel gestureModel) { GestureModel = gestureModel; }
public DragFabricButton(CustomizerGestureModel gestureModel) { GestureModel = gestureModel; }
public override void EnterState(CustomizerGestureModel currentGesture) { this.currentGesture = currentGesture; InventoryContext.EventBus.DispatchEvent(default(InventoryUIEvents.EnableScrollRect)); }
protected override void ProcessOneTouch(ITouch touch) { switch (touch.phase) { case TouchPhase.Began: currentGesture = processGesture(touch, currentGesture); break; case TouchPhase.Ended: if (Time.time - currentGesture.TouchStartTime < TapTimeThreshold && Vector2.Distance(touch.position, currentGesture.TouchDownStartPos) < tapDistanceThreshold) { switch (currentGesture.TouchDownStartArea) { case AreaTouchedEnum.GREEN_CHANNEL: if (CurrentState == CustomizerState.FABRIC) { CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.UpdateChannelFabric(CustomizationChannel.GREEN, originalFabricChannelData.ActualChannelGreen, originalFabricChannelData.UVOffsetGreen)); } else { CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.UpdateChannelDecal(CustomizationChannel.GREEN, originalDecalChannelData.ActualChannelGreen, originalDecalChannelData.ActualGreenUVOffset, originalDecalChannelData.ActualGreenRenderer)); } CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.InputOverChannel(CustomizationChannel.GREEN)); break; case AreaTouchedEnum.BLUE_CHANNEL: if (CurrentState == CustomizerState.FABRIC) { CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.UpdateChannelFabric(CustomizationChannel.BLUE, originalFabricChannelData.ActualChannelBlue, originalFabricChannelData.UVOffsetBlue)); } else { CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.UpdateChannelDecal(CustomizationChannel.BLUE, originalDecalChannelData.ActualChannelBlue, originalDecalChannelData.ActualBlueUVOffset, originalDecalChannelData.ActualBlueRenderer)); } CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.InputOverChannel(CustomizationChannel.BLUE)); break; case AreaTouchedEnum.RED_CHANNEL: if (CurrentState == CustomizerState.FABRIC) { CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.UpdateChannelFabric(CustomizationChannel.RED, originalFabricChannelData.ActualChannelRed, originalFabricChannelData.UVOffsetRed)); } else { CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.UpdateChannelDecal(CustomizationChannel.RED, originalDecalChannelData.ActualChannelRed, originalDecalChannelData.ActualRedUVOffset, originalDecalChannelData.ActualRedRenderer)); } CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.InputOverChannel(CustomizationChannel.RED)); break; case AreaTouchedEnum.TEMPLATE_BUTTON: if (currentGesture.IsEnabled) { if (currentGesture.IsEquippable) { Sprite templateSprite = Sprite.Create(currentGesture.DragIconTexture, new Rect(0f, 0f, currentGesture.DragIconTexture.width, currentGesture.DragIconTexture.height), Vector2.zero); breadcrumbController.RemovePersistentBreadcrumb(templateBreadcrumbType, currentGesture.ItemDefinitionId.ToString()); CustomizationContext.EventBus.DispatchEvent(new CustomizerUIEvents.SelectTemplate(currentGesture.TemplateData, templateSprite)); } else { ClothingDesignerContext.EventBus.DispatchEvent(new ClothingDesignerUIEvents.ShowMemberFlow("blueprints")); } } break; } } currentGesture = new CustomizerGestureModel(); break; case TouchPhase.Canceled: currentGesture = new CustomizerGestureModel(); break; case TouchPhase.Moved: switch (currentGesture.TouchDownStartArea) { case AreaTouchedEnum.RED_CHANNEL: case AreaTouchedEnum.GREEN_CHANNEL: case AreaTouchedEnum.BLUE_CHANNEL: CustomizationContext.EventBus.DispatchEvent(new CustomizerDragEvents.DragOffChannel(currentGesture)); break; case AreaTouchedEnum.FABRIC_BUTTON: if (checkButtonDrag(touch.deltaPosition)) { breadcrumbController.RemovePersistentBreadcrumb(fabricBreadcrumbType, currentGesture.ItemDefinitionId.ToString()); CustomizationContext.EventBus.DispatchEvent(new CustomizerDragEvents.DragFabricButton(currentGesture)); } break; case AreaTouchedEnum.DECAL_BUTTON: if (checkButtonDrag(touch.deltaPosition)) { breadcrumbController.RemovePersistentBreadcrumb(decalBreadcrumbType, currentGesture.ItemDefinitionId.ToString()); CustomizationContext.EventBus.DispatchEvent(new CustomizerDragEvents.DragDecalButton(currentGesture)); } break; case AreaTouchedEnum.TEMPLATE_BUTTON: if (checkButtonDrag(touch.deltaPosition) && currentGesture.IsEquippable) { breadcrumbController.RemovePersistentBreadcrumb(templateBreadcrumbType, currentGesture.ItemDefinitionId.ToString()); CustomizationContext.EventBus.DispatchEvent(new CustomizerDragEvents.DragTemplate(currentGesture)); } break; case AreaTouchedEnum.PENGUIN_ROTATION_AREA: CustomizationContext.EventBus.DispatchEvent(new CustomizerDragEvents.RotatePenguin(currentGesture)); break; case AreaTouchedEnum.CLICK_BLOCKING_UI: break; } break; case TouchPhase.Stationary: break; } }
private CustomizerGestureModel processGesture(ITouch touch, CustomizerGestureModel gestureModel) { gestureModel.TouchDownStartPos = touch.position; gestureModel.TouchStartTime = Time.time; if (isOverUI(touch)) { PointerEventData pointerEventData = new PointerEventData(EventSystem.current); pointerEventData.position = touch.position; List <RaycastResult> list = new List <RaycastResult>(); EventSystem.current.RaycastAll(pointerEventData, list); GameObject gameObject = null; float num = 0f; if (list != null && list.Count > 0) { for (int i = 0; i < list.Count; i++) { if (num <= list[i].index) { gameObject = list[i].gameObject; num = list[i].index; } } } if (gameObject != null) { CustomizationButton component = gameObject.GetComponent <CustomizationButton>(); if (component != null && component.CanDrag && component.GetTexture != null) { switch (component.DraggableButtonType) { case DraggableButtonType.TEMPLATE: { TemplateIcon templateIcon = component as TemplateIcon; gestureModel.TouchDownStartArea = AreaTouchedEnum.TEMPLATE_BUTTON; gestureModel.DragIconTexture = component.GetTexture; gestureModel.TemplateData = templateIcon.TemplateData; gestureModel.IsEquippable = templateIcon.CanSelect; gestureModel.ItemDefinitionId = templateIcon.DefinitionId; gestureModel.IsEnabled = templateIcon.IsEnabled; break; } case DraggableButtonType.FABRIC: gestureModel.TouchDownStartArea = AreaTouchedEnum.FABRIC_BUTTON; gestureModel.DragIconTexture = component.GetTexture; gestureModel.ItemDefinitionId = component.DefinitionId; break; case DraggableButtonType.DECAL: gestureModel.TouchDownStartArea = AreaTouchedEnum.DECAL_BUTTON; gestureModel.DragIconTexture = component.GetTexture; gestureModel.ItemDefinitionId = component.DefinitionId; break; } } } } else if (isTouchBlockedByUIControls(touch)) { gestureModel.TouchDownStartArea = AreaTouchedEnum.CLICK_BLOCKING_UI; } else { Ray ray = Camera.main.ScreenPointToRay(touch.position); if (Physics.Raycast(ray, out var hitInfo)) { GameObject gameObject2 = hitInfo.collider.gameObject; if (gameObject2.GetComponent <SkinnedMeshRenderer>() != null && gameObject2.GetComponent <SkinnedMeshRenderer>().sharedMaterial.shader.name.Contains("Equipment")) { Texture2D texture2D = gameObject2.GetComponent <SkinnedMeshRenderer>().sharedMaterial.GetTexture(EquipmentShaderParams.DECALS_123_OPACITY_TEX) as Texture2D; if (texture2D == null) { Log.LogErrorFormatted(this, "Unable to retrieve decal 123 map on item {0}. Property did not exist {1}.", gameObject2.name, EquipmentShaderParams.DECALS_123_OPACITY_TEX); return(gestureModel); } Vector2 textureCoord = hitInfo.textureCoord; textureCoord.Scale(new Vector2(texture2D.width, texture2D.height)); Color pixel = texture2D.GetPixel((int)textureCoord.x, (int)textureCoord.y); if (Mathf.Abs(pixel.r) < Mathf.Epsilon && Mathf.Abs(pixel.g) < Mathf.Epsilon && Mathf.Abs(pixel.b) < Mathf.Epsilon) { gestureModel.TouchDownStartArea = AreaTouchedEnum.NOTHING; } else if (pixel.r > pixel.g && pixel.r > pixel.b) { gestureModel.TouchDownStartArea = AreaTouchedEnum.RED_CHANNEL; gestureModel.StartGameObject = gameObject2; } else if (pixel.g > pixel.r && pixel.g > pixel.b) { gestureModel.TouchDownStartArea = AreaTouchedEnum.GREEN_CHANNEL; gestureModel.StartGameObject = gameObject2; } else { gestureModel.TouchDownStartArea = AreaTouchedEnum.BLUE_CHANNEL; gestureModel.StartGameObject = gameObject2; } } else { gestureModel.TouchDownStartArea = AreaTouchedEnum.PENGUIN_ROTATION_AREA; } } else { gestureModel.TouchDownStartArea = AreaTouchedEnum.PENGUIN_ROTATION_AREA; } } return(gestureModel); }
public DragTemplate(CustomizerGestureModel gestureModel) { GestureModel = gestureModel; }
public DragDecalButton(CustomizerGestureModel gestureModel) { GestureModel = gestureModel; }
public DragOffChannel(CustomizerGestureModel gestureModel) { GestureModel = gestureModel; }
public abstract void EnterState(CustomizerGestureModel currentGesture);
public override void EnterState(CustomizerGestureModel currentGesture) { previousTouchX = currentGesture.TouchDownStartPos.x; }
public override void EnterState(CustomizerGestureModel currentGesture) { equipmentId = currentGesture.ItemId; setupDragIcon(currentGesture); }