private void onObjectAdded(RectTransform item, int index)
        {
            TemplateIcon      component         = item.GetComponent <TemplateIcon>();
            DisplayedTemplate displayedTemplate = displayedTemplates[index];

            component.gameObject.name = displayedTemplate.Definition.AssetName + "_button";
            RectTransform rectTransform = component.transform as RectTransform;

            rectTransform.anchoredPosition = Vector2.zero;
            rectTransform.anchorMin        = Vector2.zero;
            rectTransform.anchorMax        = Vector2.one;
            rectTransform.sizeDelta        = Vector2.zero;
            rectTransform.localScale       = Vector3.one;
            bool flag    = Service.Get <CPDataEntityCollection>().IsLocalPlayerMember();
            bool canDrag = flag;

            if (!flag)
            {
                canDrag = !displayedTemplate.Definition.IsMemberOnlyCreatable;
            }
            string assetName = displayedTemplate.Definition.AssetName;
            Texture2DContentKey equipmentIconPath = EquipmentPathUtil.GetEquipmentIconPath(assetName);

            component.Init(equipmentIconPath, BreadcrumbType, displayedTemplate.Definition.Id, canDrag);
            if (!flag && displayedTemplate.Definition.IsMemberOnlyCreatable)
            {
                component.SetTemplateMemberLocked(displayedTemplate.Definition);
            }
            else if (userLevel < displayedTemplate.Level)
            {
                component.SetTemplateToLevelLocked(displayedTemplate.Definition, displayedTemplate.Level);
            }
            else if (!string.IsNullOrEmpty(displayedTemplate.MascotName))
            {
                component.SetTemplateToProgressionLocked(displayedTemplate.Definition, displayedTemplate.MascotName);
            }
            else
            {
                component.SetTemplateToUnlocked(displayedTemplate.Definition);
            }
            AccessibilitySettings component2 = component.GetComponent <AccessibilitySettings>();

            if (component2 != null)
            {
                component2.CustomToken = displayedTemplate.Definition.Name;
            }
        }
Ejemplo n.º 2
0
 private void Awake()
 {
     templateIcon = GetComponent <TemplateIcon>();
 }
Ejemplo n.º 3
0
        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);
        }