Commit ebc07515 authored by lijin's avatar lijin

手動保存

parent cd01177b
...@@ -52,16 +52,15 @@ public class GameEditor ...@@ -52,16 +52,15 @@ public class GameEditor
Color[] c = rd.png.GetPixels(); Color[] c = rd.png.GetPixels();
rd.png = new Texture2D(rd.png.width, rd.png.height, rd.png.format, false); rd.png = new Texture2D(rd.png.width, rd.png.height, rd.png.format, false);
rd.png.SetPixels(c); rd.png.SetPixels(c);
rd.png.Apply();
short[] l = new short[2048 * 2048]; short[] l = new short[2048 * 2048];
for (int i = 0; i < rd.json.roomDatas.Count; i++) for (int i = 0; i < rd.json.roomDatas.Count; i++)
{ {
FunDo(l, rd.png, rd.json.roomDatas[i]); FunDo(l, rd.png, rd.json.roomDatas[i]);
} }
rd.png.Apply();
rd.json.allPos = l.ToList(); rd.json.allPos = l.ToList();
Debug.Log(rd.jpg.EncodeToJPG().Length);
File.WriteAllBytes(path + "/" + rd.name + "_png.png", rd.png.EncodeToPNG()); File.WriteAllBytes(path + "/" + rd.name + "_png.png", rd.png.EncodeToPNG());
File.WriteAllBytes(path + "/" + rd.name + "_jpg.jpg", rd.jpg.EncodeToJPG()); File.WriteAllBytes(path + "/" + rd.name + "_jpg.jpg", rd.jpg.EncodeToJPG());
File.WriteAllBytes(path + "/" + rd.name + "_preview.png", rd.preview.EncodeToPNG()); File.WriteAllBytes(path + "/" + rd.name + "_preview.png", rd.preview.EncodeToPNG());
...@@ -84,16 +83,16 @@ public class GameEditor ...@@ -84,16 +83,16 @@ public class GameEditor
{ {
V2 v = new V2(rd.px, rd.py); V2 v = new V2(rd.px, rd.py);
Stack<V2> stackVector2 = new Stack<V2>(); Stack<V2> stackVector2 = new Stack<V2>();
if (rd.valid == 0)
if (v.x >= 0 && v.x < png.width && v.y >= 0 && v.y < png.height && png.GetPixel(v.x, v.y).a <= 0.35f)
{ {
stackVector2.Push(v); Debug.Log("壞點:" + v.x + "-" + v.y);
png.SetPixel(v.x, v.y, Color.clear);
return;
} }
else else
{ {
Debug.LogError("配置像素点进不了堆栈:" + rd.id); stackVector2.Push(v);
} }
V2[] d = new V2[8] { new V2(0, -1), new V2(0, 1), new V2(-1, 0), new V2(1, 0), new V2(-1, -1), new V2(-1, 1), new V2(1, -1), new V2(1, 1) }; V2[] d = new V2[8] { new V2(0, -1), new V2(0, 1), new V2(-1, 0), new V2(1, 0), new V2(-1, -1), new V2(-1, 1), new V2(1, -1), new V2(1, 1) };
V2 v_1; V2 v_1;
V2 v_2; V2 v_2;
...@@ -120,15 +119,10 @@ public class GameEditor ...@@ -120,15 +119,10 @@ public class GameEditor
break; break;
} }
} }
if (count == 1) if (count < 10)
{ {
Debug.LogError("循环次数:" + count + " rd.id:" + rd.id); Debug.LogError("循环次数:" + count + " rd.id:" + rd.id);
} }
else
{
Debug.Log("循环次数:" + count);
}
png.Apply();
} }
......
...@@ -207,4 +207,9 @@ public class GameMgr : MonoBehaviour ...@@ -207,4 +207,9 @@ public class GameMgr : MonoBehaviour
} }
} }
} }
public void Save()
{
md.Save();
}
} }
...@@ -106,7 +106,6 @@ public class MainData : MonoBehaviour ...@@ -106,7 +106,6 @@ public class MainData : MonoBehaviour
GameMgr.Ins.tiMgr.CircleId(id); GameMgr.Ins.tiMgr.CircleId(id);
GameMgr.Ins.miMgr.Play(v, id); GameMgr.Ins.miMgr.Play(v, id);
EventDispatcher.Dispatch(EventName.Event.Event_GropuItemChange, json.roomGroupsData[i], dynamic); EventDispatcher.Dispatch(EventName.Event.Event_GropuItemChange, json.roomGroupsData[i], dynamic);
SaveManager.Instance.SaveRes(key, dynamic, png);
return true; return true;
} }
} }
...@@ -153,7 +152,7 @@ public class MainData : MonoBehaviour ...@@ -153,7 +152,7 @@ public class MainData : MonoBehaviour
} }
for (int i = 0; i < list.Count; i++) for (int i = 0; i < list.Count; i++)
{ {
GameMgr.Ins.miMgr.Create(this, dic[list[i]], list[i]); GameMgr.Ins.miMgr.Create(this, dic[list[i]], list[i],id);
} }
EventDispatcher.Dispatch(EventName.Event.Event_ChoiseGroupByPic, curGroupId); EventDispatcher.Dispatch(EventName.Event.Event_ChoiseGroupByPic, curGroupId);
} }
...@@ -218,7 +217,12 @@ public class MainData : MonoBehaviour ...@@ -218,7 +217,12 @@ public class MainData : MonoBehaviour
} }
for (int i = 0; i < dynamic.step.Count; i++) for (int i = 0; i < dynamic.step.Count; i++)
{ {
GameMgr.Ins.miMgr.Create(this, dic[dynamic.step[i]], dynamic.step[i]); GameMgr.Ins.miMgr.Create(this, dic[dynamic.step[i]], dynamic.step[i],0);
} }
} }
public void Save()
{
SaveManager.Instance.SaveRes(key, dynamic, png);
}
} }
\ No newline at end of file
...@@ -6,13 +6,13 @@ using UnityEngine.UI; ...@@ -6,13 +6,13 @@ using UnityEngine.UI;
public class MaskItem : MonoBehaviour public class MaskItem : MonoBehaviour
{ {
public int id = -1; public int roomId = -1;
public int groupId = -1;
public float IsUse = -1; public float IsUse = -1;
public Image SP; public Image SP;
public RectTransform Rect; public RectTransform Rect;
public RectTransform SPRect; public RectTransform SPRect;
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
...@@ -24,15 +24,17 @@ public class MaskItem : MonoBehaviour ...@@ -24,15 +24,17 @@ public class MaskItem : MonoBehaviour
if (Rect.sizeDelta.x > IsUse * 1.05f && Rect.sizeDelta.y > IsUse * 1.5f) if (Rect.sizeDelta.x > IsUse * 1.05f && Rect.sizeDelta.y > IsUse * 1.5f)
{ {
gameObject.SetActive(false); gameObject.SetActive(false);
roomId = -1;
groupId = -1;
IsUse = -1; IsUse = -1;
GameMgr.Ins.miMgr.Circle(this); GameMgr.Ins.miMgr.Circle(this);
} }
} }
public void FunDo(MainData md, ExRoomDatas erd, int _roomId, int _groupId)
public void FunDo(MainData md, ExRoomDatas erd, int _id)
{ {
Vector3 v = Vector3.zero; Vector3 v = Vector3.zero;
id = _id; roomId = _roomId;
groupId = _groupId;
//创建图片 //创建图片
Texture2D te = new Texture2D((int)(erd.size.z - erd.size.x + 1), (int)(erd.size.w - erd.size.y + 1), TextureFormat.RGBA32, false); Texture2D te = new Texture2D((int)(erd.size.z - erd.size.x + 1), (int)(erd.size.w - erd.size.y + 1), TextureFormat.RGBA32, false);
Color[] colors = te.GetPixels(); Color[] colors = te.GetPixels();
...@@ -75,7 +77,7 @@ public class MaskItem : MonoBehaviour ...@@ -75,7 +77,7 @@ public class MaskItem : MonoBehaviour
IsUse = -Math.Max(a, b) * 2; IsUse = -Math.Max(a, b) * 2;
} }
internal void Play(Vector3 v) public void Play(Vector3 v)
{ {
MainData md = GameMgr.Ins.md; MainData md = GameMgr.Ins.md;
SPRect.SetParent(md.imgpng.transform); SPRect.SetParent(md.imgpng.transform);
......
...@@ -27,19 +27,20 @@ public class MaskItemMgr : MonoBehaviour ...@@ -27,19 +27,20 @@ public class MaskItemMgr : MonoBehaviour
{ {
useList.Remove(temp); useList.Remove(temp);
poolList.Add(temp); poolList.Add(temp);
temp.gameObject.SetActive(false);
} }
} }
public void Create(MainData md, ExRoomDatas erd, int id) public void Create(MainData md, ExRoomDatas erd, int roomId, int groupId)
{ {
MaskItem temp = Get(); MaskItem temp = Get();
temp.FunDo(md, erd, id); temp.FunDo(md, erd, roomId, groupId);
} }
public void Play(Vector3 v, int id) public void Play(Vector3 v, int id)
{ {
for (int i = 0; i < useList.Count; i++) for (int i = 0; i < useList.Count; i++)
{ {
if (useList[i].id == id) if (useList[i].roomId == id)
{ {
useList[i].Play(v); useList[i].Play(v);
} }
......
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