Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
RockCycleSimulation
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kenzy ahmed fouad
RockCycleSimulation
Commits
b9510b9b
Commit
b9510b9b
authored
Dec 01, 2025
by
KenzyAshour2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
last update for the last scene
parent
c2581977
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
575 additions
and
181 deletions
+575
-181
Scene 11 msg.asset
...DialogueSystem/Dialogues/Test/Dialogue/Scene 11 msg.asset
+1
-1
Floating 2.prefab
Assets/Prefabs/Floating 2.prefab
+165
-0
Floating 2.prefab.meta
Assets/Prefabs/Floating 2.prefab.meta
+7
-0
floating.prefab
Assets/Prefabs/floating.prefab
+29
-2
RockSimulation.unity
Assets/Scenes/RockSimulation.unity
+261
-164
DeepSeaSpawner.cs
Assets/Script/DeepSeaSpawner.cs
+54
-9
FloatingDraggableRock.cs
Assets/Script/FloatingDraggableRock.cs
+57
-5
TagManager.asset
ProjectSettings/TagManager.asset
+1
-0
No files found.
Assets/AL-Arcade/DialogueSystem/Dialogues/Test/Dialogue/Scene 11 msg.asset
View file @
b9510b9b
...
@@ -23,7 +23,7 @@ MonoBehaviour:
...
@@ -23,7 +23,7 @@ MonoBehaviour:
\u0643\u064A\u0641
\u062A\u063A\u064A\u0631
\u0634\u0643\u0644\u064A\u061F
\u0644\u0645
\u0643\u064A\u0641
\u062A\u063A\u064A\u0631
\u0634\u0643\u0644\u064A\u061F
\u0644\u0645
\u0623\u0639\u062F
\u062A\u0644\u0643
\u0627\u0644\u0635\u062E\u0631\u0629
\u0627\u0644\u062E\u0634\u0646\u0629
\u0623\u0639\u062F
\u062A\u0644\u0643
\u0627\u0644\u0635\u062E\u0631\u0629
\u0627\u0644\u062E\u0634\u0646\u0629
\u0627\u0644\u062D\u0627\u062F\u0629\u061B
\u0644\u0642\u062F
\u062C\u0639\u0644\u062A\u0646\u064A
\u0627\u0644\u062D\u0627\u062F\u0629\u061B
\u0644\u0642\u062F
\u062C\u0639\u0644\u062A\u0646\u064A
\u0627\u0644\u0631\u062D\u0644\u0629
\u0646\u0627\u0639\u0645\u0627\u064B
\u0648\u0645\u0633\u062A\u062F\u064A\u0631\u0627\u064B
.
\"\r\n\
r\n\
"\u0633\u0623\u0646\u0627\u0645
\u0627\u0644\u0631\u062D\u0644\u0629
\u0646\u0627\u0639\u0645\u0627\u064B
\u0648\u0645\u0633\u062A\u062F\u064A\u0631\u0627\u064B
.
\"\r\n\"\u0633\u0623\u0646\u0627\u0645
\u0647\u0646\u0627
\u0645\u0639
\u0623\u0635\u062F\u0642\u0627\u0626\u064A
\u0627\u0644\u062D\u0635\u0649
\u0647\u0646\u0627
\u0645\u0639
\u0623\u0635\u062F\u0642\u0627\u0626\u064A
\u0627\u0644\u062D\u0635\u0649
\u0644\u0646\u0643\u0648\u0646
\u0637\u0628\u0642\u0629
\u062C\u062F\u064A\u062F\u0629
\u0644\u0646\u0643\u0648\u0646
\u0637\u0628\u0642\u0629
\u062C\u062F\u064A\u062F\u0629
\u0645\u0646
\u0627\u0644\u0623\u0631\u0636
.
\u0634\u0643\u0631\u0627\u064B
\u0644\u0643\u0645
\u0645\u0646
\u0627\u0644\u0623\u0631\u0636
.
\u0634\u0643\u0631\u0627\u064B
\u0644\u0643\u0645
...
...
Assets/Prefabs/Floating 2.prefab
0 → 100644
View file @
b9510b9b
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!1
&5402467791447101225
GameObject
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
serializedVersion
:
6
m_Component
:
-
component
:
{
fileID
:
4896380137390114607
}
-
component
:
{
fileID
:
8632553811396521187
}
-
component
:
{
fileID
:
1183979416848431580
}
-
component
:
{
fileID
:
-8138534969968993599
}
-
component
:
{
fileID
:
68494390454496024
}
m_Layer
:
0
m_Name
:
Floating 2
m_TagString
:
Rock
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!4
&4896380137390114607
Transform
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
5402467791447101225
}
serializedVersion
:
2
m_LocalRotation
:
{
x
:
-0
,
y
:
-0
,
z
:
-0
,
w
:
1
}
m_LocalPosition
:
{
x
:
-3.1160543
,
y
:
-5.081241
,
z
:
0
}
m_LocalScale
:
{
x
:
0.10360218
,
y
:
0.10360218
,
z
:
0.10360218
}
m_ConstrainProportionsScale
:
0
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!212
&8632553811396521187
SpriteRenderer
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
5402467791447101225
}
m_Enabled
:
1
m_CastShadows
:
0
m_ReceiveShadows
:
0
m_DynamicOccludee
:
1
m_StaticShadowCaster
:
0
m_MotionVectors
:
1
m_LightProbeUsage
:
1
m_ReflectionProbeUsage
:
1
m_RayTracingMode
:
0
m_RayTraceProcedural
:
0
m_RenderingLayerMask
:
1
m_RendererPriority
:
0
m_Materials
:
-
{
fileID
:
2100000
,
guid
:
9dfc825aed78fcd4ba02077103263b40
,
type
:
2
}
m_StaticBatchInfo
:
firstSubMesh
:
0
subMeshCount
:
0
m_StaticBatchRoot
:
{
fileID
:
0
}
m_ProbeAnchor
:
{
fileID
:
0
}
m_LightProbeVolumeOverride
:
{
fileID
:
0
}
m_ScaleInLightmap
:
1
m_ReceiveGI
:
1
m_PreserveUVs
:
0
m_IgnoreNormalsForChartDetection
:
0
m_ImportantGI
:
0
m_StitchLightmapSeams
:
1
m_SelectedEditorRenderState
:
0
m_MinimumChartSize
:
4
m_AutoUVMaxDistance
:
0.5
m_AutoUVMaxAngle
:
89
m_LightmapParameters
:
{
fileID
:
0
}
m_SortingLayerID
:
0
m_SortingLayer
:
0
m_SortingOrder
:
2
m_Sprite
:
{
fileID
:
-225277643
,
guid
:
80c15077b5846b040b22ce10411e9d9a
,
type
:
3
}
m_Color
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
1
}
m_FlipX
:
0
m_FlipY
:
0
m_DrawMode
:
0
m_Size
:
{
x
:
1
,
y
:
1
}
m_AdaptiveModeThreshold
:
0.5
m_SpriteTileMode
:
0
m_WasSpriteAssigned
:
1
m_MaskInteraction
:
0
m_SpriteSortPoint
:
0
---
!u!58
&1183979416848431580
CircleCollider2D
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
5402467791447101225
}
m_Enabled
:
1
m_Density
:
1
m_Material
:
{
fileID
:
0
}
m_IncludeLayers
:
serializedVersion
:
2
m_Bits
:
0
m_ExcludeLayers
:
serializedVersion
:
2
m_Bits
:
0
m_LayerOverridePriority
:
0
m_ForceSendLayers
:
serializedVersion
:
2
m_Bits
:
4294967295
m_ForceReceiveLayers
:
serializedVersion
:
2
m_Bits
:
4294967295
m_ContactCaptureLayers
:
serializedVersion
:
2
m_Bits
:
4294967295
m_CallbackLayers
:
serializedVersion
:
2
m_Bits
:
4294967295
m_IsTrigger
:
0
m_UsedByEffector
:
0
m_UsedByComposite
:
0
m_Offset
:
{
x
:
-0.22
,
y
:
0.01
}
serializedVersion
:
2
m_Radius
:
1.89
---
!u!50
&-8138534969968993599
Rigidbody2D
:
serializedVersion
:
4
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
5402467791447101225
}
m_BodyType
:
1
m_Simulated
:
1
m_UseFullKinematicContacts
:
0
m_UseAutoMass
:
0
m_Mass
:
1
m_LinearDrag
:
0
m_AngularDrag
:
0.05
m_GravityScale
:
1
m_Material
:
{
fileID
:
0
}
m_IncludeLayers
:
serializedVersion
:
2
m_Bits
:
0
m_ExcludeLayers
:
serializedVersion
:
2
m_Bits
:
0
m_Interpolate
:
0
m_SleepingMode
:
1
m_CollisionDetection
:
0
m_Constraints
:
0
---
!u!114
&68494390454496024
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
5402467791447101225
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
6b40841678170634eaef06a08bc443a1
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
floatSpeed
:
1
touchEffectPrefab
:
{
fileID
:
0
}
Assets/Prefabs/Floating 2.prefab.meta
0 → 100644
View file @
b9510b9b
fileFormatVersion: 2
guid: 385871b7bb29c4046ad8d9dea66d0371
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Assets/Prefabs/floating.prefab
View file @
b9510b9b
...
@@ -12,6 +12,7 @@ GameObject:
...
@@ -12,6 +12,7 @@ GameObject:
-
component
:
{
fileID
:
8551629717659174405
}
-
component
:
{
fileID
:
8551629717659174405
}
-
component
:
{
fileID
:
3187258019987708695
}
-
component
:
{
fileID
:
3187258019987708695
}
-
component
:
{
fileID
:
3816263568041903583
}
-
component
:
{
fileID
:
3816263568041903583
}
-
component
:
{
fileID
:
-2207923481999681790
}
m_Layer
:
0
m_Layer
:
0
m_Name
:
floating
m_Name
:
floating
m_TagString
:
Rock
m_TagString
:
Rock
...
@@ -74,7 +75,7 @@ SpriteRenderer:
...
@@ -74,7 +75,7 @@ SpriteRenderer:
m_LightmapParameters
:
{
fileID
:
0
}
m_LightmapParameters
:
{
fileID
:
0
}
m_SortingLayerID
:
0
m_SortingLayerID
:
0
m_SortingLayer
:
0
m_SortingLayer
:
0
m_SortingOrder
:
1
m_SortingOrder
:
2
m_Sprite
:
{
fileID
:
-636720999
,
guid
:
80c15077b5846b040b22ce10411e9d9a
,
type
:
3
}
m_Sprite
:
{
fileID
:
-636720999
,
guid
:
80c15077b5846b040b22ce10411e9d9a
,
type
:
3
}
m_Color
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
1
}
m_Color
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
1
}
m_FlipX
:
0
m_FlipX
:
0
...
@@ -134,4 +135,30 @@ MonoBehaviour:
...
@@ -134,4 +135,30 @@ MonoBehaviour:
m_Name
:
m_Name
:
m_EditorClassIdentifier
:
m_EditorClassIdentifier
:
floatSpeed
:
1
floatSpeed
:
1
floatRange
:
0.5
---
!u!50
&-2207923481999681790
Rigidbody2D
:
serializedVersion
:
4
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
8621037051837905417
}
m_BodyType
:
1
m_Simulated
:
1
m_UseFullKinematicContacts
:
0
m_UseAutoMass
:
0
m_Mass
:
1
m_LinearDrag
:
0
m_AngularDrag
:
0.05
m_GravityScale
:
1
m_Material
:
{
fileID
:
0
}
m_IncludeLayers
:
serializedVersion
:
2
m_Bits
:
0
m_ExcludeLayers
:
serializedVersion
:
2
m_Bits
:
0
m_Interpolate
:
0
m_SleepingMode
:
1
m_CollisionDetection
:
0
m_Constraints
:
0
Assets/Scenes/RockSimulation.unity
View file @
b9510b9b
This diff is collapsed.
Click to expand it.
Assets/Script/DeepSeaSpawner.cs
View file @
b9510b9b
using
UnityEngine
;
using
UnityEngine
;
using
UnityEngine.UI
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
public
class
DeepSeaSpawner
:
MonoBehaviour
public
class
DeepSeaSpawner
:
MonoBehaviour
{
{
[
Header
(
"Game Logic"
)]
public
Button
nextButton
;
public
int
rocksNeededToWin
=
3
;
[
SerializeField
]
GameObject
bubblePrefab
;
private
int
currentPlacedRocks
=
0
;
[
SerializeField
]
Transform
[]
bubbleSpawnPoints
;
[
SerializeField
]
float
bubbleInterval
=
1.5f
;
[
SerializeField
]
GameObject
rockPrefab
;
[
Header
(
"Bubble Settings"
)]
[
SerializeField
]
int
initialRockCount
=
10
;
public
GameObject
bubblePrefab
;
[
SerializeField
]
float
spawnPadding
=
0.5f
;
public
Transform
[]
bubbleSpawnPoints
;
public
float
bubbleInterval
=
1.5f
;
[
Header
(
"Floating Rock Settings"
)]
public
GameObject
[]
rockPrefabs
;
public
int
initialRockCount
=
12
;
public
float
spawnPadding
=
0.5f
;
private
List
<
GameObject
>
spawnedObjects
=
new
List
<
GameObject
>();
private
List
<
GameObject
>
spawnedObjects
=
new
List
<
GameObject
>();
private
Camera
cam
;
private
Camera
cam
;
void
Start
()
void
Start
()
{
{
cam
=
Camera
.
main
;
cam
=
Camera
.
main
;
}
}
void
OnEnable
()
void
OnEnable
()
{
{
if
(
cam
==
null
)
cam
=
Camera
.
main
;
if
(
cam
==
null
)
cam
=
Camera
.
main
;
// Reset the game logic
currentPlacedRocks
=
0
;
// --- THE FIX ---
// We wait 0.1 seconds to make sure we override the ImageSwitcher
Invoke
(
nameof
(
LockButton
),
0.1f
);
// ----------------
SpawnInitialRocks
();
SpawnInitialRocks
();
InvokeRepeating
(
nameof
(
SpawnBubble
),
0f
,
bubbleInterval
);
InvokeRepeating
(
nameof
(
SpawnBubble
),
0f
,
bubbleInterval
);
}
}
void
LockButton
()
{
if
(
nextButton
!=
null
)
{
nextButton
.
interactable
=
false
;
}
}
void
OnDisable
()
void
OnDisable
()
{
{
CancelInvoke
();
CancelInvoke
();
CleanupObjects
();
CleanupObjects
();
}
}
public
void
RockPlaced
()
{
currentPlacedRocks
++;
if
(
currentPlacedRocks
>=
rocksNeededToWin
)
{
if
(
nextButton
!=
null
)
nextButton
.
interactable
=
true
;
Debug
.
Log
(
"Deposition Complete! Next button unlocked."
);
}
}
void
SpawnInitialRocks
()
void
SpawnInitialRocks
()
{
{
Vector2
minScreen
=
cam
.
ViewportToWorldPoint
(
new
Vector3
(
0
,
0
,
0
));
Vector2
minScreen
=
cam
.
ViewportToWorldPoint
(
new
Vector3
(
0
,
0
,
0
));
Vector2
maxScreen
=
cam
.
ViewportToWorldPoint
(
new
Vector3
(
1
,
1
,
0
));
Vector2
maxScreen
=
cam
.
ViewportToWorldPoint
(
new
Vector3
(
1
,
1
,
0
));
float
bottomLimit
=
minScreen
.
y
+
2.0f
;
for
(
int
i
=
0
;
i
<
initialRockCount
;
i
++)
for
(
int
i
=
0
;
i
<
initialRockCount
;
i
++)
{
{
if
(
rockPrefabs
.
Length
==
0
)
return
;
GameObject
randomPrefab
=
rockPrefabs
[
Random
.
Range
(
0
,
rockPrefabs
.
Length
)];
float
randomX
=
Random
.
Range
(
minScreen
.
x
+
spawnPadding
,
maxScreen
.
x
-
spawnPadding
);
float
randomX
=
Random
.
Range
(
minScreen
.
x
+
spawnPadding
,
maxScreen
.
x
-
spawnPadding
);
float
randomY
=
Random
.
Range
(
minScreen
.
y
+
spawnPadding
,
maxScreen
.
y
-
spawnPadding
);
float
randomY
=
Random
.
Range
(
bottomLimit
,
maxScreen
.
y
-
spawnPadding
);
Vector3
spawnPos
=
new
Vector3
(
randomX
,
randomY
,
0
);
Vector3
spawnPos
=
new
Vector3
(
randomX
,
randomY
,
0
);
GameObject
rock
=
Instantiate
(
rockPrefab
,
spawnPos
,
Quaternion
.
identity
);
GameObject
rock
=
Instantiate
(
randomPrefab
,
spawnPos
,
Quaternion
.
identity
);
rock
.
transform
.
SetParent
(
this
.
transform
);
rock
.
transform
.
SetParent
(
this
.
transform
);
spawnedObjects
.
Add
(
rock
);
spawnedObjects
.
Add
(
rock
);
...
...
Assets/Script/FloatingDraggableRock.cs
View file @
b9510b9b
...
@@ -3,26 +3,36 @@ using UnityEngine;
...
@@ -3,26 +3,36 @@ using UnityEngine;
public
class
FloatingDraggableRock
:
MonoBehaviour
public
class
FloatingDraggableRock
:
MonoBehaviour
{
{
[
Header
(
"Floating Settings"
)]
[
Header
(
"Floating Settings"
)]
[
SerializeField
]
float
floatSpeed
=
0.5f
;
public
float
floatSpeed
=
0.5f
;
private
Vector3
targetPos
;
private
Vector3
targetPos
;
private
bool
isDragging
=
false
;
private
bool
isDragging
=
false
;
private
bool
isPlaced
=
false
;
// Is it stuck to the ground?
private
bool
isHoveringGround
=
false
;
// Are we currently over the zone?
private
Vector3
dragOffset
;
private
Vector3
dragOffset
;
private
float
zCoord
;
private
float
zCoord
;
private
Camera
cam
;
private
Camera
cam
;
private
DeepSeaSpawner
mySpawner
;
void
Start
()
void
Start
()
{
{
cam
=
Camera
.
main
;
cam
=
Camera
.
main
;
// Find the spawner so we can tell it when we are placed
mySpawner
=
GetComponentInParent
<
DeepSeaSpawner
>();
PickNewScreenTarget
();
PickNewScreenTarget
();
}
}
void
Update
()
void
Update
()
{
{
// If placed, do nothing (stay stuck)
if
(
isPlaced
)
return
;
if
(!
isDragging
)
if
(!
isDragging
)
{
{
// Move slowly towards the target
transform
.
position
=
Vector3
.
MoveTowards
(
transform
.
position
,
targetPos
,
floatSpeed
*
Time
.
deltaTime
);
transform
.
position
=
Vector3
.
MoveTowards
(
transform
.
position
,
targetPos
,
floatSpeed
*
Time
.
deltaTime
);
if
(
Vector3
.
Distance
(
transform
.
position
,
targetPos
)
<
0.1f
)
if
(
Vector3
.
Distance
(
transform
.
position
,
targetPos
)
<
0.1f
)
{
{
PickNewScreenTarget
();
PickNewScreenTarget
();
...
@@ -32,8 +42,8 @@ public class FloatingDraggableRock : MonoBehaviour
...
@@ -32,8 +42,8 @@ public class FloatingDraggableRock : MonoBehaviour
void
PickNewScreenTarget
()
void
PickNewScreenTarget
()
{
{
// Keep floating targets high up so they don't accidentally float into the ground zone
Vector2
minScreen
=
cam
.
ViewportToWorldPoint
(
new
Vector3
(
0.1f
,
0.
1f
,
0
));
Vector2
minScreen
=
cam
.
ViewportToWorldPoint
(
new
Vector3
(
0.1f
,
0.
3f
,
0
));
// Start 30% up the screen
Vector2
maxScreen
=
cam
.
ViewportToWorldPoint
(
new
Vector3
(
0.9f
,
0.9f
,
0
));
Vector2
maxScreen
=
cam
.
ViewportToWorldPoint
(
new
Vector3
(
0.9f
,
0.9f
,
0
));
float
x
=
Random
.
Range
(
minScreen
.
x
,
maxScreen
.
x
);
float
x
=
Random
.
Range
(
minScreen
.
x
,
maxScreen
.
x
);
...
@@ -44,6 +54,9 @@ public class FloatingDraggableRock : MonoBehaviour
...
@@ -44,6 +54,9 @@ public class FloatingDraggableRock : MonoBehaviour
void
OnMouseDown
()
void
OnMouseDown
()
{
{
// You cannot drag it anymore if it is already placed!
if
(
isPlaced
)
return
;
isDragging
=
true
;
isDragging
=
true
;
zCoord
=
cam
.
WorldToScreenPoint
(
gameObject
.
transform
.
position
).
z
;
zCoord
=
cam
.
WorldToScreenPoint
(
gameObject
.
transform
.
position
).
z
;
dragOffset
=
gameObject
.
transform
.
position
-
GetMouseAsWorldPoint
();
dragOffset
=
gameObject
.
transform
.
position
-
GetMouseAsWorldPoint
();
...
@@ -51,13 +64,34 @@ public class FloatingDraggableRock : MonoBehaviour
...
@@ -51,13 +64,34 @@ public class FloatingDraggableRock : MonoBehaviour
void
OnMouseDrag
()
void
OnMouseDrag
()
{
{
if
(
isPlaced
)
return
;
transform
.
position
=
GetMouseAsWorldPoint
()
+
dragOffset
;
transform
.
position
=
GetMouseAsWorldPoint
()
+
dragOffset
;
}
}
void
OnMouseUp
()
void
OnMouseUp
()
{
{
isDragging
=
false
;
isDragging
=
false
;
PickNewScreenTarget
();
// CHECK: Did we drop it on the ground?
if
(
isHoveringGround
)
{
StickToGround
();
}
else
{
PickNewScreenTarget
();
}
}
void
StickToGround
()
{
isPlaced
=
true
;
// Tell the Spawner we did it
if
(
mySpawner
!=
null
)
{
mySpawner
.
RockPlaced
();
}
}
}
private
Vector3
GetMouseAsWorldPoint
()
private
Vector3
GetMouseAsWorldPoint
()
...
@@ -66,4 +100,22 @@ public class FloatingDraggableRock : MonoBehaviour
...
@@ -66,4 +100,22 @@ public class FloatingDraggableRock : MonoBehaviour
mousePoint
.
z
=
zCoord
;
mousePoint
.
z
=
zCoord
;
return
cam
.
ScreenToWorldPoint
(
mousePoint
);
return
cam
.
ScreenToWorldPoint
(
mousePoint
);
}
}
// --- COLLISION DETECTION ---
void
OnTriggerEnter2D
(
Collider2D
other
)
{
// Make sure your Ground object has the Tag "Ground"
if
(
other
.
CompareTag
(
"Ground"
))
{
isHoveringGround
=
true
;
}
}
void
OnTriggerExit2D
(
Collider2D
other
)
{
if
(
other
.
CompareTag
(
"Ground"
))
{
isHoveringGround
=
false
;
}
}
}
}
\ No newline at end of file
ProjectSettings/TagManager.asset
View file @
b9510b9b
...
@@ -6,6 +6,7 @@ TagManager:
...
@@ -6,6 +6,7 @@ TagManager:
tags
:
tags
:
-
Rock
-
Rock
-
Basket
-
Basket
-
Ground
layers
:
layers
:
-
Default
-
Default
-
TransparentFX
-
TransparentFX
...
...
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