Commit 8b802181 authored by Ever's avatar Ever

同步代码

parent 62f7b293
......@@ -52,7 +52,7 @@ public class GameEditor
{
FunDo(l, rd.png, rd.json.roomDatas[i]);
}
rd.json.All = l.ToList();
rd.json.allPos = l.ToList();
string savePath = AssetDatabase.GetAssetPath(Selection.activeInstanceID) + "/" + rd.name + ".bin";
FileStream saveFs = File.Open(savePath, FileMode.Create);
BinaryFormatter saveBf = new BinaryFormatter();
......
......@@ -41,30 +41,8 @@ public class GameMgr : MonoBehaviour
{
Scale();
Click();
Play();
}
#region 拖拽
//private bool isDrag = false;
//private Vector2 StartPos = Vector2.zero;
//private Vector2 EndPos = Vector2.zero;
//public void OnBeginDrag(PointerEventData eventData)
//{
// isDrag = true;
// RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, Input.mousePosition, Camera.main, out StartPos);
//}
//public void OnDrag(PointerEventData eventData)
//{
// if (!isDrag) { return; }
// RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, Input.mousePosition, Camera.main, out EndPos);
// Vector3 v = EndPos - StartPos;
// transform.localPosition += v;
//}
//public void OnEndDrag(PointerEventData eventData)
//{
// isDrag = false;
//}
#endregion
#region 缩放
private Vector2 Pos_1;
private Vector2 Pos_2;
......@@ -136,10 +114,9 @@ public class GameMgr : MonoBehaviour
isLongPress = -1;
Vector2 v;
RectTransformUtility.ScreenPointToLocalPointInRectangle(md.rect, Input.mousePosition, Camera.main, out v);
Debug.Log("长按:" + v);
v.x = v.x + md.png.width / 2;
v.y = v.y + md.png.height / 2;
Debug.Log("长按:" + v);
v.x = (int)v.x;
v.y = (int)v.y;
md.OnLongPressPos(v);
......@@ -189,8 +166,38 @@ public class GameMgr : MonoBehaviour
#endregion
public void Clear_Test()
public void Clear()
{
md.Clear();
md.Init(md.key, md.png, md.jpg, md.json);
}
public void RePlay()
{
md.RePlay();
rePlayIndex = 0;
}
public int rePlayIndex = -1;
public void Play()
{
if (rePlayIndex == -1)
{
return;
}
for (int i = 0; i < md.json.roomDatas.Count; i++)
{
if (md.json.roomDatas[i].id == md.json.step[rePlayIndex])
{
Vector2 v = new Vector2(md.json.roomDatas[i].px, md.json.roomDatas[i].py);
md.OnClickPos(v);
rePlayIndex++;
if (rePlayIndex >= md.json.step.Count)
{
rePlayIndex = -1;
}
break;
}
}
}
}
......@@ -66,7 +66,7 @@ public class MainData : MonoBehaviour
//Debug.Log("涂过了");
return false;
}
int id = json.All[(int)(v.x + v.y * png.width)];
int id = json.allPos[(int)(v.x + v.y * png.width)];
if (FunDo(id, v))
{
sw.Stop();
......@@ -86,11 +86,11 @@ public class MainData : MonoBehaviour
ExRoomDatas erd = new ExRoomDatas();
json.roomGroupsData[i].roomIds.Remove(id);
json.roomGroupsData[i].roomIdsOver.Add(id);
json.list.Add(id);
json.step.Add(id);
Color[] c_png = png.GetPixels();
for (int j = 0; j < json.All.Count; j++)
for (int j = 0; j < json.allPos.Count; j++)
{
if (json.All[j] == id)
if (json.allPos[j] == id)
{
erd.AddData(j, png.width);
c_png[j] = Color.clear;
......@@ -114,7 +114,7 @@ public class MainData : MonoBehaviour
public void ChooseGroup(int id)
{
Debug.Log("选中组:" + id);
if(curGroupId == id)
if (curGroupId == id)
{
return;
}
......@@ -135,11 +135,11 @@ public class MainData : MonoBehaviour
{
dic.Add(list[i], new ExRoomDatas());
}
for (int i = 0; i < json.All.Count; i++)
for (int i = 0; i < json.allPos.Count; i++)
{
if (dic.ContainsKey(json.All[i]))
if (dic.ContainsKey(json.allPos[i]))
{
dic[json.All[i]].AddData(i, png.width);
dic[json.allPos[i]].AddData(i, png.width);
}
}
for (int i = 0; i < list.Count; i++)
......@@ -165,13 +165,53 @@ public class MainData : MonoBehaviour
//Debug.Log("涂过了");
return;
}
int id = json.All[(int)(v.x + v.y * png.width)];
int id = json.allPos[(int)(v.x + v.y * png.width)];
for (int i = 0; i < json.roomGroupsData.Count; i++)
{
if (json.roomGroupsData[i].roomIds.Contains(id))
{
ChooseGroup(json.roomGroupsData[i].id);
}
}
}
public void Clear()
{
for (int i = 0; i < json.roomGroupsData.Count; i++)
{
json.roomGroupsData[i].roomIds.AddRange(json.roomGroupsData[i].roomIdsOver);
json.roomGroupsData[i].roomIdsOver.Clear();
}
json.step.Clear();
Color[] c = png.GetPixels();
for (int i = 0; i < c.Length; i++)
{
if (c[i] == Color.clear)
{
c[i] = Color.white;
}
}
png.SetPixels(c);
png.Apply();
SaveManager.Instance.SaveRes(key, json, png);
}
public void RePlay()
{
for (int i = 0; i < json.roomGroupsData.Count; i++)
{
json.roomGroupsData[i].roomIds.AddRange(json.roomGroupsData[i].roomIdsOver);
json.roomGroupsData[i].roomIdsOver.Clear();
}
Color[] c = png.GetPixels();
for (int i = 0; i < c.Length; i++)
{
if (c[i] == Color.clear)
{
c[i] = Color.white;
}
}
png.SetPixels(c);
png.Apply();
}
}
\ No newline at end of file
......@@ -9,9 +9,9 @@ using UnityEngine;
[Serializable]
public class ResJsonData
{
public List<int> list = new List<int>();
public List<int> step = new List<int>();
public List<short> All = new List<short>();
public List<short> allPos = new List<short>();
public List<RoomDatas> roomDatas = new List<RoomDatas>();
......
......@@ -39,22 +39,29 @@ public class TextItemMgr : MonoBehaviour
temp.gameObject.SetActive(false);
}
}
public void CircleAll()
{
for (int i = useList.Count - 1; i >= 0; i--)
{
Circle(useList[i]);
}
}
public void Init(ResJsonData rjd, Texture2D png)
{
CircleAll();
for (int i = 0; i < rjd.roomDatas.Count; i++)
{
RoomDatas rd = rjd.roomDatas[i];
TextItem temp = Get();
temp.gameObject.SetActive(true);
temp.id = rd.id;
temp.Text.fontSize = rd.pr;
temp.transform.localPosition = new Vector3(rd.px - png.width / 2f, rd.py - png.height / 2f, 0);
for (int j = 0; j < rjd.roomGroupsData.Count; j++)
{
RoomGroupsData rgd = rjd.roomGroupsData[j];
if (rgd.roomIds.Contains(rd.id))
{
TextItem temp = Get();
temp.gameObject.SetActive(true);
temp.id = rd.id;
temp.Text.fontSize = rd.pr;
temp.transform.localPosition = new Vector3(rd.px - png.width / 2f, rd.py - png.height / 2f, 0);
temp.Text.text = rgd.id.ToString();
break;
}
......
......@@ -1416,7 +1416,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 427, y: -82.5}
m_AnchoredPosition: {x: 427, y: -82.500015}
m_SizeDelta: {x: 87, y: 91}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &824212554
......@@ -4354,9 +4354,9 @@ MonoBehaviour:
m_HandleRect: {fileID: 5101221413184368358}
m_Direction: 0
m_MinValue: 0
m_MaxValue: 1
m_MaxValue: 100
m_WholeNumbers: 0
m_Value: 1
m_Value: 100
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
......@@ -6408,7 +6408,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3396359898559686475}
m_Enabled: 0
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 582a8965e0faeec4a8df7d0271769c6d, type: 3}
m_Name:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment