Commit ebabfedc authored by Ever's avatar Ever

更新同步代码

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