Commit 01ebe7fa authored by lijin's avatar lijin

性能优化版

parent e23830ed
......@@ -103,7 +103,7 @@ public class GameEditor
{
v_1 = stackVector2.Pop();
png.SetPixel(v_1.x, v_1.y, Color.white);
rd.posIndex.Add((short)(v_1.x + v_1.y * png.width));
rd.posIndex.Add(v_1.x + v_1.y * png.width);
for (int i = 0; i < d.Length; i++)
{
v_2 = v_1 + d[i];
......
......@@ -73,23 +73,23 @@ public class MainData : MonoBehaviour
if (FunDo(v, b))
{
sw.Stop();
Debug.Log("耗时:" + sw.ElapsedMilliseconds);
Debug.Log("涂色全耗时:" + sw.ElapsedMilliseconds);
return true;
}
return false;
}
public bool FunDo(Vector2 v, bool b = false)
{
System.Diagnostics.Stopwatch sw_1 = new System.Diagnostics.Stopwatch();
sw_1.Start();
RoomDatas rd = null;
int index = (int)(v.x + v.y * png.width);
for (int i = 0; i < json.roomDatas.Count; i++)
{
List<short> l = json.roomDatas[i].posIndex;
for (int j = 0; j < l.Count; j++)
if(json.roomDatas[i].posIndex.Contains(index))
{
if (l[j] == v.x + v.y * png.width)
{
rd = json.roomDatas[i];
}
rd = json.roomDatas[i];
break;
}
}
if (rd == null)
......@@ -97,6 +97,8 @@ public class MainData : MonoBehaviour
Debug.LogError("沒找到點:" + v.x + "-" + v.y);
return false;
}
sw_1.Stop();
Debug.Log("点转区ID耗时:" + sw_1.ElapsedMilliseconds);
if (dynamic.step.Contains(rd.id))
{
Debug.LogError("點過了:" + rd.id);
......@@ -104,7 +106,8 @@ public class MainData : MonoBehaviour
}
if (rd.groupId == curGroupId || b)
{
dynamic.AddData(rd.groupId, rd.id);
System.Diagnostics.Stopwatch sw_2 = new System.Diagnostics.Stopwatch();
sw_2.Start();
Color[] c_png = png.GetPixels();
for (int i = 0; i < rd.posIndex.Count; i++)
{
......@@ -112,11 +115,19 @@ public class MainData : MonoBehaviour
}
png.SetPixels(c_png);
png.Apply();
sw_2.Stop();
Debug.Log("涂色耗时:" + sw_2.ElapsedMilliseconds);
System.Diagnostics.Stopwatch sw_3 = new System.Diagnostics.Stopwatch();
sw_3.Start();
dynamic.AddData(rd.groupId, rd.id);
RoomGroupsData rgd = json.roomGroupsData[rd.groupId - 1];
GameMgr.Ins.eiMgr.Create(new Color(rgd.R / 255f, rgd.G / 255f, rgd.B / 255f, 1), v);
GameMgr.Ins.tiMgr.CircleId(rd.id);
GameMgr.Ins.miMgr.Play(v, rd.id);
EventDispatcher.Dispatch(EventName.Event.Event_GropuItemChange, rgd, dynamic);
sw_3.Stop();
Debug.Log("效果耗时:" + sw_3.ElapsedMilliseconds);
return true;
}
return false;
......@@ -130,6 +141,8 @@ public class MainData : MonoBehaviour
GameMgr.Ins.miMgr.CircleAll();
}
Debug.Log("选中组:" + id);
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
if (curGroupId == id)
{
return;
......@@ -150,6 +163,8 @@ public class MainData : MonoBehaviour
GameMgr.Ins.miMgr.Create(this, erd, rd.id, rd.groupId);
}
}
sw.Stop();
Debug.Log("选组耗时:" + sw.ElapsedMilliseconds);
EventDispatcher.Dispatch(EventName.Event.Event_ChoiseGroupByPic, curGroupId);
}
......@@ -173,7 +188,7 @@ public class MainData : MonoBehaviour
RoomDatas rd = null;
for (int i = 0; i < json.roomDatas.Count; i++)
{
List<short> l = json.roomDatas[i].posIndex;
List<int> l = json.roomDatas[i].posIndex;
for (int j = 0; j < l.Count; j++)
{
if (l[j] == v.x + v.y * png.width)
......
......@@ -12,7 +12,7 @@ public class MaskItem : MonoBehaviour
public Image SP;
public RectTransform Rect;
public RectTransform SPRect;
public Vector4 size;
// Update is called once per frame
void Update()
{
......@@ -20,7 +20,7 @@ public class MaskItem : MonoBehaviour
{
return;
}
Rect.sizeDelta += Time.deltaTime * Vector2.one * IsUse * 2f;
Rect.sizeDelta += Time.deltaTime * Vector2.one * IsUse * 1f;
if (Rect.sizeDelta.x > IsUse * 1.05f && Rect.sizeDelta.y > IsUse * 1.5f)
{
gameObject.SetActive(false);
......@@ -72,9 +72,8 @@ public class MaskItem : MonoBehaviour
//初始处理
gameObject.SetActive(true);
Rect.sizeDelta = Vector2.zero;
float a = Math.Max(erd.size.z - v.x, v.x - erd.size.x);
float b = Math.Max(erd.size.w - v.y, v.y - erd.size.y);
IsUse = -Math.Max(a, b) * 2;
size = erd.size;
}
public void Play(Vector3 v)
......@@ -89,6 +88,9 @@ public class MaskItem : MonoBehaviour
SPRect.SetParent(Rect);
IsUse *= -1;
float a = Math.Max(size.z - v.x, v.x - size.x);
float b = Math.Max(size.w - v.y, v.y - size.y);
IsUse = Math.Max(a, b) * 2;
}
}
......@@ -91,7 +91,7 @@ public class ExtraMetaData //后面再看为啥json序列化失败
public class RoomDatas
{
public int groupId = -1;
public List<short> posIndex = new List<short>();
public List<int> posIndex = new List<int>();
public int id;
public int valid;
......
fileFormatVersion: 2
guid: 9dceb814ec309594686d933949505996
guid: 5deef8a321f86c0459d749c0e87b24be
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
fileFormatVersion: 2
guid: c8fb47e3e3c044946b746a24bcc7aac3
guid: dc863db1bf418db4aa501a7b4c1356ca
DefaultImporter:
externalObjects: {}
userData:
......
fileFormatVersion: 2
guid: a9f2a0a08bc1c89468426e4e75dad3ba
guid: 3c8da2e0ddb5ceb4faf0b2605b091d61
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
......
fileFormatVersion: 2
guid: 443bdf89f2e136242a6868a9f657e6c6
guid: 126b61d0eeba82e4782699d7f91dbc07
DefaultImporter:
externalObjects: {}
userData:
......
fileFormatVersion: 2
guid: 80288066af556804fbb9659376a6d156
guid: bf3d014937afaa64e8c89f47c46c03e7
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
......
fileFormatVersion: 2
guid: 9fc579f1b0a9d81429afafbf7555d3a8
guid: 100c000cdcecb6d4cb3c956344d7b903
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
......
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