Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
T
tuseGameColor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shujianhe
tuseGameColor
Commits
427f8ba3
Commit
427f8ba3
authored
Aug 18, 2023
by
JiangWanZhi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.huolea.com:shujianhe/tusegamecolor
parents
4f3355f8
40e5d431
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
54 deletions
+48
-54
GameEditor.cs
Assets/Editor/GameEditor.cs
+1
-0
MainData.cs
Assets/GameMgr/MainData.cs
+47
-54
No files found.
Assets/Editor/GameEditor.cs
View file @
427f8ba3
...
@@ -45,6 +45,7 @@ public class GameEditor
...
@@ -45,6 +45,7 @@ public class GameEditor
fs
.
Close
();
fs
.
Close
();
}
}
}
}
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
();
...
...
Assets/GameMgr/MainData.cs
View file @
427f8ba3
...
@@ -10,7 +10,7 @@ using UnityEngine.UI;
...
@@ -10,7 +10,7 @@ using UnityEngine.UI;
public
class
MainData
:
MonoBehaviour
,
IDragHandler
,
IEndDragHandler
,
IBeginDragHandler
public
class
MainData
:
MonoBehaviour
,
IDragHandler
,
IEndDragHandler
,
IBeginDragHandler
{
{
public
List
<
ExRoomDatas
>
erdList
=
new
List
<
ExRoomDatas
>()
;
public
ExRoomDatas
erd
;
public
static
int
gunSize
=
50
;
public
static
int
gunSize
=
50
;
...
@@ -36,48 +36,26 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag
...
@@ -36,48 +36,26 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag
png
=
_png
;
png
=
_png
;
jpg
=
_jpg
;
jpg
=
_jpg
;
json
=
_json
;
json
=
_json
;
erdList
=
new
List
<
ExRoomDatas
>();
GoOn
();
Split
();
}
}
public
void
GoOn
()
#
region
解析图片
public
void
Split
()
{
for
(
int
i
=
0
;
i
<
json
.
roomDatas
.
Count
;
i
++)
{
RoomDatas
temp
=
json
.
roomDatas
[
i
];
ExRoomDatas
erd
=
new
ExRoomDatas
();
erdList
.
Add
(
erd
);
Vector2
v
=
new
Vector2
(
temp
.
px
,
temp
.
py
);
if
(
png
.
GetPixel
((
int
)
v
.
x
,
(
int
)
v
.
y
).
a
<=
0.35f
)
{
FunDo
(
v
,
erd
);
}
}
png
.
Apply
();
}
public
void
FunDo
(
Vector2
_v
,
ExRoomDatas
erd
)
{
{
stackVector2
.
Push
(
_v
);
List
<
int
>
list
=
json
.
list
;
Vector2
[]
d
=
new
Vector2
[
4
]
{
new
Vector2
(
0
,
-
1
),
new
Vector2
(
0
,
1
),
new
Vector2
(-
1
,
0
),
new
Vector2
(
1
,
0
)
};
Vector2
v_1
;
for
(
int
i
=
0
;
i
<
list
.
Count
;
i
++)
Vector2
v_2
;
while
(
stackVector2
.
Count
>
0
)
{
{
v_1
=
stackVector2
.
Pop
();
int
id
=
list
[
i
];
erd
.
AddData
(
v_1
);
for
(
int
j
=
0
;
j
<
json
.
roomDatas
.
Count
;
j
++)
png
.
SetPixel
((
int
)
v_1
.
x
,
(
int
)
v_1
.
y
,
Color
.
white
);
for
(
int
i
=
0
;
i
<
d
.
Length
;
i
++)
{
{
v_2
=
v_1
+
d
[
i
];
RoomDatas
rd
=
json
.
roomDatas
[
j
];
if
(
v_2
.
x
>=
0
&&
v_2
.
x
<
png
.
width
&&
v_2
.
y
>=
0
&&
v_2
.
y
<
png
.
height
&&
png
.
GetPixel
((
int
)
v_2
.
x
,
(
int
)
v_2
.
y
).
a
<=
0f
)
if
(
rd
.
id
==
id
)
{
{
stackVector2
.
Push
(
v_2
);
OnClickPixel
(
rd
.
px
,
rd
.
py
);
}
}
}
}
}
}
}
}
#
endregion
#
region
拖拽
#
region
拖拽
private
bool
isDrag
=
false
;
private
bool
isDrag
=
false
;
...
@@ -187,20 +165,26 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag
...
@@ -187,20 +165,26 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag
});
});
for
(
int
i
=
0
;
i
<
list
.
Count
;
i
++)
for
(
int
i
=
0
;
i
<
list
.
Count
;
i
++)
{
{
bool
b
=
OnClickPos
(
list
[
i
]);
if
(
OnClickPixel
(
list
[
i
]))
if
(
b
)
{
{
return
;
return
;
}
}
}
}
}
}
public
bool
OnClickPixel
(
float
x
,
float
y
)
{
Vector2
v
=
new
Vector2
(
x
+
png
.
width
/
2
,
y
+
png
.
height
/
2
);
return
OnClickPos
(
v
);
}
public
bool
OnClickPixel
(
Vector2
v
)
{
v
.
x
=
v
.
x
+
png
.
width
/
2
;
v
.
y
=
v
.
y
+
png
.
height
/
2
;
return
OnClickPos
(
v
);
}
public
bool
OnClickPos
(
Vector2
v
)
public
bool
OnClickPos
(
Vector2
v
)
{
{
v
.
x
=
(
int
)
v
.
x
+
png
.
width
/
2
;
v
.
y
=
(
int
)
v
.
y
+
png
.
height
/
2
;
if
(
v
.
x
<
0
||
v
.
x
>=
png
.
width
)
if
(
v
.
x
<
0
||
v
.
x
>=
png
.
width
)
{
{
//Debug.Log("x越界:" + v.x);
//Debug.Log("x越界:" + v.x);
...
@@ -216,20 +200,7 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag
...
@@ -216,20 +200,7 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag
//Debug.Log("涂过了");
//Debug.Log("涂过了");
return
false
;
return
false
;
}
}
ExRoomDatas
erd
=
null
;
FunDo
(
v
);
for
(
int
i
=
0
;
i
<
erdList
.
Count
;
i
++)
{
if
(
erdList
[
i
].
Contains
(
v
))
{
//Debug.Log("在第" + i + "组数据中");
erd
=
erdList
[
i
];
}
}
if
(
erd
==
null
)
{
//Debug.Log("组数据为空");
return
false
;
}
GameMgr
.
Ins
.
Create
(
this
,
erd
,
v
);
GameMgr
.
Ins
.
Create
(
this
,
erd
,
v
);
...
@@ -240,4 +211,26 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag
...
@@ -240,4 +211,26 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag
png
.
Apply
();
png
.
Apply
();
return
true
;
return
true
;
}
}
public
void
FunDo
(
Vector2
_v
)
{
erd
=
new
ExRoomDatas
();
stackVector2
.
Push
(
_v
);
Vector2
[]
d
=
new
Vector2
[
4
]
{
new
Vector2
(
0
,
-
1
),
new
Vector2
(
0
,
1
),
new
Vector2
(-
1
,
0
),
new
Vector2
(
1
,
0
)
};
Vector2
v_1
;
Vector2
v_2
;
while
(
stackVector2
.
Count
>
0
)
{
v_1
=
stackVector2
.
Pop
();
erd
.
AddData
(
v_1
);
png
.
SetPixel
((
int
)
v_1
.
x
,
(
int
)
v_1
.
y
,
Color
.
white
);
for
(
int
i
=
0
;
i
<
d
.
Length
;
i
++)
{
v_2
=
v_1
+
d
[
i
];
if
(
v_2
.
x
>=
0
&&
v_2
.
x
<
png
.
width
&&
v_2
.
y
>=
0
&&
v_2
.
y
<
png
.
height
&&
png
.
GetPixel
((
int
)
v_2
.
x
,
(
int
)
v_2
.
y
).
a
<=
0.35f
)
{
stackVector2
.
Push
(
v_2
);
}
}
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment