Commit ebabfedc authored by Ever's avatar Ever

更新同步代码

parent 836c6b67
...@@ -47,17 +47,12 @@ public class GameEditor ...@@ -47,17 +47,12 @@ public class GameEditor
} }
} }
Color[] list = rd.png.GetPixels(0); short[] l = new short[2048 * 2048];
for (int i = 0; i < list.Length; i++) for (int i = 0; i < rd.json.roomDatas.Count; i++)
{ {
if (list[i].a <= 0.5f) FunDo(l, rd.png, rd.json.roomDatas[i]);
{
list[i] = Color.white;
}
} }
rd.png.SetPixels(list); rd.json.All = l.ToList();
rd.png.Apply();
string savePath = AssetDatabase.GetAssetPath(Selection.activeInstanceID) + "/" + rd.name + ".bin"; string savePath = AssetDatabase.GetAssetPath(Selection.activeInstanceID) + "/" + rd.name + ".bin";
FileStream saveFs = File.Open(savePath, FileMode.Create); FileStream saveFs = File.Open(savePath, FileMode.Create);
BinaryFormatter saveBf = new BinaryFormatter(); BinaryFormatter saveBf = new BinaryFormatter();
...@@ -65,4 +60,41 @@ public class GameEditor ...@@ -65,4 +60,41 @@ public class GameEditor
saveFs.Close(); saveFs.Close();
Debug.Log("成功:" + savePath); Debug.Log("成功:" + savePath);
} }
public static void FunDo(short[] l, Texture2D png, RoomDatas rd)
{
V2 v2 = new V2(rd.px, rd.py);
Stack<V2> stackVector2 = new Stack<V2>();
stackVector2.Push(v2);
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_2;
int count = 0;
while (stackVector2.Count > 0)
{
v_1 = stackVector2.Pop();
png.SetPixel(v_1.x, v_1.y, Color.white);
l[v_1.x + v_1.y * png.width] = (short)rd.id;
for (int i = 0; i < d.Length; i++)
{
v_2 = v_1 + d[i];
Color c = png.GetPixel(v_2.x, v_2.y);
if (v_2.x >= 0 && v_2.x < png.width && v_2.y >= 0 && v_2.y < png.height && c.a <= 0.5f)
{
stackVector2.Push(v_2);
}
}
count++;
if (count > 10000000)
{
Debug.LogError("死循环了!");
break;
}
}
Debug.Log("循环次数:" + count);
png.Apply();
}
} }
...@@ -24,7 +24,7 @@ public class GameMgr : MonoBehaviour ...@@ -24,7 +24,7 @@ public class GameMgr : MonoBehaviour
public void ChooseGroup(int id) public void ChooseGroup(int id)
{ {
md.ChooseGroup(id);
} }
} }
...@@ -13,13 +13,17 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag ...@@ -13,13 +13,17 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag
public static int gunSize = 50; public static int gunSize = 50;
public static Vector4 config = new Vector4(0, -100, 725f, 725f); public static Vector4 config = new Vector4(0, -100, 725f, 725f);
public ExRoomDatas erd;
public Texture2D png = null; public Texture2D png = null;
public Sprite jpg = null; public Sprite jpg = null;
public ResJsonData json; public ResJsonData json;
public Texture2D mask = null;
public Texture2D gray = null;
public Image imgpng; public Image imgpng;
public Image imgjpg; public Image imgjpg;
public Image imgmask;
public RectTransform rect; public RectTransform rect;
...@@ -44,9 +48,20 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag ...@@ -44,9 +48,20 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag
float s = Math.Min(w, h); float s = Math.Min(w, h);
transform.parent.localScale = Vector3.one * s; transform.parent.localScale = Vector3.one * s;
transform.parent.localPosition = new Vector3(config.x, config.y, 0); transform.parent.localPosition = new Vector3(config.x, config.y, 0);
GameMgr.Ins.tiMgr.Init(json, png);
GameMgr.Ins.tiMgr.Init(json,png);
GameMgr.Ins.tiMgr.SizeChange(s); GameMgr.Ins.tiMgr.SizeChange(s);
mask = new Texture2D(png.width, png.height);
Color[] c = mask.GetPixels();
for (int i = 0; i < c.Length; i++)
{
c[i].a = 0;
}
mask.SetPixels(c);
mask.Apply();
imgmask.sprite = Sprite.Create(mask, new Rect(0, 0, png.width, png.height), new Vector2(0.5f, 0.5f));
imgmask.GetComponent<RectTransform>().sizeDelta = new Vector2(png.width, png.height);
EventDispatcher.Dispatch(EventName.Event.Event_GroupListCreate, json.roomGroupsData); EventDispatcher.Dispatch(EventName.Event.Event_GroupListCreate, json.roomGroupsData);
} }
...@@ -189,47 +204,56 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag ...@@ -189,47 +204,56 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag
//Debug.Log("涂过了"); //Debug.Log("涂过了");
return false; return false;
} }
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); int id = json.All[(int)(v.x + v.y * png.width)];
sw.Start(); FunDo(id);
FunDo(v); //GameMgr.Ins.miMgr.Create(this, erd, v);
sw.Stop();
Debug.Log("耗时:" + sw.ElapsedMilliseconds); //TODO保存点
GameMgr.Ins.miMgr.Create(this, erd, v);
return true; return true;
} }
public void FunDo(Vector2 _v) public void FunDo(int id)
{ {
V2 v2 = new V2(_v); Color[] c = png.GetPixels();
Stack<V2> stackVector2 = new Stack<V2>(); for (int i = 0; i < json.All.Count; i++)
erd = new ExRoomDatas();
stackVector2.Push(v2);
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_2;
int count = 0;
while (stackVector2.Count > 0)
{ {
v_1 = stackVector2.Pop(); if (json.All[i] == id)
erd.AddData(v_1);
png.SetPixel(v_1.x, v_1.y, Color.clear);
for (int i = 0; i < d.Length; i++)
{ {
v_2 = v_1 + d[i]; c[i] = Color.clear;
Color c = png.GetPixel(v_2.x, v_2.y);
if (v_2.x >= 0 && v_2.x < png.width && v_2.y >= 0 && v_2.y < png.height && c == Color.white)
{
stackVector2.Push(v_2);
}
} }
count++; }
if (count > 10000000) png.SetPixels(c);
png.Apply();
}
public void ChooseGroup(int id)
{
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
List<int> list = new List<int>();
List<RoomGroupsData> l = json.roomGroupsData;
for (int i = 0; i < l.Count; i++)
{
if (l[i].id == id)
{ {
Debug.LogError("死循环了!"); list = l[i].roomIds;
break; break;
} }
} }
Debug.Log("循环次数:" + count); Color[] c = mask.GetPixels();
png.Apply(); for (int i = 0; i < c.Length; i++)
{
c[i].a = 0;
}
for (int i = 0; i < json.All.Count; i++)
{
if (list.Contains(json.All[i]))
{
c[i].a = 1;
}
}
mask.SetPixels(c);
mask.Apply();
sw.Stop();
Debug.Log("耗时:" + sw.ElapsedMilliseconds);
} }
} }
...@@ -33,42 +33,42 @@ public class MaskItem : MonoBehaviour ...@@ -33,42 +33,42 @@ public class MaskItem : MonoBehaviour
} }
} }
internal void FunDo(MainData md, ExRoomDatas erd, Vector3 v) public void FunDo(MainData md, Vector3 v)
{ {
//创建图片 ////创建图片
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();
for (int i = 0; i < colors.Length; i++) //for (int i = 0; i < colors.Length; i++)
{ //{
colors[i].a = 0f; // colors[i].a = 0f;
} //}
te.SetPixels(colors); //te.SetPixels(colors);
for (int i = 0; i < erd.list.Count; i++) //for (int i = 0; i < erd.list.Count; i++)
{ //{
te.SetPixel((int)(erd.list[i].x - erd.size.x), (int)(erd.list[i].y - erd.size.y), Color.white); // te.SetPixel((int)(erd.list[i].x - erd.size.x), (int)(erd.list[i].y - erd.size.y), Color.white);
} //}
te.Apply(); //te.Apply();
Sprite sp = Sprite.Create(te, new Rect(0, 0, te.width, te.height), Vector2.zero); //Sprite sp = Sprite.Create(te, new Rect(0, 0, te.width, te.height), Vector2.zero);
SP.sprite = sp; //SP.sprite = sp;
SP.GetComponent<RectTransform>().sizeDelta = new Vector2(te.width, te.height); //SP.GetComponent<RectTransform>().sizeDelta = new Vector2(te.width, te.height);
//坐标计算 ////坐标计算
Transform p = Rect.parent; //Transform p = Rect.parent;
Rect.SetParent(md.imgpng.transform); //Rect.SetParent(md.imgpng.transform);
Rect.localPosition = v - new Vector3(md.png.width / 2, md.png.height / 2); //Rect.localPosition = v - new Vector3(md.png.width / 2, md.png.height / 2);
Rect.SetParent(p); //Rect.SetParent(p);
Rect.localScale = Vector2.one; //Rect.localScale = Vector2.one;
SPRect.SetParent(md.imgpng.transform); //SPRect.SetParent(md.imgpng.transform);
SPRect.localPosition = new Vector3(erd.size.x + (erd.size.z + 1 - erd.size.x) / 2 - (md.png.width + 1) / 2, erd.size.y + (erd.size.w + 1 - erd.size.y) / 2 - (md.png.height + 1) / 2, 0); //SPRect.localPosition = new Vector3(erd.size.x + (erd.size.z + 1 - erd.size.x) / 2 - (md.png.width + 1) / 2, erd.size.y + (erd.size.w + 1 - erd.size.y) / 2 - (md.png.height + 1) / 2, 0);
SPRect.SetParent(Rect); //SPRect.SetParent(Rect);
SPRect.localScale = Vector2.one; //SPRect.localScale = Vector2.one;
//初始处理 ////初始处理
gameObject.SetActive(true); //gameObject.SetActive(true);
Rect.sizeDelta = Vector2.zero; //Rect.sizeDelta = Vector2.zero;
float a = Math.Max(erd.size.z - v.x, v.x - erd.size.x); //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); //float b = Math.Max(erd.size.w - v.y, v.y - erd.size.y);
IsUse = Math.Max(a, b) * 2; //IsUse = Math.Max(a, b) * 2;
} }
} }
...@@ -27,9 +27,9 @@ public class MaskItemMgr : MonoBehaviour ...@@ -27,9 +27,9 @@ public class MaskItemMgr : MonoBehaviour
poolList.Add(temp); poolList.Add(temp);
} }
} }
public void Create(MainData md, ExRoomDatas erd, Vector3 v) public void Create(MainData md, Vector3 v)
{ {
MaskItem temp = Get(); MaskItem temp = Get();
temp.FunDo(md, erd, v); temp.FunDo(md, v);
} }
} }
...@@ -67,46 +67,6 @@ public class RoomGroupsData ...@@ -67,46 +67,6 @@ public class RoomGroupsData
public int G; public int G;
public int B; public int B;
} }
[Serializable]
public class ExRoomDatas
{
public Vector4 size = -Vector4.one;
public List<V2> list = new List<V2>();
public void AddData(V2 v)
{
if (size.x == -1 || size.x > v.x)
{
size.x = v.x;
}
if (size.y == -1 || size.y > v.y)
{
size.y = v.y;
}
if (size.z == -1 || size.z < v.x)
{
size.z = v.x;
}
if (size.w == -1 || size.w < v.y)
{
size.w = v.y;
}
list.Add(v);
}
public bool Contains(Vector2 v)
{
for (int i = 0; i < list.Count; i++)
{
if (list[i].x == v.x && list[i].y == v.y)
{
return true;
}
}
return false;
}
}
[Serializable] [Serializable]
public struct V2 public struct V2
{ {
......
...@@ -56,7 +56,7 @@ Material: ...@@ -56,7 +56,7 @@ Material:
- _EnableExternalAlpha: 0 - _EnableExternalAlpha: 0
- _QueueControl: 1 - _QueueControl: 1
- _QueueOffset: 0 - _QueueOffset: 0
- progress: 0.472 - progress: 0.2
m_Colors: m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 1, g: 1, b: 1, a: 1}
- _Flip: {r: 1, g: 1, b: 1, a: 1} - _Flip: {r: 1, g: 1, b: 1, a: 1}
......
...@@ -20,8 +20,8 @@ SpriteAtlasImporter: ...@@ -20,8 +20,8 @@ SpriteAtlasImporter:
blockOffset: 1 blockOffset: 1
allowAlphaSplitting: 0 allowAlphaSplitting: 0
enableRotation: 1 enableRotation: 1
enableTightPacking: 0 enableTightPacking: 1
enableAlphaDilation: 1 enableAlphaDilation: 0
secondaryTextureSettings: {} secondaryTextureSettings: {}
variantMultiplier: 1 variantMultiplier: 1
bindAsDefault: 1 bindAsDefault: 1
......
fileFormatVersion: 2
guid: 32b4a1c330339ff4ba171e293d568be6
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
...@@ -119,6 +119,32 @@ TextureImporter: ...@@ -119,6 +119,32 @@ TextureImporter:
ignorePlatformSupport: 0 ignorePlatformSupport: 0
androidETC2FallbackOverride: 0 androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0 forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet: spriteSheet:
serializedVersion: 2 serializedVersion: 2
sprites: [] sprites: []
......
...@@ -317,10 +317,10 @@ RectTransform: ...@@ -317,10 +317,10 @@ RectTransform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 7902676659994826364} - {fileID: 7902676659994826364}
- {fileID: 5445402404206781183}
- {fileID: 7679003703182876708} - {fileID: 7679003703182876708}
- {fileID: 8460472138427881079}
- {fileID: 800309816225797410} - {fileID: 800309816225797410}
- {fileID: 5445402404206781183}
- {fileID: 8460472138427881079}
m_Father: {fileID: 2908597137679265870} m_Father: {fileID: 2908597137679265870}
m_RootOrder: -1 m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
...@@ -341,12 +341,11 @@ MonoBehaviour: ...@@ -341,12 +341,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: dfb345a38dec3ca46a0d72d6e32abaaa, type: 3} m_Script: {fileID: 11500000, guid: dfb345a38dec3ca46a0d72d6e32abaaa, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
erd:
size: {x: -1, y: -1, z: -1, w: -1}
png: {fileID: 0} png: {fileID: 0}
jpg: {fileID: 0} jpg: {fileID: 0}
json: json:
list: list:
All:
roomDatas: [] roomDatas: []
roomGroupsData: [] roomGroupsData: []
colorDiff: 0 colorDiff: 0
...@@ -367,8 +366,11 @@ MonoBehaviour: ...@@ -367,8 +366,11 @@ MonoBehaviour:
extraMetaData: extraMetaData:
kadian_size: 0 kadian_size: 0
tuhei_size: 0 tuhei_size: 0
mask: {fileID: 0}
gray: {fileID: 2800000, guid: e2d616a4f0dc6da4385fe6a816421e53, type: 3}
imgpng: {fileID: 7126587409335573646} imgpng: {fileID: 7126587409335573646}
imgjpg: {fileID: 2338271980406512720} imgjpg: {fileID: 2338271980406512720}
imgmask: {fileID: 3177285961417058712}
rect: {fileID: 136994829194703267} rect: {fileID: 136994829194703267}
--- !u!1 &2488372294624611549 --- !u!1 &2488372294624611549
GameObject: GameObject:
...@@ -440,7 +442,7 @@ GameObject: ...@@ -440,7 +442,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &5445402404206781183 --- !u!224 &5445402404206781183
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -459,7 +461,7 @@ RectTransform: ...@@ -459,7 +461,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 2048, y: 2048} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2742025492825055717 --- !u!222 &2742025492825055717
CanvasRenderer: CanvasRenderer:
...@@ -490,7 +492,7 @@ MonoBehaviour: ...@@ -490,7 +492,7 @@ MonoBehaviour:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 0} m_Sprite: {fileID: 0}
m_Type: 2 m_Type: 0
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1
m_FillMethod: 4 m_FillMethod: 4
......
...@@ -84,8 +84,6 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -84,8 +84,6 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
onEvent(EventName.Event.Event_GroupIsLoadOver, onGroupIsLoadOver); //组的成员加载完成,就是组列表下的item onEvent(EventName.Event.Event_GroupIsLoadOver, onGroupIsLoadOver); //组的成员加载完成,就是组列表下的item
transform.Find("ingameLoad/loadImg").gameObject.SetActive(false); transform.Find("ingameLoad/loadImg").gameObject.SetActive(false);
//gameScenUser //gameScenUser
//var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>();
//gridViewList.gameObject.SetActive(false);
transform.Find("areaGroupList/groupListBg").gameObject.SetActive(false); transform.Find("areaGroupList/groupListBg").gameObject.SetActive(false);
transform.Find("areaGroupList/gameProgress/gameProgressText").gameObject.SetActive(false); transform.Find("areaGroupList/gameProgress/gameProgressText").gameObject.SetActive(false);
transform.Find("areaGroupList/gameProgress").gameObject.SetActive(false); transform.Find("areaGroupList/gameProgress").gameObject.SetActive(false);
......
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