Commit b9510b9b authored by KenzyAshour2's avatar KenzyAshour2

last update for the last scene

parent c2581977
......@@ -23,7 +23,7 @@ MonoBehaviour:
\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
\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
\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
......
%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}
fileFormatVersion: 2
guid: 385871b7bb29c4046ad8d9dea66d0371
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 8551629717659174405}
- component: {fileID: 3187258019987708695}
- component: {fileID: 3816263568041903583}
- component: {fileID: -2207923481999681790}
m_Layer: 0
m_Name: floating
m_TagString: Rock
......@@ -74,7 +75,7 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 1
m_SortingOrder: 2
m_Sprite: {fileID: -636720999, guid: 80c15077b5846b040b22ce10411e9d9a, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
......@@ -134,4 +135,30 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
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
This diff is collapsed.
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
public class DeepSeaSpawner : MonoBehaviour
{
[Header("Game Logic")]
public Button nextButton;
public int rocksNeededToWin = 3;
[SerializeField] GameObject bubblePrefab;
[SerializeField] Transform[] bubbleSpawnPoints;
[SerializeField] float bubbleInterval = 1.5f;
private int currentPlacedRocks = 0;
[SerializeField] GameObject rockPrefab;
[SerializeField] int initialRockCount = 10;
[SerializeField] float spawnPadding = 0.5f;
[Header("Bubble Settings")]
public GameObject bubblePrefab;
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 Camera cam;
void Start()
{
cam = Camera.main;
}
void OnEnable()
{
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();
InvokeRepeating(nameof(SpawnBubble), 0f, bubbleInterval);
}
void LockButton()
{
if (nextButton != null)
{
nextButton.interactable = false;
}
}
void OnDisable()
{
CancelInvoke();
CleanupObjects();
}
public void RockPlaced()
{
currentPlacedRocks++;
if (currentPlacedRocks >= rocksNeededToWin)
{
if (nextButton != null) nextButton.interactable = true;
Debug.Log("Deposition Complete! Next button unlocked.");
}
}
void SpawnInitialRocks()
{
Vector2 minScreen = cam.ViewportToWorldPoint(new Vector3(0, 0, 0));
Vector2 maxScreen = cam.ViewportToWorldPoint(new Vector3(1, 1, 0));
float bottomLimit = minScreen.y + 2.0f;
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 randomY = Random.Range(minScreen.y + spawnPadding, maxScreen.y - spawnPadding);
float randomY = Random.Range(bottomLimit, maxScreen.y - spawnPadding);
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);
spawnedObjects.Add(rock);
......
......@@ -3,26 +3,36 @@ using UnityEngine;
public class FloatingDraggableRock : MonoBehaviour
{
[Header("Floating Settings")]
[SerializeField] float floatSpeed = 0.5f;
public float floatSpeed = 0.5f;
private Vector3 targetPos;
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 float zCoord;
private Camera cam;
private DeepSeaSpawner mySpawner;
void Start()
{
cam = Camera.main;
// Find the spawner so we can tell it when we are placed
mySpawner = GetComponentInParent<DeepSeaSpawner>();
PickNewScreenTarget();
}
void Update()
{
// If placed, do nothing (stay stuck)
if (isPlaced) return;
if (!isDragging)
{
// Move slowly towards the target
transform.position = Vector3.MoveTowards(transform.position, targetPos, floatSpeed * Time.deltaTime);
if (Vector3.Distance(transform.position, targetPos) < 0.1f)
{
PickNewScreenTarget();
......@@ -32,8 +42,8 @@ public class FloatingDraggableRock : MonoBehaviour
void PickNewScreenTarget()
{
Vector2 minScreen = cam.ViewportToWorldPoint(new Vector3(0.1f, 0.1f, 0));
// Keep floating targets high up so they don't accidentally float into the ground zone
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));
float x = Random.Range(minScreen.x, maxScreen.x);
......@@ -44,6 +54,9 @@ public class FloatingDraggableRock : MonoBehaviour
void OnMouseDown()
{
// You cannot drag it anymore if it is already placed!
if (isPlaced) return;
isDragging = true;
zCoord = cam.WorldToScreenPoint(gameObject.transform.position).z;
dragOffset = gameObject.transform.position - GetMouseAsWorldPoint();
......@@ -51,14 +64,35 @@ public class FloatingDraggableRock : MonoBehaviour
void OnMouseDrag()
{
if (isPlaced) return;
transform.position = GetMouseAsWorldPoint() + dragOffset;
}
void OnMouseUp()
{
isDragging = false;
// 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()
{
......@@ -66,4 +100,22 @@ public class FloatingDraggableRock : MonoBehaviour
mousePoint.z = zCoord;
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
......@@ -6,6 +6,7 @@ TagManager:
tags:
- Rock
- Basket
- Ground
layers:
- Default
- TransparentFX
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment