|
@@ -1,5 +1,7 @@
|
|
using FairyGUI;
|
|
using FairyGUI;
|
|
using System;
|
|
using System;
|
|
|
|
+using System.Collections;
|
|
|
|
+using System.Collections.Generic;
|
|
using UI.DressUp;
|
|
using UI.DressUp;
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.EventSystems;
|
|
@@ -13,6 +15,10 @@ namespace GFGGame
|
|
private GameObject _sceneObject;
|
|
private GameObject _sceneObject;
|
|
private DressUpObjDataCache equipDataCache;
|
|
private DressUpObjDataCache equipDataCache;
|
|
|
|
|
|
|
|
+ private List<int> _listData = null;//当前选择的资源数据
|
|
|
|
+ private List<int> equipRoleData = new List<int>();//当前穿戴的角色数据
|
|
|
|
+ // private List<int> equipSceneData = new List<int>();
|
|
|
|
+ private Dictionary<int, List<int>> equipSceneData = new Dictionary<int, List<int>>();//当前穿戴的场景数据
|
|
protected override void OnInit()
|
|
protected override void OnInit()
|
|
{
|
|
{
|
|
base.OnInit();
|
|
base.OnInit();
|
|
@@ -22,6 +28,11 @@ namespace GFGGame
|
|
isfullScreen = true;
|
|
isfullScreen = true;
|
|
|
|
|
|
_ui.m_btnBack.onClick.Add(OnClickBtnBack);
|
|
_ui.m_btnBack.onClick.Add(OnClickBtnBack);
|
|
|
|
+
|
|
|
|
+ _ui.m_ComSelect.m_list.itemRenderer = RenderListItem;
|
|
|
|
+ _ui.m_ComSelect.m_list.onClickItem.Add(OnListItemClick);
|
|
|
|
+ _ui.m_ComSelect.m_c1.onChanged.Add(OnContorllerChanged);
|
|
|
|
+
|
|
_scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("ScenePhotograph"));
|
|
_scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("ScenePhotograph"));
|
|
|
|
|
|
}
|
|
}
|
|
@@ -29,24 +40,93 @@ namespace GFGGame
|
|
protected override void OnShown()
|
|
protected override void OnShown()
|
|
{
|
|
{
|
|
base.OnShown();
|
|
base.OnShown();
|
|
- // Debug.Log("Length:" + EquipDataCache.cacher.equipDatas.Length);
|
|
|
|
- // Debug.Log("bgId:" + EquipDataCache.cacher.bgId);
|
|
|
|
- // Debug.Log("suitId:" + EquipDataCache.cacher.suitId);
|
|
|
|
|
|
+
|
|
|
|
|
|
if (_sceneObject == null)
|
|
if (_sceneObject == null)
|
|
{
|
|
{
|
|
_sceneObject = GameObject.Instantiate(_scenePrefab);
|
|
_sceneObject = GameObject.Instantiate(_scenePrefab);
|
|
- // _sceneObject.sortingOrder = 1000;
|
|
|
|
EquipDataCache.cacher.setSceneObj(_sceneObject);
|
|
EquipDataCache.cacher.setSceneObj(_sceneObject);
|
|
}
|
|
}
|
|
|
|
|
|
equipDataCache = EquipDataCache.cacher;
|
|
equipDataCache = EquipDataCache.cacher;
|
|
- UpdateBg();
|
|
|
|
|
|
+
|
|
|
|
+ _ui.m_ComSelect.m_c1.selectedIndex = 0;
|
|
|
|
+ RefreshList(EnumPhotographType.BG);
|
|
|
|
+ UpdateEquipData();
|
|
|
|
+
|
|
|
|
+ UpdateBgOrNpcOrBorder(EnumPhotographType.BG, equipDataCache.bgId);
|
|
UpdateBody();
|
|
UpdateBody();
|
|
|
|
+ UpdateScene();
|
|
|
|
+ Timers.inst.Add(0.001f, 0, OnTimerListener);
|
|
|
|
+ }
|
|
|
|
+ /************************************************************UI界面*********************************************************/
|
|
|
|
+ private void OnContorllerChanged(EventContext context)
|
|
|
|
+ {
|
|
|
|
+ int index = _ui.m_ComSelect.m_c1.selectedIndex;
|
|
|
|
+ RefreshList((EnumPhotographType)index);
|
|
|
|
+ }
|
|
|
|
+ private void RefreshList(EnumPhotographType index)
|
|
|
|
+ {
|
|
|
|
+ _ui.m_ComSelect.m_list.numItems = 0;
|
|
|
|
+
|
|
|
|
+ switch (index)
|
|
|
|
+ {
|
|
|
|
+ case EnumPhotographType.BG:
|
|
|
|
+ _listData = PhotographDataManager.Instance.listBgData;
|
|
|
|
+ break;
|
|
|
|
+ case EnumPhotographType.NPC:
|
|
|
|
+ _listData = PhotographDataManager.Instance.listNpcData;
|
|
|
|
+ break;
|
|
|
|
+ case EnumPhotographType.SCENE:
|
|
|
|
+ _listData = PhotographDataManager.Instance.listSceneData;
|
|
|
|
+ break;
|
|
|
|
+ case EnumPhotographType.BORDER:
|
|
|
|
+ _listData = PhotographDataManager.Instance.listBorderData;
|
|
|
|
+ break;
|
|
|
|
+ case EnumPhotographType.EFFECT:
|
|
|
|
+ _listData = PhotographDataManager.Instance.listEffectData;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ _ui.m_ComSelect.m_list.numItems = _listData.Count;
|
|
|
|
+ }
|
|
|
|
+ private void RenderListItem(int index, GObject obj)
|
|
|
|
+ {
|
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_listData[index]);
|
|
|
|
+ string resPath = ResPathUtil.GetPhotographFPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType));
|
|
|
|
+
|
|
|
|
+ UI_ListItem item = UI_ListItem.Proxy(obj);
|
|
|
|
+ item.target.data = _listData[index];
|
|
|
|
+ item.m_loaIcon.url = resPath;
|
|
|
|
+ }
|
|
|
|
+ private void OnListItemClick(EventContext context)
|
|
|
|
+ {
|
|
|
|
+ int itemID = (int)((context.data as GObject).data);
|
|
|
|
+ EnumPhotographType type = (EnumPhotographType)_ui.m_ComSelect.m_c1.selectedIndex;
|
|
|
|
+ switch (type)
|
|
|
|
+ {
|
|
|
|
+ case EnumPhotographType.BG:
|
|
|
|
+ case EnumPhotographType.BORDER:
|
|
|
|
+ case EnumPhotographType.NPC:
|
|
|
|
+ UpdateBgOrNpcOrBorder(type, itemID);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case EnumPhotographType.SCENE:
|
|
|
|
+ if (!equipSceneData.ContainsKey(itemID))
|
|
|
|
+ {
|
|
|
|
+ equipSceneData.Add(itemID, new List<int>());
|
|
|
|
+ }
|
|
|
|
+ equipSceneData[itemID].Add(itemID);
|
|
|
|
+ AddScene(itemID, equipSceneData[itemID].Count - 1);
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ case EnumPhotographType.EFFECT:
|
|
|
|
|
|
- Timers.inst.Add(0.001f, 0, OnClickListener);
|
|
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- private void OnClickListener(object param)
|
|
|
|
|
|
+ /************************************************************场景*********************************************************/
|
|
|
|
+
|
|
|
|
+ private void OnTimerListener(object param)
|
|
{
|
|
{
|
|
// Debug.Log("点击鼠标:" + Input.GetMouseButtonDown(0));
|
|
// Debug.Log("点击鼠标:" + Input.GetMouseButtonDown(0));
|
|
if (Input.GetMouseButtonDown(0))
|
|
if (Input.GetMouseButtonDown(0))
|
|
@@ -62,7 +142,6 @@ namespace GFGGame
|
|
//从摄像机发出到点击坐标的射线
|
|
//从摄像机发出到点击坐标的射线
|
|
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
|
|
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
|
|
Vector2 pos = Input.mousePosition;
|
|
Vector2 pos = Input.mousePosition;
|
|
- // Debug.Log("pos:" + pos);
|
|
|
|
|
|
|
|
if (hit.collider != null)
|
|
if (hit.collider != null)
|
|
{
|
|
{
|
|
@@ -77,57 +156,82 @@ namespace GFGGame
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ Debug.Log("触摸屏幕的手指个数:" + Input.touchCount);
|
|
|
|
+
|
|
|
|
+ if (Input.touchCount <= 0) { return; }
|
|
|
|
+ // for (var touch : Touch in Input.touches)
|
|
|
|
+ // {
|
|
|
|
+ if (Input.GetTouch(0).phase == TouchPhase.Began)
|
|
|
|
+ {
|
|
|
|
+ Debug.Log("触摸:" + "Began");
|
|
|
|
+ }
|
|
|
|
+ if (Input.GetTouch(0).phase == TouchPhase.Moved)
|
|
|
|
+ {
|
|
|
|
+ Debug.Log("触摸:" + "Moved");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (Input.GetTouch(0).phase == TouchPhase.Stationary)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ Debug.Log("触摸:" + "Stationary");
|
|
|
|
+ }
|
|
|
|
+ if (Input.GetTouch(0).phase == TouchPhase.Ended)
|
|
|
|
+ {
|
|
|
|
+ Debug.Log("触摸:" + "Ended");
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
//背景
|
|
//背景
|
|
- private void UpdateBg()
|
|
|
|
|
|
+ private void UpdateBgOrNpcOrBorder(EnumPhotographType type, int itemId)
|
|
{
|
|
{
|
|
- Transform tf = _sceneObject.transform.Find("Bg");
|
|
|
|
- SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
|
|
|
|
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(equipDataCache.bgId);
|
|
|
|
- var resPath = ResPathUtil.GetDressUpPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType));
|
|
|
|
- Sprite sp = GFGAsset.Load<Sprite>(resPath);
|
|
|
|
- DressUpUtil.AddAssetReleaser(tf.gameObject, resPath);
|
|
|
|
- spr.sprite = sp;
|
|
|
|
|
|
|
|
- int[] bgId = { equipDataCache.bgId };
|
|
|
|
- GameObject obj = _sceneObject.transform.Find("Bg").gameObject;
|
|
|
|
- SceneController.UpdateRole(bgId, _sceneObject, false, null, false, obj);
|
|
|
|
- SetObjSize(obj.transform.GetChild(0).gameObject);
|
|
|
|
- }
|
|
|
|
- private void SetObjSize(GameObject obj)
|
|
|
|
- {
|
|
|
|
- obj.AddComponent<BoxCollider2D>();
|
|
|
|
|
|
+ SceneController.UpdatePhotographBgOrNpcOrBorder(_sceneObject, type, itemId);
|
|
}
|
|
}
|
|
|
|
+
|
|
//主角
|
|
//主角
|
|
private void UpdateBody()
|
|
private void UpdateBody()
|
|
{
|
|
{
|
|
|
|
|
|
- // CustomSuitData suitSavedData = CustomSuitDataManager.GetCurrentSuitList();
|
|
|
|
- int[] equipDatas = equipDataCache.equipDatas;
|
|
|
|
- SceneController.UpdateRole(equipDatas, _sceneObject, false, null, false);
|
|
|
|
|
|
+ // int[] equipDatas = equipDataCache.equipDatas;
|
|
|
|
+ SceneController.UpdateRole(equipRoleData.ToArray(), _sceneObject, false, null, false);
|
|
if (equipDataCache.IsSuitPic && equipDataCache.suitId > 0)
|
|
if (equipDataCache.IsSuitPic && equipDataCache.suitId > 0)
|
|
{
|
|
{
|
|
SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(equipDataCache.suitId);
|
|
SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(equipDataCache.suitId);
|
|
DressUpUtil.UpdateBody(suitCfg.picRes, _sceneObject);
|
|
DressUpUtil.UpdateBody(suitCfg.picRes, _sceneObject);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ GameObject gameObject = _sceneObject.transform.Find("Role/Body").gameObject;
|
|
|
|
|
|
- //合照NPC
|
|
|
|
- private void UpdateNpc()
|
|
|
|
- {
|
|
|
|
|
|
+ SceneController.PhotographAddCollider(gameObject);
|
|
|
|
|
|
}
|
|
}
|
|
//场景道具
|
|
//场景道具
|
|
private void UpdateScene()
|
|
private void UpdateScene()
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ ICollection keys = equipSceneData.Keys;
|
|
|
|
+ foreach (int key in keys)
|
|
|
|
+ {
|
|
|
|
+ for (int i = 0; i < equipSceneData[key].Count; i++)
|
|
|
|
+ {
|
|
|
|
+ AddScene(key, i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- //边框
|
|
|
|
- private void UpdateBorder()
|
|
|
|
- {
|
|
|
|
|
|
|
|
|
|
+ //场景添加道具
|
|
|
|
+ private void AddScene(int itemId, int index)
|
|
|
|
+ {
|
|
|
|
+ var gameObj = new GameObject(string.Format("{0}_{1}", itemId, index));
|
|
|
|
+ gameObj.transform.SetParent(_sceneObject.transform.Find("Scene"), false);
|
|
|
|
+ // SceneController.UpdateRole(itemId, _sceneObject, false, null, false, gameObj);
|
|
|
|
+ DressUpUtil.AddItem(itemId, _sceneObject, false, false, gameObj);
|
|
|
|
+ for (int i = 0; i < gameObj.transform.childCount; i++)
|
|
|
|
+ {
|
|
|
|
+ SceneController.PhotographAddCollider(gameObj.transform.GetChild(i).gameObject);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
//滤镜效果
|
|
//滤镜效果
|
|
private void UpdateEffect()
|
|
private void UpdateEffect()
|
|
{
|
|
{
|
|
@@ -136,6 +240,27 @@ namespace GFGGame
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ private void UpdateEquipData()
|
|
|
|
+ {
|
|
|
|
+ for (int i = 0; i < equipDataCache.equipDatas.Length; i++)
|
|
|
|
+ {
|
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(equipDataCache.equipDatas[i]);
|
|
|
|
+ if (itemCfg.subType == ConstDressUpItemType.QIAN_JING || itemCfg.subType == ConstDressUpItemType.BEI_SHI || itemCfg.subType == ConstDressUpItemType.HUAN_JING)
|
|
|
|
+ {
|
|
|
|
+ if (!equipSceneData.ContainsKey(itemCfg.id))
|
|
|
|
+ {
|
|
|
|
+ equipSceneData.Add(itemCfg.id, new List<int>());
|
|
|
|
+ }
|
|
|
|
+ equipSceneData[itemCfg.id].Add(itemCfg.id);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ equipRoleData.Add(equipDataCache.equipDatas[i]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
private void OnClickBtnBack()
|
|
private void OnClickBtnBack()
|
|
{
|
|
{
|
|
this.Hide();
|
|
this.Hide();
|