|
@@ -25,10 +25,12 @@ namespace GFGGame
|
|
|
private const string RolePath = "Scene/Role";
|
|
|
private const string RoleName = "Role";
|
|
|
private const string NpcPath = "Scene/Npc";
|
|
|
+ private const string NpcName = "Npc";
|
|
|
private const string BgResName = "BgRes";
|
|
|
|
|
|
private List<int> _listData = null;//当前选择的资源数据
|
|
|
- private List<GameObject> _itemGameObjs = new List<GameObject>();
|
|
|
+ private List<GameObject> _itemGameObjs;// = new List<GameObject>();
|
|
|
+
|
|
|
public Dictionary<int, List<int>> _equipSceneData = new Dictionary<int, List<int>>();//当前穿戴的场景数据
|
|
|
private Dictionary<GameObject, float> _equipDistance = new Dictionary<GameObject, float>();
|
|
|
|
|
@@ -82,7 +84,7 @@ namespace GFGGame
|
|
|
_ui.m_comSelectBox.m_btnFlip.onTouchEnd.Add(OnTouchBtnFlipEnd);
|
|
|
|
|
|
_ui.m_comSelectBox.m_btnDelete.onTouchBegin.Add(OnTouchBtnDeleteBegin);
|
|
|
- _ui.m_comSelectBox.m_btnDelete.onTouchEnd.Add(OnTouchBtnDeleteEnd);
|
|
|
+
|
|
|
|
|
|
_ui.m_btnUp.onClick.Add(OnClickBtnUp);
|
|
|
_ui.m_btnDown.onClick.Add(OnClickBtnDown);
|
|
@@ -97,11 +99,13 @@ namespace GFGGame
|
|
|
PhotographDataManager.Instance.ClassifyEquipData();
|
|
|
_equipSceneData = PhotographDataManager.Instance._equipSceneData;
|
|
|
|
|
|
- _itemGameObjs.Clear();
|
|
|
+ PhotographDataManager.Instance.itemGameObjs.Clear();
|
|
|
+ _itemGameObjs = PhotographDataManager.Instance.itemGameObjs;
|
|
|
if (_sceneObject == null)
|
|
|
{
|
|
|
_sceneObject = GameObject.Instantiate(_scenePrefab);
|
|
|
EquipDataCache.cacher.setSceneObj(_sceneObject);
|
|
|
+ PhotographSceneManager.Instance.sceneObject = _sceneObject;
|
|
|
}
|
|
|
pinchGesture = new PinchGesture(_ui.target);
|
|
|
pinchGesture.onAction.Add(OnPinch);
|
|
@@ -112,13 +116,18 @@ namespace GFGGame
|
|
|
|
|
|
RefreshList(EnumPhotographType.BG);
|
|
|
SetUIView();
|
|
|
- UpdateBg(ItemCfgArray.Instance.GetCfg(EquipDataCache.cacher.bgId));
|
|
|
- UpdateBody();
|
|
|
+ // UpdateBg(ItemCfgArray.Instance.GetCfg(EquipDataCache.cacher.bgId));
|
|
|
+ PhotographSceneManager.Instance.AddBgItem(ItemCfgArray.Instance.GetCfg(EquipDataCache.cacher.bgId));
|
|
|
+
|
|
|
+ // UpdateBody();
|
|
|
+ PhotographSceneManager.Instance.AddBodyItem();
|
|
|
UpdateScene();
|
|
|
- for (int i = 0; i < _itemGameObjs.Count; i++)
|
|
|
- {
|
|
|
- PhotographDataManager.Instance.SetLayer(_itemGameObjs[i], i * 100, "up");
|
|
|
- }
|
|
|
+ // for (int i = 0; i < _itemGameObjs.Count; i++)
|
|
|
+ // {
|
|
|
+ // PhotographDataManager.Instance.ChangeLayer(_itemGameObjs[i], i * 100, "up");
|
|
|
+ // }
|
|
|
+ PhotographDataManager.Instance.SetLayer(null, "refresh");
|
|
|
+
|
|
|
if (GuideDataManager.GetGuideCountCopy(ConstGuideId.PHOTOGRAPH) > 0)
|
|
|
{
|
|
|
_ui.m_loaGuide.enabled = false;
|
|
@@ -168,30 +177,21 @@ namespace GFGGame
|
|
|
switch (type)
|
|
|
{
|
|
|
case EnumPhotographType.BG:
|
|
|
- UpdateBg(itemCfg);
|
|
|
+
|
|
|
+ PhotographSceneManager.Instance.AddBgItem(itemCfg);
|
|
|
break;
|
|
|
|
|
|
case EnumPhotographType.BORDER:
|
|
|
- if (_listData.IndexOf(itemID) == 0)
|
|
|
- {
|
|
|
- Transform tf = _sceneObject.transform.Find(BorderResPath);
|
|
|
- SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
|
|
|
- if (spr != null)
|
|
|
- {
|
|
|
- GameObject.Destroy(spr);
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- UpdateBorder(itemCfg);
|
|
|
+
|
|
|
+ PhotographSceneManager.Instance.AddBorderItem(itemCfg);
|
|
|
break;
|
|
|
|
|
|
case EnumPhotographType.NPC:
|
|
|
|
|
|
- UpdateNpc(itemCfg);
|
|
|
+ PhotographSceneManager.Instance.AddNpcItem(itemCfg);
|
|
|
break;
|
|
|
|
|
|
case EnumPhotographType.SCENE:
|
|
|
-
|
|
|
AddSceneItem(itemCfg, false, true);
|
|
|
break;
|
|
|
case EnumPhotographType.EFFECT:
|
|
@@ -199,6 +199,33 @@ namespace GFGGame
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ //添加初始场景道具
|
|
|
+ private void UpdateScene()
|
|
|
+ {
|
|
|
+ ICollection keys = _equipSceneData.Keys;
|
|
|
+ foreach (int key in keys)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < _equipSceneData[key].Count; i++)
|
|
|
+ {
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(key);
|
|
|
+
|
|
|
+ AddSceneItem(itemCfg, true, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void AddSceneItem(ItemCfg itemCfg, bool isDefaultLayer, bool setLayer)
|
|
|
+ {
|
|
|
+ if (itemCfg.resLayer2 > 0)
|
|
|
+ {
|
|
|
+ PhotographSceneManager.Instance.AddSceneItem(itemCfg, itemCfg.resLayer2, setLayer);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (itemCfg.resLayer1 > 0)
|
|
|
+ {
|
|
|
+ PhotographSceneManager.Instance.AddSceneItem(itemCfg, itemCfg.resLayer1, setLayer);
|
|
|
+ }
|
|
|
+ }
|
|
|
/************************************************************场景*********************************************************/
|
|
|
|
|
|
private void OnTouchUIBegin(EventContext context)
|
|
@@ -228,14 +255,7 @@ namespace GFGGame
|
|
|
|
|
|
_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");
|
|
|
- }
|
|
|
+ PhotographDataManager.Instance.SetLayer(hitGameObj, "top");
|
|
|
|
|
|
if (!_equipDistance.ContainsKey(hitGameObj))
|
|
|
{
|
|
@@ -263,13 +283,14 @@ namespace GFGGame
|
|
|
rotation = hitGameObj.transform.localEulerAngles.z;
|
|
|
}
|
|
|
}
|
|
|
- _ui.m_comSelectBox.target.rotation = rotation;// localEulerAngles.y != 0 ? hitGameObj.transform.localEulerAngles.z : -hitGameObj.transform.localEulerAngles.z;
|
|
|
+ _ui.m_comSelectBox.target.rotation = rotation;
|
|
|
Debug.Log("rotation:" + _ui.m_comSelectBox.target.rotation + " " + _ui.m_comSelectBox.target.rotationX + " " + _ui.m_comSelectBox.target.rotationY);
|
|
|
_ui.m_comSelectBox.target.size = SceneController.GetGameObjectSize(hitGameObj);
|
|
|
ControllerSelectBoxPos();
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
private void OnTouchUIMove(EventContext context)
|
|
|
{
|
|
|
if (hitGameObj == null) return;//未选中任何物体
|
|
@@ -282,7 +303,6 @@ namespace GFGGame
|
|
|
}
|
|
|
private void OnTouchUIEnd(EventContext context)
|
|
|
{
|
|
|
- // if (Stage.inst.touchCount > 1 || context.inputEvent.touchId != 0) return; //只监听1根手指
|
|
|
hitGameObj = null;
|
|
|
}
|
|
|
|
|
@@ -404,132 +424,9 @@ namespace GFGGame
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void UpdateBg(ItemCfg itemCfg)
|
|
|
- {
|
|
|
- Transform tf = _sceneObject.transform.Find(BgResPath);
|
|
|
- string resPath = ResPathUtil.GetDressUpPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType));
|
|
|
- SceneController.SetSpriteRendererToTransform(tf, resPath);
|
|
|
- SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
|
|
|
- spr.sortingOrder = ItemTypeCfgArray.Instance.GetCfg(ConstDressUpItemType.BEI_JING).defaultLayer;
|
|
|
- SceneController.SetBoxCollider2DToGameObject(tf.gameObject);
|
|
|
- }
|
|
|
- //主角
|
|
|
- private void UpdateBody()
|
|
|
- {
|
|
|
- GameObject bodyParent = _sceneObject.transform.Find(RolePath).gameObject;
|
|
|
- SceneController.UpdatePhotographBody(PhotographDataManager.Instance._equipRoleData.ToArray(), _sceneObject, bodyParent);
|
|
|
- AddItemGameObject(bodyParent, false);
|
|
|
-
|
|
|
- }
|
|
|
- //添加初始场景道具
|
|
|
- private void UpdateScene()
|
|
|
- {
|
|
|
- ICollection keys = _equipSceneData.Keys;
|
|
|
- foreach (int key in keys)
|
|
|
- {
|
|
|
- for (int i = 0; i < _equipSceneData[key].Count; i++)
|
|
|
- {
|
|
|
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(key);
|
|
|
- int defaultLayer = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).defaultLayer;
|
|
|
- AddSceneItem(itemCfg, true, false);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- private void UpdateNpc(ItemCfg itemCfg)
|
|
|
- {
|
|
|
- Transform tf = _sceneObject.transform.Find(NpcResPath);
|
|
|
- string resPath = ResPathUtil.GetNpcPicFPath(itemCfg.res);
|
|
|
- SceneController.SetSpriteRendererToTransform(tf, resPath);
|
|
|
- SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
|
|
|
-
|
|
|
- tf.localPosition = new Vector2(-spr.bounds.center.x, -spr.bounds.center.y);
|
|
|
- SceneController.SetBoxCollider2DToGameObject(tf.gameObject);
|
|
|
- AddItemGameObject(tf.parent.gameObject, true);
|
|
|
-
|
|
|
- }
|
|
|
- private void UpdateBorder(ItemCfg itemCfg)
|
|
|
- {
|
|
|
- Transform tf = _sceneObject.transform.Find(BorderResPath);
|
|
|
- string resPath = ResPathUtil.GetPhotographFPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType));
|
|
|
- SceneController.SetSpriteRendererToTransform(tf, resPath);
|
|
|
- SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
|
|
|
- spr.sortingOrder = 10000;//边框在所有道具的上边
|
|
|
- }
|
|
|
- private void UpdateEffect()
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void AddSceneItem(ItemCfg itemCfg, bool isDefaultLayer, bool setLayer)
|
|
|
- {
|
|
|
- int index = 0;
|
|
|
-
|
|
|
- GameObject parentGameObj;
|
|
|
- if (itemCfg.resLayer2 > 0)
|
|
|
- {
|
|
|
- if (!isDefaultLayer)
|
|
|
- {
|
|
|
- PhotographDataManager.Instance.AddEquipItem(_equipSceneData, itemCfg.id, out _equipSceneData);
|
|
|
- }
|
|
|
- index = _equipSceneData[itemCfg.id].Count - 1;
|
|
|
- parentGameObj = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.id, index, 1));
|
|
|
- SceneController.AddItemToScene(_sceneObject, parentGameObj, itemCfg.id, 2, itemCfg.resLayer2);
|
|
|
-
|
|
|
- AddItemGameObject(parentGameObj, setLayer);
|
|
|
-
|
|
|
- }
|
|
|
- if (itemCfg.resLayer1 > 0)
|
|
|
- {
|
|
|
- if (!isDefaultLayer)
|
|
|
- {
|
|
|
- PhotographDataManager.Instance.AddEquipItem(_equipSceneData, itemCfg.id, out _equipSceneData);
|
|
|
- }
|
|
|
- index = _equipSceneData[itemCfg.id].Count - 1;
|
|
|
-
|
|
|
- parentGameObj = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.id, index, 0));
|
|
|
- SceneController.AddItemToScene(_sceneObject, parentGameObj, itemCfg.id, 1, itemCfg.resLayer1);
|
|
|
-
|
|
|
- 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;
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
private void OnClickBtnBg()
|
|
|
{
|
|
|
_ui.m_ComSelectRes.target.visible = false;
|
|
|
- // GuideController.TryGuideOpenPhotographView(null);
|
|
|
-
|
|
|
}
|
|
|
private void OnClickLoaGuide()
|
|
|
{
|
|
@@ -566,7 +463,7 @@ namespace GFGGame
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- else if (memoryHitGameObj.transform.name == NpcPath)
|
|
|
+ else if (memoryHitGameObj.transform.name == NpcName)
|
|
|
{
|
|
|
SpriteRenderer spriteRenderer = memoryHitGameObj.transform.GetChild(0).GetComponent<SpriteRenderer>();
|
|
|
if (spriteRenderer != null)
|
|
@@ -580,12 +477,8 @@ namespace GFGGame
|
|
|
}
|
|
|
_itemGameObjs.Remove(memoryHitGameObj);
|
|
|
_ui.m_comSelectBox.target.visible = false;
|
|
|
-
|
|
|
}
|
|
|
- private void OnTouchBtnDeleteEnd()
|
|
|
- {
|
|
|
|
|
|
- }
|
|
|
private void SetUIView()
|
|
|
{
|
|
|
_ui.m_ComSelectRes.target.visible = true;
|
|
@@ -597,46 +490,15 @@ 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");
|
|
|
+ PhotographDataManager.Instance.SetLayer(memoryHitGameObj, "up");
|
|
|
}
|
|
|
private void OnClickBtnDown()
|
|
|
{
|
|
|
+ PhotographDataManager.Instance.SetLayer(memoryHitGameObj, "down");
|
|
|
+ }
|
|
|
|
|
|
- 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()
|
|
|
{
|
|
|
_ui.target.visible = false;
|