|
@@ -47,7 +47,7 @@ namespace GFGGame
|
|
|
private RotationGesture rotationGesture;
|
|
|
|
|
|
|
|
|
- private int maxLayer = int.MinValue;//最上层的层级数
|
|
|
+ // private int maxLayer = int.MinValue;//最上层的层级数
|
|
|
|
|
|
protected override void OnInit()
|
|
|
{
|
|
@@ -115,6 +115,10 @@ namespace GFGGame
|
|
|
UpdateBg(ItemCfgArray.Instance.GetCfg(EquipDataCache.cacher.bgId));
|
|
|
UpdateBody();
|
|
|
UpdateScene();
|
|
|
+ for (int i = 0; i < _itemGameObjs.Count; i++)
|
|
|
+ {
|
|
|
+ PhotographDataManager.Instance.SetLayer(_itemGameObjs[i], i * 100, "up");
|
|
|
+ }
|
|
|
if (GuideDataManager.GetGuideCountCopy(ConstGuideId.PHOTOGRAPH) > 0)
|
|
|
{
|
|
|
_ui.m_loaGuide.enabled = false;
|
|
@@ -188,7 +192,7 @@ namespace GFGGame
|
|
|
|
|
|
case EnumPhotographType.SCENE:
|
|
|
|
|
|
- AddSceneItem(itemCfg, false);
|
|
|
+ AddSceneItem(itemCfg, false, true);
|
|
|
break;
|
|
|
case EnumPhotographType.EFFECT:
|
|
|
|
|
@@ -222,9 +226,17 @@ namespace GFGGame
|
|
|
{
|
|
|
hitGameObj = hitGameObj.transform.parent.gameObject;
|
|
|
|
|
|
- PhotographDataManager.Instance.SetItemLayer(hitGameObj, maxLayer);
|
|
|
- maxLayer = PhotographDataManager.Instance.GetMaxLayer(hitGameObj, maxLayer) + 1;
|
|
|
_ui.m_comSelectBox.target.visible = true;
|
|
|
+
|
|
|
+ int index = _itemGameObjs.IndexOf(hitGameObj);
|
|
|
+ GameObject gameObject = _itemGameObjs[index];
|
|
|
+ _itemGameObjs.RemoveAt(index);
|
|
|
+ _itemGameObjs.Add(gameObject);
|
|
|
+ for (int i = 0; i < _itemGameObjs.Count; i++)
|
|
|
+ {
|
|
|
+ PhotographDataManager.Instance.SetLayer(_itemGameObjs[i], i * 100, "up");
|
|
|
+ }
|
|
|
+
|
|
|
if (!_equipDistance.ContainsKey(hitGameObj))
|
|
|
{
|
|
|
SceneController.SetGameObjectCenter(hitGameObj);
|
|
@@ -384,7 +396,6 @@ namespace GFGGame
|
|
|
gameObject.transform.localScale = new Vector3(value, value, 1);
|
|
|
Vector2 size = SceneController.GetGameObjectSize(gameObject);
|
|
|
_ui.m_comSelectBox.target.size = size;
|
|
|
- // _ui.m_comSelectBox.target.SetSize(size.x, size.y);
|
|
|
}
|
|
|
private void ControllerRotate(float value, GameObject gameObject)
|
|
|
{
|
|
@@ -407,9 +418,8 @@ namespace GFGGame
|
|
|
{
|
|
|
GameObject bodyParent = _sceneObject.transform.Find(RolePath).gameObject;
|
|
|
SceneController.UpdatePhotographBody(PhotographDataManager.Instance._equipRoleData.ToArray(), _sceneObject, bodyParent);
|
|
|
- _itemGameObjs.Add(bodyParent);
|
|
|
+ AddItemGameObject(bodyParent, false);
|
|
|
|
|
|
- maxLayer = PhotographDataManager.Instance.GetMaxLayer(bodyParent, maxLayer) + 1;
|
|
|
}
|
|
|
//添加初始场景道具
|
|
|
private void UpdateScene()
|
|
@@ -421,21 +431,20 @@ namespace GFGGame
|
|
|
{
|
|
|
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(key);
|
|
|
int defaultLayer = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).defaultLayer;
|
|
|
- AddSceneItem(itemCfg, true);
|
|
|
+ AddSceneItem(itemCfg, true, false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
private void UpdateNpc(ItemCfg itemCfg)
|
|
|
{
|
|
|
- maxLayer++;
|
|
|
Transform tf = _sceneObject.transform.Find(NpcResPath);
|
|
|
string resPath = ResPathUtil.GetNpcPicFPath(itemCfg.res);
|
|
|
SceneController.SetSpriteRendererToTransform(tf, resPath);
|
|
|
SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
|
|
|
- spr.sortingOrder = maxLayer;
|
|
|
+
|
|
|
tf.localPosition = new Vector2(-spr.bounds.center.x, -spr.bounds.center.y);
|
|
|
SceneController.SetBoxCollider2DToGameObject(tf.gameObject);
|
|
|
- _itemGameObjs.Add(tf.parent.gameObject);
|
|
|
+ AddItemGameObject(tf.parent.gameObject, true);
|
|
|
|
|
|
}
|
|
|
private void UpdateBorder(ItemCfg itemCfg)
|
|
@@ -452,7 +461,7 @@ namespace GFGGame
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void AddSceneItem(ItemCfg itemCfg, bool isDefaultLayer)
|
|
|
+ private void AddSceneItem(ItemCfg itemCfg, bool isDefaultLayer, bool setLayer)
|
|
|
{
|
|
|
int index = 0;
|
|
|
|
|
@@ -467,13 +476,7 @@ namespace GFGGame
|
|
|
parentGameObj = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.id, index, 1));
|
|
|
SceneController.AddItemToScene(_sceneObject, parentGameObj, itemCfg.id, 2, itemCfg.resLayer2);
|
|
|
|
|
|
- maxLayer = PhotographDataManager.Instance.GetMaxLayer(parentGameObj, maxLayer) + 1;
|
|
|
- _itemGameObjs.Add(parentGameObj);
|
|
|
-
|
|
|
- if (!isDefaultLayer)
|
|
|
- {
|
|
|
- PhotographDataManager.Instance.SetItemLayer(parentGameObj, maxLayer);
|
|
|
- }
|
|
|
+ AddItemGameObject(parentGameObj, setLayer);
|
|
|
|
|
|
}
|
|
|
if (itemCfg.resLayer1 > 0)
|
|
@@ -487,18 +490,37 @@ namespace GFGGame
|
|
|
parentGameObj = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.id, index, 0));
|
|
|
SceneController.AddItemToScene(_sceneObject, parentGameObj, itemCfg.id, 1, itemCfg.resLayer1);
|
|
|
|
|
|
- maxLayer = PhotographDataManager.Instance.GetMaxLayer(parentGameObj, maxLayer) + 1;
|
|
|
- _itemGameObjs.Add(parentGameObj);
|
|
|
-
|
|
|
- if (!isDefaultLayer)
|
|
|
- {
|
|
|
- PhotographDataManager.Instance.SetItemLayer(parentGameObj, maxLayer);
|
|
|
- }
|
|
|
+ AddItemGameObject(parentGameObj, setLayer);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void AddItemGameObject(GameObject parentGameObj, bool setLayer)
|
|
|
+ {
|
|
|
+ _itemGameObjs.Add(parentGameObj);
|
|
|
|
|
|
+ if (setLayer)
|
|
|
+ {
|
|
|
+ int index = _itemGameObjs.Count - 1;
|
|
|
+ PhotographDataManager.Instance.SetLayer(_itemGameObjs[index], index * 100, "up");
|
|
|
+ }
|
|
|
+ _itemGameObjs.Sort((GameObject a, GameObject b) =>
|
|
|
+ {
|
|
|
+
|
|
|
+ int layerA = PhotographDataManager.Instance.GetMinLayer(a);
|
|
|
+ int layerB = PhotographDataManager.Instance.GetMinLayer(b);
|
|
|
+ if (layerA < layerB)
|
|
|
+ {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ else if (layerA > layerB)
|
|
|
+ {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -575,10 +597,45 @@ namespace GFGGame
|
|
|
private void OnClickBtnUp()
|
|
|
{
|
|
|
|
|
|
+ int index = _itemGameObjs.IndexOf(memoryHitGameObj);
|
|
|
+ if (index < 0)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("未选中任物品");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (index == _itemGameObjs.Count - 1)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("已经在最上层了");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ GameObject gameObject = _itemGameObjs[index];
|
|
|
+ _itemGameObjs.RemoveAt(index);
|
|
|
+ _itemGameObjs.Insert((index + 1), gameObject);
|
|
|
+ PhotographDataManager.Instance.SetLayer(memoryHitGameObj, (index + 1) * 100, "up");
|
|
|
+ PhotographDataManager.Instance.SetLayer(_itemGameObjs[index], index * 100, "down");
|
|
|
}
|
|
|
private void OnClickBtnDown()
|
|
|
{
|
|
|
|
|
|
+ int index = _itemGameObjs.IndexOf(memoryHitGameObj);
|
|
|
+ if (index < 0)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("未选中任物品");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (index == 0)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("已经在最下层了");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ GameObject gameObject = _itemGameObjs[index];
|
|
|
+ _itemGameObjs.RemoveAt(index);
|
|
|
+ _itemGameObjs.Insert((index - 1), gameObject);
|
|
|
+ PhotographDataManager.Instance.SetLayer(memoryHitGameObj, (index - 1) * 100, "down");
|
|
|
+ PhotographDataManager.Instance.SetLayer(_itemGameObjs[index], index * 100, "up");
|
|
|
+
|
|
|
}
|
|
|
private void OnClickBtnPhotograph()
|
|
|
{
|