Commit e8e4f392 authored by KenzyAshour2's avatar KenzyAshour2

added a scorepanel and a score manager script and a openthepanel script

parent 28d169be
......@@ -3,7 +3,7 @@ guid: 44cdafe20c28a4276a8ef25566bab908
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
......@@ -49,7 +49,7 @@ TextureImporter:
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 26, y: 0, z: 26, w: 0}
spriteBorder: {x: 24, y: 24, z: 24, w: 24}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
......@@ -77,6 +77,7 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
......@@ -89,6 +90,33 @@ TextureImporter:
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:
......
This diff is collapsed.
fileFormatVersion: 2
guid: 3af5d86d0a690f14ebaabc9eec30110a
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:
This diff is collapsed.
......@@ -15,6 +15,7 @@ public class ImageSwitcher : MonoBehaviour
private int currentIndex = 0;
[SerializeField] string[] gameobjectives;
void Start()
{
if (pictures.Length > 0)
......@@ -27,15 +28,8 @@ public class ImageSwitcher : MonoBehaviour
pictures[0].SetActive(true);
currentIndex = 0;
}
if (restartButton != null)
{
restartButton.gameObject.SetActive(false);
}
if (nextButton != null)
{
nextButton.gameObject.SetActive(true);
}
if (restartButton != null) restartButton.gameObject.SetActive(false);
if (nextButton != null) nextButton.gameObject.SetActive(true);
}
public void NextPicture()
......@@ -44,25 +38,40 @@ public class ImageSwitcher : MonoBehaviour
pictures[currentIndex].SetActive(false);
currentIndex++;
if (currentIndex >= pictures.Length)
{
currentIndex = pictures.Length - 1;
}
pictures[currentIndex].SetActive(true);
// Check for GameContextBuilder to avoid errors if missing
if (GameContextBuilder.Instance != null && currentIndex < gameobjectives.Length)
{
GameContextBuilder.Instance.SetCurrentObjective(gameobjectives[currentIndex]);
}
if (currentIndex == pictures.Length - 1)
{
if (nextButton != null) nextButton.interactable = false;
if (restartButton != null) restartButton.gameObject.SetActive(true);
ScorePanel endScreen = FindObjectOfType<ScorePanel>();
if (endScreen != null)
{
endScreen.TriggerEndSequence();
}
else
{
Debug.LogWarning("Cannot find ScorePanel script in the scene!");
}
}
}
public void RestartGame()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
\ No newline at end of file
using UnityEngine;
public class ScoreManager : MonoBehaviour
{
public static ScoreManager Instance;
[SerializeField] int currentScore = 0;
void Awake()
{
if (Instance == null)
Instance = this;
else
Destroy(gameObject);
}
public void AddScore(int amount)
{
currentScore += amount;
}
public void CalculateFinalScore()
{
//mesh 3arfa a-calculate el score ezay
currentScore = 85;
Debug.Log("Score Calculated: " + currentScore);
}
public int GetScore()
{
return currentScore;
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 2106376e289b6b04cb960b4525779dab
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System.Collections;
public class ScorePanel : MonoBehaviour
{
[SerializeField] GameObject endPanel;
[SerializeField] TextMeshProUGUI scoreText;
[SerializeField] float delayDuration = 7.0f;
void Start()
{
// Safety: Force the panel to hide when the game starts
if (endPanel != null)
{
endPanel.SetActive(false);
}
}
public void TriggerEndSequence()
{
StartCoroutine(WaitAndShowPanel());
}
private IEnumerator WaitAndShowPanel()
{
Debug.Log("Simulation finished. Waiting for " + delayDuration + " seconds...");
ScoreManager.Instance.CalculateFinalScore();
yield return new WaitForSeconds(delayDuration);
int finalScore = ScoreManager.Instance.GetScore();
scoreText.text = finalScore.ToString();
endPanel.SetActive(true);
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: fbf33f5e54b957e448b2850339fda288
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 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