Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
1465 Разработка игрового приложения для демонстрации возможностей VR оборудования
MainProject
Commits
1ba8cf20
Verified
Commit
1ba8cf20
authored
1 year ago
by
Мартинич Андрей Иванович
Browse files
Options
Download
Patches
Plain Diff
Fix
parent
d4fd5d31
master
develop
1 merge request
!5
Merge from develop into master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Assets/Playing room/Scripts/BallThrower.cs
+24
-6
Assets/Playing room/Scripts/BallThrower.cs
with
24 additions
and
6 deletions
+24
-6
Assets/Playing room/Scripts/BallThrower.cs
+
24
−
6
View file @
1ba8cf20
using
System.Collections.Generic
;
using
System
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine
;
using
UnityEngine.UI
;
using
UnityEngine.UI
;
using
TMPro
;
using
TMPro
;
...
@@ -18,6 +19,9 @@ public class BallThrower : MonoBehaviour
...
@@ -18,6 +19,9 @@ public class BallThrower : MonoBehaviour
private
bool
gameOver
=
true
;
private
bool
gameOver
=
true
;
private
float
remainingTime
;
private
float
remainingTime
;
private
GameObject
currentBall
;
private
GameObject
currentBall
;
private
GameObject
ball1
;
private
GameObject
ball2
;
private
GameObject
ball3
;
private
List
<
GameObject
>
goList
=
new
List
<
GameObject
>();
private
List
<
GameObject
>
goList
=
new
List
<
GameObject
>();
private
void
Start
()
private
void
Start
()
...
@@ -32,7 +36,6 @@ private void SpawnBall(Transform h)
...
@@ -32,7 +36,6 @@ private void SpawnBall(Transform h)
{
{
currentBall
=
Instantiate
(
ballPrefab
,
h
.
position
,
Quaternion
.
identity
);
currentBall
=
Instantiate
(
ballPrefab
,
h
.
position
,
Quaternion
.
identity
);
Rigidbody
ballRigidbody
=
currentBall
.
GetComponent
<
Rigidbody
>();
Rigidbody
ballRigidbody
=
currentBall
.
GetComponent
<
Rigidbody
>();
ballRigidbody
.
isKinematic
=
false
;
goList
.
Add
(
currentBall
);
goList
.
Add
(
currentBall
);
currentBall
=
null
;
currentBall
=
null
;
}
}
...
@@ -49,10 +52,10 @@ private void Update()
...
@@ -49,10 +52,10 @@ private void Update()
remainingTime
-=
Time
.
deltaTime
;
remainingTime
-=
Time
.
deltaTime
;
if
(
remainingTime
<=
0
)
if
(
remainingTime
<=
0
)
{
{
foreach
(
GameObject
obj
in
goList
)
DestroyBalls
();
{
//Destroy(ball1);
Destroy
(
obj
);
//
Destroy(
ball2
);
}
//Destroy(ball3);
timerText
.
text
=
"0"
;
timerText
.
text
=
"0"
;
gameOver
=
true
;
gameOver
=
true
;
}
}
...
@@ -62,6 +65,20 @@ private void Update()
...
@@ -62,6 +65,20 @@ private void Update()
}
}
}
}
private
void
DestroyBalls
()
{
try
{
foreach
(
GameObject
obj
in
goList
)
{
Destroy
(
obj
);
}
}
catch
(
Exception
e
)
{
DestroyBalls
();
}
}
public
void
StartGame
()
public
void
StartGame
()
{
{
if
(!
gameOver
)
return
;
if
(!
gameOver
)
return
;
...
@@ -71,6 +88,7 @@ public void StartGame()
...
@@ -71,6 +88,7 @@ public void StartGame()
SpawnBall
(
ballSpawnPos1
);
SpawnBall
(
ballSpawnPos1
);
SpawnBall
(
ballSpawnPos2
);
SpawnBall
(
ballSpawnPos2
);
SpawnBall
(
ballSpawnPos3
);
SpawnBall
(
ballSpawnPos3
);
Debug
.
LogError
(
goList
);
remainingTime
=
startTime
;
remainingTime
=
startTime
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets