Commit c2581977 authored by KenzyAshour2's avatar KenzyAshour2

did the rock particle system added the replay button

parent fcf61210
This source diff could not be displayed because it is too large. You can view the blob instead.
fileFormatVersion: 2
guid: 2c01b18b37e4b314db11b69373af98b2
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This source diff could not be displayed because it is too large. You can view the blob instead.
fileFormatVersion: 2
guid: d9ba27a385cd28d4e9e0b2b78fc0598c
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
...@@ -10,7 +10,6 @@ GameObject: ...@@ -10,7 +10,6 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 6487795819855637101} - component: {fileID: 6487795819855637101}
- component: {fileID: 8551629717659174405} - component: {fileID: 8551629717659174405}
- component: {fileID: 7826709417781551847}
- component: {fileID: 7581605642125399447} - component: {fileID: 7581605642125399447}
m_Layer: 0 m_Layer: 0
m_Name: Spwaner2 m_Name: Spwaner2
...@@ -86,19 +85,6 @@ SpriteRenderer: ...@@ -86,19 +85,6 @@ SpriteRenderer:
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 1
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!114 &7826709417781551847
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8621037051837905417}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a988a7abe4883994ea526b4fb710800b, type: 3}
m_Name:
m_EditorClassIdentifier:
gravityscale: 0.2
--- !u!58 &7581605642125399447 --- !u!58 &7581605642125399447
CircleCollider2D: CircleCollider2D:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -10,7 +10,6 @@ GameObject: ...@@ -10,7 +10,6 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 6487795819855637101} - component: {fileID: 6487795819855637101}
- component: {fileID: 8551629717659174405} - component: {fileID: 8551629717659174405}
- component: {fileID: 7826709417781551847}
- component: {fileID: 7581605642125399447} - component: {fileID: 7581605642125399447}
m_Layer: 0 m_Layer: 0
m_Name: spawner m_Name: spawner
...@@ -29,7 +28,7 @@ Transform: ...@@ -29,7 +28,7 @@ Transform:
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3.93, y: -0.0374, z: 0} m_LocalPosition: {x: -3.93, y: -0.0374, z: 0}
m_LocalScale: {x: 0.5432894, y: 0.5432894, z: 0.5432894} m_LocalScale: {x: 0.54328936, y: 0.54328936, z: 0.54328936}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
...@@ -86,19 +85,6 @@ SpriteRenderer: ...@@ -86,19 +85,6 @@ SpriteRenderer:
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 1
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!114 &7826709417781551847
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8621037051837905417}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a988a7abe4883994ea526b4fb710800b, type: 3}
m_Name:
m_EditorClassIdentifier:
gravityscale: 0.2
--- !u!58 &7581605642125399447 --- !u!58 &7581605642125399447
CircleCollider2D: CircleCollider2D:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
This diff is collapsed.
...@@ -4,17 +4,19 @@ using System.Collections; ...@@ -4,17 +4,19 @@ using System.Collections;
public class CrackableRock : MonoBehaviour public class CrackableRock : MonoBehaviour
{ {
[SerializeField] Sprite[] crackSprites; [SerializeField] Sprite[] crackSprites;
[SerializeField] Button nextButton; [SerializeField] Button nextButton;
private float moveSpeed = 5f;
[SerializeField] float moveSpeed = 5f;
[SerializeField] Vector2 startOffset = new Vector2(-5f, 10f); [SerializeField] Vector2 startOffset = new Vector2(-5f, 10f);
[SerializeField] float rotationSpeed = 360f; [SerializeField] float rotationSpeed = 360f;
[SerializeField] float shakeDuration = 0.1f; [SerializeField] float shakeDuration = 0.1f;
[SerializeField] float shakeMagnitude = 0.1f; [SerializeField] float shakeMagnitude = 0.1f;
[SerializeField] GameObject hitEffectPrefab;
[SerializeField] float effectDuration = 1.0f;
private int currentClickCount = 0; private int currentClickCount = 0;
private SpriteRenderer spriteRenderer; private SpriteRenderer spriteRenderer;
private Vector3 targetPosition; private Vector3 targetPosition;
...@@ -40,15 +42,12 @@ public class CrackableRock : MonoBehaviour ...@@ -40,15 +42,12 @@ public class CrackableRock : MonoBehaviour
{ {
if (!canClick) if (!canClick)
{ {
transform.position = Vector3.MoveTowards(transform.position, targetPosition, moveSpeed * Time.deltaTime); transform.position = Vector3.MoveTowards(transform.position, targetPosition, moveSpeed * Time.deltaTime);
transform.Rotate(Vector3.forward * rotationSpeed * Time.deltaTime); transform.Rotate(Vector3.forward * rotationSpeed * Time.deltaTime);
if (Vector3.Distance(transform.position, targetPosition) < 0.01f) if (Vector3.Distance(transform.position, targetPosition) < 0.01f)
{ {
transform.position = targetPosition; transform.position = targetPosition;
transform.rotation = Quaternion.identity; transform.rotation = Quaternion.identity;
canClick = true; canClick = true;
} }
} }
...@@ -58,6 +57,12 @@ public class CrackableRock : MonoBehaviour ...@@ -58,6 +57,12 @@ public class CrackableRock : MonoBehaviour
{ {
if (!canClick) return; if (!canClick) return;
if (hitEffectPrefab != null)
{
GameObject effect = Instantiate(hitEffectPrefab, transform.position, Quaternion.identity);
Destroy(effect, effectDuration);
}
StartCoroutine(ShakeRock()); StartCoroutine(ShakeRock());
currentClickCount++; currentClickCount++;
...@@ -98,6 +103,14 @@ public class CrackableRock : MonoBehaviour ...@@ -98,6 +103,14 @@ public class CrackableRock : MonoBehaviour
{ {
if (nextButton != null) if (nextButton != null)
nextButton.interactable = true; nextButton.interactable = true;
if (hitEffectPrefab != null)
{
GameObject finalEffect = Instantiate(hitEffectPrefab, transform.position, Quaternion.identity);
Destroy(finalEffect, effectDuration);
}
gameObject.SetActive(false); gameObject.SetActive(false);
} }
} }
\ No newline at end of file
...@@ -4,12 +4,19 @@ using UnityEngine; ...@@ -4,12 +4,19 @@ using UnityEngine;
public class DestroyMountain : MonoBehaviour public class DestroyMountain : MonoBehaviour
{ {
[Header("Spawning Settings")]
[SerializeField] Transform[] spawnPoints;
[SerializeField] GameObject rockDebrisPrefab; [Header("Physical Rock")]
[SerializeField] Transform[] spawnPoints; [SerializeField] GameObject rockDebrisPrefab; // The heavy falling rock object
[Header("Visual Effects")]
[SerializeField] GameObject dustEffectPrefab; // <-- DRAG YOUR PARTICLE PREFAB HERE
[SerializeField] float effectDuration = 1.0f; // How long the dust lasts
private float minForce = 1f; private float minForce = 1f;
private float maxForce = 3f; private float maxForce = 3f;
void OnMouseDown() void OnMouseDown()
{ {
SpawnDebris(); SpawnDebris();
...@@ -17,23 +24,34 @@ public class DestroyMountain : MonoBehaviour ...@@ -17,23 +24,34 @@ public class DestroyMountain : MonoBehaviour
void SpawnDebris() void SpawnDebris()
{ {
if (rockDebrisPrefab == null) return;
foreach (Transform point in spawnPoints) foreach (Transform point in spawnPoints)
{ {
// --- 1. Spawn the Visual Particle Effect ---
if (dustEffectPrefab != null)
{
GameObject dust = Instantiate(dustEffectPrefab, point.position, Quaternion.identity);
// Clean up the particle system after it finishes
Destroy(dust, effectDuration);
}
GameObject rock = Instantiate(rockDebrisPrefab, point.position, Quaternion.identity); // --- 2. Spawn the Physical Rock (Your original code) ---
rock.transform.SetParent(this.transform); if (rockDebrisPrefab != null)
Rigidbody2D rb = rock.GetComponent<Rigidbody2D>();
if (rb != null)
{ {
float direction = (point.position.x < transform.position.x) ? -1f : 1f; GameObject rock = Instantiate(rockDebrisPrefab, point.position, Quaternion.identity);
// Optional: Don't parent physical rocks to the mountain if you want them to fall free
rock.transform.SetParent(this.transform);
Rigidbody2D rb = rock.GetComponent<Rigidbody2D>();
if (rb != null)
{
float direction = (point.position.x < transform.position.x) ? -1f : 1f;
Vector2 force = new Vector2(direction * Random.Range(minForce, maxForce), Random.Range(1f, 3f)); Vector2 force = new Vector2(direction * Random.Range(minForce, maxForce), Random.Range(1f, 3f));
rb.AddForce(force, ForceMode2D.Impulse); rb.AddForce(force, ForceMode2D.Impulse);
rb.AddTorque(Random.Range(-90f, 90f)); rb.AddTorque(Random.Range(-90f, 90f));
}
} }
} }
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class ImageSwitcher : MonoBehaviour public class ImageSwitcher : MonoBehaviour
{ {
[Header("Pictures")]
public GameObject[] pictures; public GameObject[] pictures;
[Header("Buttons")]
public Button nextButton;
public Button restartButton;
private int currentIndex = 0; private int currentIndex = 0;
void Start() void Start()
{ {
if (pictures.Length > 0) if (pictures.Length > 0)
{ {
for (int i = 0; i < pictures.Length; i++) for (int i = 0; i < pictures.Length; i++)
...@@ -18,19 +25,39 @@ public class ImageSwitcher : MonoBehaviour ...@@ -18,19 +25,39 @@ public class ImageSwitcher : MonoBehaviour
pictures[0].SetActive(true); pictures[0].SetActive(true);
currentIndex = 0; currentIndex = 0;
} }
if (restartButton != null)
{
restartButton.gameObject.SetActive(false);
}
if (nextButton != null)
{
nextButton.gameObject.SetActive(true);
}
} }
public void NextPicture() public void NextPicture()
{ {
if (pictures.Length == 0) return; if (pictures.Length == 0) return;
pictures[currentIndex].SetActive(false); pictures[currentIndex].SetActive(false);
currentIndex++; currentIndex++;
if (currentIndex >= pictures.Length) if (currentIndex >= pictures.Length)
{ {
currentIndex = 0; currentIndex = pictures.Length - 1;
} }
pictures[currentIndex].SetActive(true); pictures[currentIndex].SetActive(true);
if (currentIndex == pictures.Length - 1)
{
if (nextButton != null) nextButton.interactable = false;
if (restartButton != null) restartButton.gameObject.SetActive(true);
}
}
public void RestartGame()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
} }
} }
\ No newline at end of file
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-6240883434852827896
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 7
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Dust
m_Shader: {fileID: 211, guid: 0000000000000000f000000000000000, type: 0}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- _ALPHAPREMULTIPLY_ON
m_InvalidKeywords: []
m_LightmapFlags: 0
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses:
- GRABPASS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: b6dcbefea125f2c4394972710a5d1348, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BlendOp: 0
- _BumpScale: 1
- _CameraFadingEnabled: 0
- _CameraFarFadeDistance: 2
- _CameraNearFadeDistance: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _ColorMode: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DistortionBlend: 0.5
- _DistortionEnabled: 0
- _DistortionStrength: 1
- _DistortionStrengthScaled: 0
- _DstBlend: 10
- _DstBlendAlpha: 0
- _EmissionEnabled: 0
- _EnvironmentReflections: 1
- _FlipbookMode: 0
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _LightingEnabled: 0
- _Metallic: 0
- _Mode: 3
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SoftParticlesEnabled: 0
- _SoftParticlesFarFadeDistance: 1
- _SoftParticlesNearFadeDistance: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _ColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
fileFormatVersion: 2
guid: 08780cab1ffe7c44ca036dc8f6f924d3
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b6dcbefea125f2c4394972710a5d1348
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
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