Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
M
MusicBigWatermelon
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
王雪伟
MusicBigWatermelon
Commits
ef2cdcb7
Commit
ef2cdcb7
authored
Aug 05, 2021
by
LiLiuZhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
51b15136
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
9 deletions
+79
-9
UIMgr.cs
Assets/FunScripts/UI/UIMgr.cs
+13
-0
RestartPanel.prefab
Assets/Resources/UI/Panel/RestartPanel.prefab
+44
-0
GameController.cs
.../Resources/UI/Panel/Scripts/Controllers/GameController.cs
+11
-0
Fruit.cs
Assets/Resources/UI/Panel/Scripts/Game/Fruit.cs
+4
-2
RestartPanel.cs
Assets/Resources/UI/Panel/Scripts/Panel/RestartPanel.cs
+4
-3
TouchPanel.cs
Assets/Resources/UI/Panel/Scripts/Panel/TouchPanel.cs
+3
-4
No files found.
Assets/FunScripts/UI/UIMgr.cs
View file @
ef2cdcb7
...
...
@@ -183,6 +183,19 @@ public class UIMgr : BaseMgr<UIMgr>
paneldic
.
Remove
(
panelname
);
}
}
public
void
HidePanel
<
T
>(
T
panel
)
where
T
:
BasePanel
{
CheckInit
();
string
panelname
=
typeof
(
T
).
ToString
();
if
(
paneldic
.
ContainsKey
(
panelname
))
{
paneldic
[
panelname
].
OnHide
();
GameObject
.
Destroy
(
paneldic
[
panelname
].
gameObject
);
paneldic
.
Remove
(
panelname
);
}
}
public
T
GetPanel
<
T
>(
bool
ShowError
=
true
)
where
T
:
BasePanel
{
...
...
Assets/Resources/UI/Panel/RestartPanel.prefab
View file @
ef2cdcb7
...
...
@@ -161,6 +161,7 @@ GameObject:
-
component
:
{
fileID
:
3309373071280343784
}
-
component
:
{
fileID
:
3309373071280343786
}
-
component
:
{
fileID
:
3309373071280343787
}
-
component
:
{
fileID
:
1019774784496669404
}
m_Layer
:
5
m_Name
:
BtnRestart
m_TagString
:
Untagged
...
...
@@ -224,6 +225,49 @@ MonoBehaviour:
m_FillOrigin
:
0
m_UseSpriteMesh
:
0
m_PixelsPerUnitMultiplier
:
1
---
!u!114
&1019774784496669404
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
3309373071280343785
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
4e29b1a8efbd4b44bb3f3716e73f07ff
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
m_Navigation
:
m_Mode
:
3
m_SelectOnUp
:
{
fileID
:
0
}
m_SelectOnDown
:
{
fileID
:
0
}
m_SelectOnLeft
:
{
fileID
:
0
}
m_SelectOnRight
:
{
fileID
:
0
}
m_Transition
:
1
m_Colors
:
m_NormalColor
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
1
}
m_HighlightedColor
:
{
r
:
0.9607843
,
g
:
0.9607843
,
b
:
0.9607843
,
a
:
1
}
m_PressedColor
:
{
r
:
0.78431374
,
g
:
0.78431374
,
b
:
0.78431374
,
a
:
1
}
m_SelectedColor
:
{
r
:
0.9607843
,
g
:
0.9607843
,
b
:
0.9607843
,
a
:
1
}
m_DisabledColor
:
{
r
:
0.78431374
,
g
:
0.78431374
,
b
:
0.78431374
,
a
:
0.5019608
}
m_ColorMultiplier
:
1
m_FadeDuration
:
0.1
m_SpriteState
:
m_HighlightedSprite
:
{
fileID
:
0
}
m_PressedSprite
:
{
fileID
:
0
}
m_SelectedSprite
:
{
fileID
:
0
}
m_DisabledSprite
:
{
fileID
:
0
}
m_AnimationTriggers
:
m_NormalTrigger
:
Normal
m_HighlightedTrigger
:
Highlighted
m_PressedTrigger
:
Pressed
m_SelectedTrigger
:
Selected
m_DisabledTrigger
:
Disabled
m_Interactable
:
1
m_TargetGraphic
:
{
fileID
:
3309373071280343787
}
m_OnClick
:
m_PersistentCalls
:
m_Calls
:
[]
---
!u!1
&3309373071677453143
GameObject
:
m_ObjectHideFlags
:
0
...
...
Assets/Resources/UI/Panel/Scripts/Controllers/GameController.cs
View file @
ef2cdcb7
...
...
@@ -13,6 +13,7 @@ public class GameController : MonoBehaviour
GameObject
obj
=
new
GameObject
(
"GameController"
);
Instance
=
obj
.
AddComponent
<
GameController
>();
Instance
.
Fruits
=
new
GameObject
(
"Fruits"
).
transform
;
Instance
.
Fruits
.
position
=
Vector3
.
zero
;
}
return
Instance
;
}
...
...
@@ -27,4 +28,14 @@ public class GameController : MonoBehaviour
//红线高度
public
float
RedLinePosY
=>
ColliderAdapter
.
Instance
.
RedLinePosY
;
public
void
ResetGame
()
{
IsGameOver
=
false
;
for
(
int
i
=
Fruits
.
childCount
-
1
;
i
>=
0
;
i
--)
{
Destroy
(
Fruits
.
GetChild
(
i
).
gameObject
);
}
UIMgr
.
GetInstance
().
GetPanel
<
TouchPanel
>().
SetInstantiateFruit
();
}
}
Assets/Resources/UI/Panel/Scripts/Game/Fruit.cs
View file @
ef2cdcb7
...
...
@@ -43,7 +43,8 @@ public class Fruit : MonoBehaviour
if
(
rig2D
.
bodyType
==
RigidbodyType2D
.
Kinematic
)
{
GameController
.
GetInstance
().
IsGameOver
=
true
;
Debug
.
LogError
(
"游戏结束"
);
UIMgr
.
GetInstance
().
ShowPanel
<
RestartPanel
>(
E_Layer
.
mid
);
//GameController.GetInstance().ResetGame();
}
if
(
collision
.
gameObject
.
CompareTag
(
"Bottom"
))
...
...
@@ -107,7 +108,8 @@ public class Fruit : MonoBehaviour
int
fruitNum
=
int
.
Parse
(
gameObject
.
name
)
+
1
;
string
NewObjName
=
fruitNum
.
ToString
();
GameObject
Obj
=
Instantiate
(
Resources
.
Load
<
GameObject
>(
"Fruits/"
+
NewObjName
),
MidPos
,
Quaternion
.
identity
);
GameObject
Obj
=
Instantiate
(
Resources
.
Load
<
GameObject
>(
"Fruits/"
+
NewObjName
),
GameController
.
GetInstance
().
Fruits
);
Obj
.
transform
.
localPosition
=
MidPos
;
Obj
.
transform
.
localScale
=
new
Vector3
(
0.3f
,
0.3f
,
1
);
Obj
.
name
=
NewObjName
;
...
...
Assets/Resources/UI/Panel/Scripts/Panel/RestartPanel.cs
View file @
ef2cdcb7
...
...
@@ -13,7 +13,8 @@ public class RestartPanel : BasePanel
{
GetControl
<
Button
>(
"BtnRestart"
).
onClick
.
AddListener
(()=>
{
GameController
.
GetInstance
().
ResetGame
();
UIMgr
.
GetInstance
().
HidePanel
(
this
);
});
}
...
...
Assets/Resources/UI/Panel/Scripts/Panel/TouchPanel.cs
View file @
ef2cdcb7
...
...
@@ -10,7 +10,6 @@ using UnityEngine.EventSystems;
[RequireComponent(typeof(EventTrigger))]
public
class
TouchPanel
:
BasePanel
{
//相机
public
Camera
cam
;
...
...
@@ -119,7 +118,7 @@ public class TouchPanel : BasePanel
}
//刷新水果
p
rivate
void
SetInstantiateFruit
()
p
ublic
void
SetInstantiateFruit
()
{
if
(
InstantFruitList
.
Count
==
0
)
{
...
...
@@ -127,11 +126,11 @@ public class TouchPanel : BasePanel
return
;
}
#if Test
int
NowFruitType
=
7
;
int
NowFruitType
=
10
;
#else
int
NowFruitType
=
InstantFruitList
.
Dequeue
();
#endif
NowFruit
=
GameObject
.
Instantiate
(
Resources
.
Load
<
GameObject
>(
"Fruits/"
+
NowFruitType
));
NowFruit
=
GameObject
.
Instantiate
(
Resources
.
Load
<
GameObject
>(
"Fruits/"
+
NowFruitType
)
,
GameController
.
GetInstance
().
Fruits
);
NowFruit
.
name
=
NowFruitType
.
ToString
();
NowFruit
.
transform
.
position
=
new
Vector3
(
0
,
GameController
.
GetInstance
().
RedLinePosY
);
NowFruit
.
transform
.
localScale
=
new
Vector3
(
0.3f
,
0.3f
,
1
);
...
...
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