소스 검색

换装界面添加放大功能

guodong 1 년 전
부모
커밋
29b85b1a20

+ 10 - 3
GameClient/Assets/Editor/BuildEditor/PresetAssetHelper.cs

@@ -71,11 +71,18 @@ namespace GFGEditor
                     TryAdd(assetPath, manifest, bundles);
                     assetPath = ResPathUtil.GetDressUpLayerAnimationResPath(dressUpCfg, 3);
                     TryAdd(assetPath, manifest, bundles);
-                    assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 1);
+                    assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 1, false);
                     TryAdd(assetPath, manifest, bundles);
-                    assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 2);
+                    assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 2, false);
                     TryAdd(assetPath, manifest, bundles);
-                    assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 3);
+                    assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 3, false);
+                    TryAdd(assetPath, manifest, bundles);
+                    TryAdd(assetPath, manifest, bundles);
+                    assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 1, true);
+                    TryAdd(assetPath, manifest, bundles);
+                    assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 2, true);
+                    TryAdd(assetPath, manifest, bundles);
+                    assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 3, true);
                     TryAdd(assetPath, manifest, bundles);
                 }
             }

+ 10 - 4
GameClient/Assets/Game/HotUpdate/Assets/PreloadManager.cs

@@ -51,7 +51,7 @@ namespace GFGGame
                 {
                     string assetPath = ResPathUtil.GetDressUpAnimationPath(suitCfg.aniRes);
                     PreloadManager.Instance.TryAdd(assetPath);
-                    assetPath = ResPathUtil.GetDressUpEffectPath(suitCfg.aniRes);
+                    assetPath = ResPathUtil.GetDressUpEffectPath(suitCfg.aniRes, true);
                     PreloadManager.Instance.TryAdd(assetPath);
                 }
             }
@@ -69,6 +69,12 @@ namespace GFGGame
                 PreloadManager.Instance.TryAdd(assetPath);
                 assetPath = ResPathUtil.GetDressUpLayerSpriteResPath(dressUpCfg, 3);
                 PreloadManager.Instance.TryAdd(assetPath);
+                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 1, false);
+                PreloadManager.Instance.TryAdd(assetPath);
+                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 2, false);
+                PreloadManager.Instance.TryAdd(assetPath);
+                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 3, false);
+                PreloadManager.Instance.TryAdd(assetPath);
             }
             if (resType != ResType.Sprite)
             {
@@ -78,11 +84,11 @@ namespace GFGGame
                 PreloadManager.Instance.TryAdd(assetPath);
                 assetPath = ResPathUtil.GetDressUpLayerAnimationResPath(dressUpCfg, 3);
                 PreloadManager.Instance.TryAdd(assetPath);
-                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 1);
+                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 1, true);
                 PreloadManager.Instance.TryAdd(assetPath);
-                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 2);
+                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 2, true);
                 PreloadManager.Instance.TryAdd(assetPath);
-                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 3);
+                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 3, true);
                 PreloadManager.Instance.TryAdd(assetPath);
             }
         }

+ 2 - 2
GameClient/Assets/Game/HotUpdate/Controller/GMController.cs

@@ -62,10 +62,10 @@ namespace GFGGame
                 //LogUtil.LogDev("OnTouchBegin 2");
                 if (index == 0)
                 {
-                    Timers.inst.Add(1, 1, OnTimeComplete);
+                    Timers.inst.Add(0.5f, 1, OnTimeComplete);
                 }
                 index++;
-                if (index == 2)
+                if (index == 3)
                 {
                     ShowGmView();
                 }

+ 130 - 0
GameClient/Assets/Game/HotUpdate/Controller/ScaleGestureController.cs

