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
e269b470
Commit
e269b470
authored
Aug 23, 2023
by
lijin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化初始化速度
parent
4cc2cde9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
90 deletions
+86
-90
GameMgr.cs
Assets/GameMgr/GameMgr.cs
+54
-83
MaskItemMgr.cs
Assets/GameMgr/MaskItemMgr.cs
+31
-5
TextItemMgr.cs
Assets/GameMgr/TextItemMgr.cs
+0
-1
GroupListManager.cs
Assets/scripts/Views/maingame/GroupListManager.cs
+1
-1
No files found.
Assets/GameMgr/GameMgr.cs
View file @
e269b470
...
...
@@ -12,12 +12,21 @@ public class GameMgr : MonoBehaviour
get
{
return
ins
;
}
}
public
MainData
md
;
public
MaskItemMgr
miMgr
;
public
TextItemMgr
tiMgr
;
public
EffectItemMgr
eiMgr
;
public
MainData
md
;
//主数据
public
MaskItemMgr
miMgr
;
//遮罩管理器
public
TextItemMgr
tiMgr
;
//字体管理器
public
EffectItemMgr
eiMgr
;
//特效管理器
public
Texture2D
gray
;
public
Texture2D
gray
;
//遮罩显示图元
void
Update
()
{
Save
();
//自动保存逻辑
Click
();
//点击事件逻辑
Play
();
//涂色重播逻辑
}
//初始化,主逻辑入口
public
void
Init
(
string
key
,
Texture2D
png
,
Sprite
jpg
,
ResJsonData
json
,
DynamicData
dynamic
,
Texture2D
map
)
{
ins
=
this
;
...
...
@@ -25,63 +34,38 @@ public class GameMgr : MonoBehaviour
GetComponent
<
RectTransform
>().
offsetMax
=
Vector2
.
zero
;
GetComponent
<
RectTransform
>().
offsetMin
=
Vector2
.
zero
;
}
public
void
ChooseGroup
(
int
id
)
{
md
.
ChooseGroup
(
id
);
}
//设置遮罩显示图元,优先于Init调用
public
void
SetGray
(
Texture2D
_gray
)
{
gray
=
_gray
;
}
public
static
int
gunSize
=
3
;
void
Update
()
//选组接口,传入组ID
public
void
ChooseGroup
(
int
groupId
)
{
Save
();
//Scale();
Click
();
Play
();
md
.
ChooseGroup
(
groupId
);
}
#
region
缩放
private
Vector2
Pos_1
;
private
Vector2
Pos_2
;
public
void
Scale
()
//重置接口,还原涂色数据
public
void
Clear
()
{
if
(
Input
.
touchCount
==
2
)
{
if
(
Input
.
GetTouch
(
0
).
phase
==
TouchPhase
.
Moved
||
Input
.
GetTouch
(
1
).
phase
==
TouchPhase
.
Moved
)
{
Vector2
n_Pos_1
=
Input
.
GetTouch
(
0
).
position
;
Vector2
n_Pos_2
=
Input
.
GetTouch
(
1
).
position
;
if
(
Vector2
.
Distance
(
Pos_1
,
Pos_2
)
<
Vector2
.
Distance
(
n_Pos_1
,
n_Pos_2
))
{
transform
.
parent
.
localScale
+=
Vector3
.
one
*
0.25f
;
if
(
transform
.
parent
.
localScale
.
x
>
4
)
{
transform
.
parent
.
localScale
=
Vector3
.
one
*
4
;
}
}
else
{
transform
.
parent
.
localScale
-=
Vector3
.
one
*
0.25f
;
if
(
transform
.
parent
.
localScale
.
x
<
0.6f
)
{
transform
.
parent
.
localScale
=
Vector3
.
one
*
0.6f
;
}
}
Pos_1
=
n_Pos_1
;
Pos_2
=
n_Pos_2
;
tiMgr
.
SizeChange
(
transform
.
parent
.
localScale
.
x
);
}
}
md
.
Clear
();
md
.
Init
(
md
.
key
,
md
.
png
,
md
.
jpg
,
md
.
json
,
md
.
dynamic
,
md
.
map
);
}
//重播接口
public
void
RePlay
()
{
md
.
RePlay
();
stepIndex
=
0
;
curTime
=
0
;
}
//辅助涂色接口
public
void
AutoClick
()
{
md
.
AutoClick
();
}
#
endregion
#
region
点击
public
static
readonly
Vector2
gunSize
=
new
Vector2
(
3
,
10
);
private
float
time
=
0
;
private
Vector2
pos
=
Vector2
.
zero
;
private
int
isLongPress
=
-
1
;
//-1无逻辑,0按下,1响应点击,2响应长按
...
...
@@ -131,11 +115,11 @@ public class GameMgr : MonoBehaviour
public
void
UseGun
(
Vector2
v
)
{
List
<
Vector2
>
list
=
new
List
<
Vector2
>();
for
(
int
i
=
0
;
i
<
gunSize
;
i
++)
for
(
int
i
=
0
;
i
<
gunSize
.
x
;
i
++)
{
for
(
int
j
=
0
;
j
<
gunSize
;
j
++)
for
(
int
j
=
0
;
j
<
gunSize
.
x
;
j
++)
{
Vector2
temp
=
new
Vector2
((
int
)
v
.
x
+
(
i
-
gunSize
/
2
)
*
10
,
(
int
)
v
.
y
+
(
j
-
gunSize
/
2
)
*
10
);
Vector2
temp
=
new
Vector2
((
int
)
v
.
x
+
(
i
-
gunSize
.
x
/
2
)
*
gunSize
.
y
,
(
int
)
v
.
y
+
(
j
-
gunSize
.
x
/
2
)
*
gunSize
.
y
);
list
.
Add
(
temp
);
}
}
...
...
@@ -153,11 +137,7 @@ public class GameMgr : MonoBehaviour
}
}
}
public
bool
OnClickPixel
(
float
x
,
float
y
)
{
Vector2
v
=
new
Vector2
(
x
+
md
.
png
.
width
/
2
,
y
+
md
.
png
.
height
/
2
);
return
md
.
OnClickPos
(
v
);
}
//点击由坐标系转图内像素坐标
public
bool
OnClickPixel
(
Vector2
v
)
{
v
.
x
+=
md
.
png
.
width
/
2
;
...
...
@@ -166,24 +146,13 @@ public class GameMgr : MonoBehaviour
}
#
endregion
public
void
Clear
()
{
md
.
Clear
();
md
.
Init
(
md
.
key
,
md
.
png
,
md
.
jpg
,
md
.
json
,
md
.
dynamic
,
md
.
map
);
}
public
void
RePlay
()
{
md
.
RePlay
();
stepIndex
=
0
;
curTime
=
0
;
}
private
int
stepIndex
=
-
1
;
private
readonly
float
delay
=
0.5f
;
private
readonly
float
maxTime
=
0.1f
;
private
float
curTime
=
0
;
public
void
Play
()
#
region
重播逻辑
private
int
stepIndex
=
-
1
;
//重播判断值,-1不处理,0及以上为重播到第几步
private
static
readonly
float
delay
=
0.5f
;
//重播延迟
private
static
readonly
float
maxTime
=
0.1f
;
//重播步间隔
private
float
curTime
=
0
;
//重播当前进行时间
//Update调用判断逻辑
private
void
Play
()
{
if
(
stepIndex
==
-
1
)
{
...
...
@@ -203,12 +172,17 @@ public class GameMgr : MonoBehaviour
}
}
}
public
float
saveTime
=
-
1
;
#
endregion
#
region
保存逻辑
private
float
saveTime
=
-
1
;
//保存判断值,由正变负则保存
//保存接口,点击涂色触发
public
void
SaveTime
()
{
saveTime
=
1.5f
;
}
public
void
Save
()
//Update调用判断逻辑
private
void
Save
()
{
if
(
saveTime
<=
0
)
{
...
...
@@ -224,8 +198,5 @@ public class GameMgr : MonoBehaviour
}
}
}
public
void
AutoClick
()
{
md
.
AutoClick
();
}
#
endregion
}
Assets/GameMgr/MaskItemMgr.cs
View file @
e269b470
...
...
@@ -33,10 +33,11 @@ public class MaskItemMgr : MonoBehaviour
temp
.
gameObject
.
SetActive
(
false
);
}
}
public
void
Create
(
MainData
md
,
ExRoomDatas
erd
,
int
roomId
,
int
groupId
)
public
MaskItem
Create
(
MainData
md
,
ExRoomDatas
erd
,
int
roomId
,
int
groupId
)
{
MaskItem
temp
=
Get
();
temp
.
Init
(
md
,
erd
,
roomId
,
groupId
);
return
temp
;
}
public
void
Play
(
Vector3
v
,
int
id
)
...
...
@@ -53,12 +54,14 @@ public class MaskItemMgr : MonoBehaviour
public
void
Init
(
ResJsonData
rjd
,
DynamicData
dynamic
,
Texture2D
png
)
{
CircleAll
();
float
f
=
png
.
width
*
png
.
height
*
0.01f
;
for
(
int
i
=
0
;
i
<
rjd
.
roomGroupsData
.
Count
;
i
++)
{
RoomGroupsData
rgd
=
rjd
.
roomGroupsData
[
i
];
for
(
int
j
=
0
;
j
<
rgd
.
roomIds
.
Count
;
j
++)
{
RoomDatas
rd
=
rjd
.
roomDatas
[
rgd
.
roomIds
[
j
]];
if
(
rd
.
posIndex
.
Count
>
f
)
//if (!dynamic.step.Contains(rd.id))
{
ExRoomDatas
erd
=
new
ExRoomDatas
();
...
...
@@ -84,16 +87,39 @@ public class MaskItemMgr : MonoBehaviour
{
for
(
int
i
=
0
;
i
<
useList
.
Count
;
i
++)
{
if
(
useList
[
i
].
groupId
==
groupId
)
useList
[
i
].
Hide
();
}
if
(
groupId
!=
-
1
)
{
RoomGroupsData
rgd
=
GameMgr
.
Ins
.
md
.
json
.
roomGroupsData
[
groupId
-
1
];
for
(
int
i
=
0
;
i
<
rgd
.
roomIds
.
Count
;
i
++)
{
useList
[
i
].
Show
();
RoomDatas
rd
=
GameMgr
.
Ins
.
md
.
json
.
roomDatas
[
rgd
.
roomIds
[
i
]];
MaskItem
item
=
IsHave
(
rd
.
id
,
rd
);
if
(!
GameMgr
.
Ins
.
md
.
dynamic
.
step
.
Contains
(
item
.
roomId
))
{
item
.
Show
();
}
}
else
}
}
public
MaskItem
IsHave
(
int
roomId
,
RoomDatas
rd
)
{
for
(
int
j
=
0
;
j
<
useList
.
Count
;
j
++)
{
if
(
useList
[
j
].
roomId
==
roomId
)
{
useList
[
i
].
Hide
()
;
return
useList
[
j
]
;
}
}
ExRoomDatas
erd
=
new
ExRoomDatas
();
for
(
int
k
=
0
;
k
<
rd
.
posIndex
.
Count
;
k
++)
{
erd
.
AddData
(
rd
.
posIndex
[
k
],
GameMgr
.
Ins
.
md
.
png
.
width
);
}
return
Create
(
GameMgr
.
Ins
.
md
,
erd
,
rd
.
id
,
rd
.
groupId
);
}
public
void
Replay
(
int
roomId
=
-
1
)
{
for
(
int
i
=
0
;
i
<
useList
.
Count
;
i
++)
...
...
Assets/GameMgr/TextItemMgr.cs
View file @
e269b470
...
...
@@ -58,7 +58,6 @@ public class TextItemMgr : MonoBehaviour
//if (!dynamic.step.Contains(rd.id))
{
TextItem
temp
=
Get
();
temp
.
gameObject
.
SetActive
(
true
);
temp
.
roomId
=
rd
.
id
;
temp
.
Text
.
fontSize
=
rd
.
pr
;
temp
.
transform
.
localPosition
=
new
Vector3
(
rd
.
px
-
png
.
width
/
2f
,
rd
.
py
-
png
.
height
/
2f
,
0
);
...
...
Assets/scripts/Views/maingame/GroupListManager.cs
View file @
e269b470
...
...
@@ -387,7 +387,7 @@ public class GroupListManager : MonoBehaviour
public
void
Save_Btn
()
{
GameMgr
.
Ins
.
Save
();
//
GameMgr.Ins.Save();
}
public
void
Clear_Btn
()
...
...
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