Exemplo n.º 1
0
 void OnClickSwatch(AnturaSpaceSwatchButton _bt)
 {
     SelectSwatch(_bt.Data);
 }
Exemplo n.º 2
0
        void SelectReward(RewardItem _rewardData)
        {
            showSwatchesTween.Rewind();
            bool isTextureOrDecal = currCategory == AnturaSpaceCategoryButton.AnturaSpaceCategory.Texture ||
                                    currCategory == AnturaSpaceCategoryButton.AnturaSpaceCategory.Decal;

            BTRemoveMods.gameObject.SetActive(!isTextureOrDecal && _rewardData != null);
            if (_rewardData == null)
            {
                foreach (AnturaSpaceItemButton item in btsItems)
                {
                    item.Toggle(false);
                }
                if (currCategory == AnturaSpaceCategoryButton.AnturaSpaceCategory.Ears)
                {
                    AnturaModelManager.Instance.ClearLoadedRewardInCategory("EAR_L");
                    AnturaModelManager.Instance.ClearLoadedRewardInCategory("EAR_R");
                }
                else
                {
                    AnturaModelManager.Instance.ClearLoadedRewardInCategory(currCategory.ToString());
                }
                return;
            }

            foreach (AnturaSpaceItemButton item in btsItems)
            {
                item.Toggle(item.Data == _rewardData);
            }
            currSwatchesDatas = RewardSystemManager.SelectRewardItem(_rewardData.ID, currRewardType);
            if (currSwatchesDatas.Count == 0)
            {
                Debug.Log("No color swatches for the selected reward!");
                return;
            }

            // Hide non-existent swatches
            for (int i = currSwatchesDatas.Count - 1; i < btsSwatches.Length; ++i)
            {
                btsSwatches[i].gameObject.SetActive(false);
            }
            // Setup and show swatches
            RewardColorItem selectedSwatchData = null;

            for (int i = 0; i < currSwatchesDatas.Count; ++i)
            {
                RewardColorItem         swatchData = currSwatchesDatas[i];
                AnturaSpaceSwatchButton swatch     = btsSwatches[i];
                swatch.gameObject.SetActive(true);
                swatch.Data = swatchData;
                if (swatchData != null)
                {
                    swatch.SetAsNew(swatchData.IsNew);
                    swatch.Toggle(swatchData.IsSelected);
                    swatch.SetColors(GenericUtilities.HexToColor(swatchData.Color1RGB), GenericUtilities.HexToColor(swatchData.Color2RGB));
                    if (swatchData.IsSelected)
                    {
                        selectedSwatchData = swatchData;
                    }
                }
                else
                {
                    swatch.Toggle(false);
                }
                swatch.Lock(swatchData == null);
            }

            SwatchesContainer.gameObject.SetActive(true);
            showSwatchesTween.PlayForward();

            // Select eventual color
            if (selectedSwatchData != null)
            {
                SelectSwatch(selectedSwatchData);
            }
        }