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
60565d35
Commit
60565d35
authored
Aug 05, 2021
by
LiLiuZhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
abf592aa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
GameController.cs
Assets/Scripts/Controllers/GameController.cs
+2
-0
Fruit.cs
Assets/Scripts/Game/Fruit.cs
+10
-1
TouchPanel.cs
Assets/Scripts/Panel/TouchPanel.cs
+9
-2
No files found.
Assets/Scripts/Controllers/GameController.cs
View file @
60565d35
...
...
@@ -19,6 +19,8 @@ public class GameController : MonoBehaviour
public
Transform
Fruits
;
public
bool
IsGameOver
=
false
;
//准备销毁的水果集合
public
LinkedList
<
GameObject
>
TempList
=
new
LinkedList
<
GameObject
>();
...
...
Assets/Scripts/Game/Fruit.cs
View file @
60565d35
...
...
@@ -37,6 +37,15 @@ public class Fruit : MonoBehaviour
private
void
OnCollisionEnter2D
(
Collision2D
collision
)
{
if
(
GameController
.
GetInstance
().
IsGameOver
)
return
;
if
(
rig2D
.
bodyType
==
RigidbodyType2D
.
Kinematic
)
{
GameController
.
GetInstance
().
IsGameOver
=
true
;
Debug
.
LogError
(
"游戏结束"
);
}
if
(
collision
.
gameObject
.
CompareTag
(
"Bottom"
))
{
if
(!
BottomColiderIsCD
)
...
...
@@ -106,7 +115,7 @@ public class Fruit : MonoBehaviour
Vector2
Velocity
=
gameObject
.
GetComponent
<
Rigidbody2D
>().
velocity
.
magnitude
>
collision
.
gameObject
.
GetComponent
<
Rigidbody2D
>().
velocity
.
magnitude
?
gameObject
.
GetComponent
<
Rigidbody2D
>().
velocity
:
collision
.
gameObject
.
GetComponent
<
Rigidbody2D
>().
velocity
;
Obj
.
GetComponent
<
Fruit
>().
rig2D
=
Obj
.
GetComponent
<
Rigidbody2D
>();
Obj
.
GetComponent
<
Rigidbody2D
>().
velocity
=
Velocity
;
#
region
上报水果合成
...
...
Assets/Scripts/Panel/TouchPanel.cs
View file @
60565d35
using
System
;
#
define
Test
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.EventSystems
;
[RequireComponent(typeof(EventTrigger))]
public
class
TouchPanel
:
BasePanel
{
//相机
public
Camera
cam
;
...
...
@@ -122,8 +126,11 @@ public class TouchPanel : BasePanel
RequestNewFruitType
();
return
;
}
#if Test
int
NowFruitType
=
7
;
#else
int
NowFruitType
=
InstantFruitList
.
Dequeue
();
#endif
NowFruit
=
GameObject
.
Instantiate
(
Resources
.
Load
<
GameObject
>(
"Fruits/"
+
NowFruitType
));
NowFruit
.
name
=
NowFruitType
.
ToString
();
NowFruit
.
transform
.
position
=
new
Vector3
(
0
,
GameController
.
GetInstance
().
RedLinePosY
);
...
...
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