@@ -0,0 +1,130 @@
+using FairyGUI;
+using GFGGame.Launcher;
+using UnityEngine;
+
+namespace GFGGame
+{
+    public class ScaleGestureController : SingletonMonoBase<ScaleGestureController>
+    {
+        public Transform target; //目标
+
+        //缩放
+        public bool isScaling;
+        Vector3 touch1, touch2, oriPos, scaleCenter;
+        float scale, disX, disY, oriScale;
+        public float scaleSpeed = 1;
+        public float min = 1f;
+        public float max = 1.7f;
+
+
+        //移动
+        private bool isDraging;
+        private Vector3 offset = Vector3.zero;
+        public Vector2 uiSize;
+
+        private void Update()
+        {
+            if (target == null)
+            {
+                isScaling = false;
+                isDraging = false;
+                return;
+            }
+            if(Input.touchCount != 2)
+            {
+                isScaling = false;
+            }
+            if (isScaling)
+            {
+                //两指缩放比例
+                scale = Vector3.Distance(Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position), Camera.main.ScreenToWorldPoint(Input.GetTouch(1).position)) / Vector3.Distance(touch1, touch2);
+
+                //利用scaleSpeed控制缩放速度
+                scale = (scale - 1) * scaleSpeed;
+                var targetScale = oriScale + scale;
+                //给缩放比例加限制
+                if (targetScale <= min && scale < 0)
+                {
+                    targetScale = min;
+                }
+                if (targetScale >= max && scale > 0)
+                {
+                    targetScale = max;
+                }
+
+                LogUtil.LogDev($"scaling {oriScale} {scale}");
+                //缩放目标大小
+                target.localScale = new Vector3(targetScale, targetScale, 1);
+                //改变目标位置,让位置保持不变
+                target.position = new Vector3(oriPos.x - ((target.localScale.x - oriScale) * disX), oriPos.y - ((target.localScale.y - oriScale) * disY), 0);
+                UpdatePos();
+            }
+            if (Input.touchCount == 2)
+            {
+                //两指点位
+                touch1 = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
+                touch2 = Camera.main.ScreenToWorldPoint(Input.GetTouch(1).position);
+
+                //目标初始点位
+                oriPos = new Vector3(target.position.x, target.position.y, 0);
+
+                //两指中点
+                scaleCenter = new Vector3((Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position).x + Camera.main.ScreenToWorldPoint(Input.GetTouch(1).position).x) / 2, (Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position).y + Camera.main.ScreenToWorldPoint(Input.GetTouch(1).position).y) / 2, 0);
+
+                //两指中点和目标距离
+                disX = scaleCenter.x - oriPos.x;
+                disY = scaleCenter.y - oriPos.y;
+                oriScale = target.localScale.x;
+                LogUtil.LogDev($"start scale {oriPos} {oriScale}");
+
+
+                isScaling = true;
+            }
+
+            if (!Input.GetMouseButton(0) || isScaling)
+            {
+                isDraging = false;
+                return;
+            }
+            if (isDraging)
+            {
+                target.position = Camera.main.ScreenToWorldPoint(Input.mousePosition - offset);
+                UpdatePos();
+            }
+            else if (Input.GetMouseButtonDown(0))
+            {
+                //LogUtil.LogEditor($"DragGestureController {GRoot.inst.touchTarget} {Input.touchCount}");
+                if (GRoot.inst.touchTarget != null && !(GRoot.inst.touchTarget is GGraph)) return;
+                isDraging = true;
+                offset = Input.mousePosition - Camera.main.WorldToScreenPoint(target.position);
+            }
+        }
+
+        public void UpdatePos()
+        {
+            if (target == null) return;
+            Vector2 size = target.Find("Bg").GetComponent<SpriteRenderer>().size * target.localScale.x;
+
+            float deviationWidth = (size.x - uiSize.x / 100) / 2;
+            float deviationHeigh = (size.y - uiSize.y / 100) / 2;
+            Vector2 pos = target.transform.position;
+            if (pos.x <= -deviationWidth)
+            {
+                target.transform.position = new Vector2(-deviationWidth, target.transform.position.y);
+            }
+            if (pos.x >= deviationWidth)
+            {
+                target.transform.position = new Vector2(deviationWidth, target.transform.position.y);
+            }
+            if (pos.y <= -deviationHeigh)
+            {
+                target.transform.position = new Vector2(target.transform.position.x, -deviationHeigh);
+            }
+            if (pos.y >= deviationHeigh)
+            {
+                target.transform.position = new Vector2(target.transform.position.x, deviationHeigh);
+            }
+        }
+
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Controller/ScaleGestureController.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7922930891b918d4bb98502a238e15b8
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 1
GameClient/Assets/Game/HotUpdate/DressUp/DressUpLayerOperation.cs

@@ -250,7 +250,7 @@ namespace GFGGame
             //LogUtil.LogEditor($"add UpdateLayer {itemCfg.id} layerId {layerId}");
             int sortingOrder = ItemTypeCfgArray.Instance.GetSortingOrder(itemCfg.subType, layerId);
             //清理旧的
-            var spritObjName = string.Format(DressUpUtil.FORMAT_SPRITE_NAME, itemCfg.id, layerId);
+            var spritObjName = DressUpUtil.GetSpriteName(itemCfg, layerId);
             DressUpUtil.TryRemoveSprite(parentObj, spritObjName);
             var aniObjName = string.Format(DressUpUtil.FORMAT_ANIMATION_NAME, itemCfg.id, layerId);
             DressUpUtil.TryRemoveObj(parentObj, aniObjName);

+ 13 - 4
GameClient/Assets/Game/HotUpdate/DressUp/DressUpUtil.cs

@@ -93,6 +93,15 @@ namespace GFGGame
             return null;
         }
 
