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
f6d1bad2
Commit
f6d1bad2
authored
Aug 20, 2023
by
Ever
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步代码
parent
5f8903dc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
427 additions
and
49 deletions
+427
-49
GameMgr.cs
Assets/GameMgr/GameMgr.cs
+7
-0
GrayItem.cs
Assets/GameMgr/GrayItem.cs
+7
-3
MainData.cs
Assets/GameMgr/MainData.cs
+20
-20
MaskItem.cs
Assets/GameMgr/MaskItem.cs
+6
-1
GameMgr.prefab
Assets/Resources/perfabs/GameMgr.prefab
+383
-21
gameScene.unity
Assets/Scenes/gameScene.unity
+4
-4
No files found.
Assets/GameMgr/GameMgr.cs
View file @
f6d1bad2
...
...
@@ -17,10 +17,13 @@ public class GameMgr : MonoBehaviour
public
TextItemMgr
tiMgr
;
public
GrayItemMgr
giMgr
;
public
Texture2D
gray
;
public
void
Init
(
string
key
,
Texture2D
png
,
Sprite
jpg
,
ResJsonData
json
)
{
ins
=
this
;
md
.
Init
(
key
,
png
,
jpg
,
json
);
GetComponent
<
RectTransform
>().
offsetMax
=
Vector2
.
zero
;
GetComponent
<
RectTransform
>().
offsetMin
=
Vector2
.
zero
;
}
public
void
ChooseGroup
(
int
id
)
...
...
@@ -28,4 +31,8 @@ public class GameMgr : MonoBehaviour
md
.
ChooseGroup
(
id
);
}
public
void
SetGray
(
Texture2D
_gray
)
{
gray
=
_gray
;
}
}
Assets/GameMgr/GrayItem.cs
View file @
f6d1bad2
...
...
@@ -9,8 +9,7 @@ public class GrayItem : MonoBehaviour
public
Image
SP
;
public
RectTransform
Rect
;
public
int
id
=
-
1
;
public
Texture2D
png
;
public
void
FunDo
(
MainData
md
,
ExRoomDatas
erd
,
int
_id
)
public
void
FunDo
(
MainData
md
,
ExRoomDatas
erd
,
int
_id
)
{
id
=
_id
;
//创建图片
...
...
@@ -21,9 +20,14 @@ public class GrayItem : MonoBehaviour
colors
[
i
].
a
=
0f
;
}
te
.
SetPixels
(
colors
);
Texture2D
gray
=
GameMgr
.
Ins
.
gray
;
Color
[]
list
=
gray
.
GetPixels
();
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
.
black
);
int
x
=
erd
.
list
[
i
].
x
%
gray
.
width
;
int
y
=
erd
.
list
[
i
].
y
%
gray
.
height
;
Color
c
=
list
[
x
+
y
*
gray
.
width
];
te
.
SetPixel
((
int
)(
erd
.
list
[
i
].
x
-
erd
.
size
.
x
),
(
int
)(
erd
.
list
[
i
].
y
-
erd
.
size
.
y
),
c
);
}
te
.
Apply
();
Sprite
sp
=
Sprite
.
Create
(
te
,
new
Rect
(
0
,
0
,
te
.
width
,
te
.
height
),
Vector2
.
zero
);
...
...
Assets/GameMgr/MainData.cs
View file @
f6d1bad2
...
...
@@ -8,7 +8,7 @@ using UnityEngine;
using
UnityEngine.EventSystems
;
using
UnityEngine.UI
;
public
class
MainData
:
MonoBehaviour
,
IDragHandler
,
IEndDragHandler
,
IBeginDragHandler
public
class
MainData
:
MonoBehaviour
{
public
static
int
gunSize
=
50
;
public
static
Vector4
config
=
new
Vector4
(
0
,
150
,
725f
,
725f
);
...
...
@@ -54,26 +54,26 @@ public class MainData : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDrag
}
#
region
拖拽
private
bool
isDrag
=
false
;
private
Vector2
StartPos
=
Vector2
.
zero
;
private
Vector2
EndPos
=
Vector2
.
zero
;
public
void
OnBeginDrag
(
PointerEventData
eventData
)
{
isDrag
=
true
;
RectTransformUtility
.
ScreenPointToLocalPointInRectangle
(
rect
,
Input
.
mousePosition
,
Camera
.
main
,
out
StartPos
);
}
public
void
OnDrag
(
PointerEventData
eventData
)
{
if
(!
isDrag
)
{
return
;
}
RectTransformUtility
.
ScreenPointToLocalPointInRectangle
(
rect
,
Input
.
mousePosition
,
Camera
.
main
,
out
EndPos
);
//
private bool isDrag = false;
//
private Vector2 StartPos = Vector2.zero;
//
private Vector2 EndPos = Vector2.zero;
//
public void OnBeginDrag(PointerEventData eventData)
//
{
//
isDrag = true;
//
RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, Input.mousePosition, Camera.main, out StartPos);
//
}
//
public void OnDrag(PointerEventData eventData)
//
{
//
if (!isDrag) { return; }
//
RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, Input.mousePosition, Camera.main, out EndPos);
Vector3
v
=
EndPos
-
StartPos
;
transform
.
localPosition
+=
v
;
}
public
void
OnEndDrag
(
PointerEventData
eventData
)
{
isDrag
=
false
;
}
//
Vector3 v = EndPos - StartPos;
//
transform.localPosition += v;
//
}
//
public void OnEndDrag(PointerEventData eventData)
//
{
//
isDrag = false;
//
}
#
endregion
#
region
缩放
...
...
Assets/GameMgr/MaskItem.cs
View file @
f6d1bad2
...
...
@@ -38,9 +38,14 @@ public class MaskItem : MonoBehaviour
colors
[
i
].
a
=
0f
;
}
te
.
SetPixels
(
colors
);
Texture2D
gray
=
GameMgr
.
Ins
.
gray
;
Color
[]
list
=
gray
.
GetPixels
();
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
);
int
x
=
erd
.
list
[
i
].
x
%
gray
.
width
;
int
y
=
erd
.
list
[
i
].
y
%
gray
.
height
;
Color
c
=
list
[
x
+
y
*
gray
.
width
];
te
.
SetPixel
((
int
)(
erd
.
list
[
i
].
x
-
erd
.
size
.
x
),
(
int
)(
erd
.
list
[
i
].
y
-
erd
.
size
.
y
),
c
);
}
te
.
Apply
();
Sprite
sp
=
Sprite
.
Create
(
te
,
new
Rect
(
0
,
0
,
te
.
width
,
te
.
height
),
Vector2
.
zero
);
...
...
Assets/Resources/perfabs/GameMgr.prefab
View file @
f6d1bad2
This diff is collapsed.
Click to expand it.
Assets/Scenes/gameScene.unity
View file @
f6d1bad2
...
...
@@ -7111,11 +7111,11 @@ RectTransform:
m_Father
:
{
fileID
:
1147557151012020857
}
m_RootOrder
:
-1
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_AnchorMin
:
{
x
:
0.5
,
y
:
0.5
}
m_AnchorMax
:
{
x
:
0.5
,
y
:
0.5
}
m_AnchorMin
:
{
x
:
0.5
,
y
:
1
}
m_AnchorMax
:
{
x
:
0.5
,
y
:
1
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
0
}
m_SizeDelta
:
{
x
:
0
,
y
:
0
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
m_SizeDelta
:
{
x
:
750
,
y
:
1274
}
m_Pivot
:
{
x
:
0.5
,
y
:
1
}
---
!u!1
&7432927552733396289
GameObject
:
m_ObjectHideFlags
:
0
...
...
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