+        public static string GetSpriteName(ItemCfg itemCfg, int layer)
+        {
+            if(itemCfg.subType == ConstDressUpItemType.BEI_JING)
+            {
+                return "Bg";
+            }
+            return string.Format(FORMAT_SPRITE_NAME, itemCfg.id, layer);
+        }
+
         public static void RemoveItem(int itemID, GameObject parentObj)
         {
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
@@ -102,7 +111,7 @@ namespace GFGGame
             //默认层
             if (!string.IsNullOrEmpty(itemCfg.resLayer1))
             {
-                spritObjName = string.Format(FORMAT_SPRITE_NAME, itemCfg.id, 1);
+                spritObjName = GetSpriteName(itemCfg, 1);
                 TryRemoveSprite(parentObj, spritObjName);
                 aniObjName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.id, 1);
                 TryRemoveObj(parentObj, aniObjName);
@@ -112,7 +121,7 @@ namespace GFGGame
             //特殊层
             if (!string.IsNullOrEmpty(itemCfg.resLayer2))
             {
-                spritObjName = string.Format(FORMAT_SPRITE_NAME, itemCfg.id, 2);
+                spritObjName = GetSpriteName(itemCfg, 2);
                 TryRemoveSprite(parentObj, spritObjName);
                 aniObjName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.id, 2);
                 TryRemoveObj(parentObj, aniObjName);
@@ -122,7 +131,7 @@ namespace GFGGame
             //第三层
             if (!string.IsNullOrEmpty(itemCfg.resLayer3))
             {
-                spritObjName = string.Format(FORMAT_SPRITE_NAME, itemCfg.id, 3);
+                spritObjName = GetSpriteName(itemCfg, 3);
                 TryRemoveSprite(parentObj, spritObjName);
                 aniObjName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.id, 3);
                 TryRemoveObj(parentObj, aniObjName);
@@ -256,7 +265,7 @@ namespace GFGGame
             }
 
             //特效
-            string effectResPath = ResPathUtil.GetDressUpLayerEffectResPath(itemCfg, layerId);
+            string effectResPath = ResPathUtil.GetDressUpLayerEffectResPath(itemCfg, layerId, showAni);
             if (!YooAssets.CheckResExist(effectResPath))
             {
                 effectResPath = null;

+ 3 - 3
GameClient/Assets/Game/HotUpdate/Utils/ResPathUtil.cs

@@ -187,17 +187,17 @@ namespace GFGGame
             return YooAssets.CheckResExist(resPath);
         }
 
-        public static string GetDressUpLayerEffectResPath(ItemCfg itemCfg, int layerId)
+        public static string GetDressUpLayerEffectResPath(ItemCfg itemCfg, int layerId, bool inAniDir)
         {
             string res = GetDressUpLayerResName(itemCfg, layerId);
-            return GetDressUpEffectPath(res);
+            return GetDressUpEffectPath(res, inAniDir);
         }
         public static string GetDressUpEffectDirPath(string res)
         {
             return $"{EFFECT_DIR_PATH}/DressUp/{res}";
         }
 
-        public static string GetDressUpEffectPath(string res, bool inAniDir = false, string extName = "prefab")
+        public static string GetDressUpEffectPath(string res, bool inAniDir, string extName = "prefab")
         {
             if (inAniDir)
             {

+ 4 - 1
GameClient/Assets/Game/HotUpdate/Views/DressUp/DressUpView.cs

@@ -179,7 +179,7 @@ namespace GFGGame
             {
                 _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneDressUp"));
             }
-            MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject);
+            MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, true, null, true, ScaleGestureController.Instance.UpdatePos);
 
             currentIndex = CustomSuitDataManager.currentIndex;
             _ui.m_comboBox.items = CustomSuitDataManager.GetSuitPosItems();
@@ -188,6 +188,8 @@ namespace GFGGame
             UpdateStepBtn(true);
 
             Timers.inst.AddUpdate(CheckGuide);
+            ScaleGestureController.Instance.target = _sceneObject.transform;
+            ScaleGestureController.Instance.uiSize = _ui.target.size;
         }
 
         protected override void OnHide()
@@ -207,6 +209,7 @@ namespace GFGGame
             _ui.m_c2.selectedIndex = 0;
             Reset();
             Timers.inst.Remove(CheckGuide);
+            ScaleGestureController.Instance.target = null;
         }
         protected override void RemoveEventListener()
         {

+ 2 - 2
GameClient/Assets/Game/Launcher/Version/VersionController.cs

@@ -140,7 +140,7 @@ namespace GFGGame
                     string totalSizeMB = sizeMB.ToString("f1");
                     if(string.IsNullOrEmpty(LauncherConfig.updateResPrompt))
                     {
-                        LauncherConfig.updateResPrompt = $"游戏有新的内容,需要更新{0}MB大小的资源";
+                        LauncherConfig.updateResPrompt = "游戏有新的内容,需要更新{0}MB大小的资源";
                     }
                     string message = string.Format(LauncherConfig.updateResPrompt, totalSizeMB);
                     Alert.Show(message)
@@ -194,7 +194,7 @@ namespace GFGGame
         /// </summary>
         private string GetHostServerURL(string packageName)
         {
-            //LauncherConfig.CDN_ROOT = "http://10.108.64.127";
+            LauncherConfig.CDN_ROOT = "http://10.108.64.127";
 
             string platform = "PC";
 #if UNITY_EDITOR