Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

62 saving games exergame #88

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,23 @@ public override void Print()
public class AsianMonkSavingGame : MainSaveObject
{
public int currentLevel;
public float obstacleSpeed; // New variable to store obstacle speed

public AsianMonkSavingGame(int _currentLevel)
public AsianMonkSavingGame(int _currentLevel, float _obstacleSpeed)
{
currentLevel = _currentLevel;
obstacleSpeed = _obstacleSpeed;
GameSaveObjectType = "AsianMonkSavingGame";
}

public override void Print()
{
Debug.Log(primaryKey + " level: " + currentLevel.ToString());
Debug.Log(primaryKey + " level: " + currentLevel.ToString() + " speed: " + obstacleSpeed.ToString());
}
}



[Serializable]

public class FitnessBoxingSavingGame : MainSaveObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
obstaclePrefab: {fileID: 616131786392999559, guid: 3731599bc741b9e47ba67a3d3dd6db98,
type: 3}
spawnInterval: 6
spawnInterval: 2
--- !u!1 &235687209
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -5337,7 +5337,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
obstaclePrefab: {fileID: 1215166025353205516, guid: ab16d0fab5087744f96f8b39c1f65a52,
type: 3}
spawnInterval: 12
spawnInterval: 2
--- !u!1 &1518252112
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -5428,7 +5428,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
obstaclePrefab: {fileID: 1215166025353205516, guid: ab16d0fab5087744f96f8b39c1f65a52,
type: 3}
spawnInterval: 16
spawnInterval: 2
--- !u!1 &1536847528
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -5531,7 +5531,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
obstaclePrefab: {fileID: 1215166025353205516, guid: ab16d0fab5087744f96f8b39c1f65a52,
type: 3}
spawnInterval: 10
spawnInterval: 2
--- !u!1 &1590486410
GameObject:
m_ObjectHideFlags: 0
Expand Down
31 changes: 28 additions & 3 deletions FontanQuest/Assets/Scenes/Exergame/Exergame1/Script/AsianMonkUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
using System.Collections.Generic;
using UnityEngine;


public class AsianMonkUI : MonoBehaviour
{
public Canvas StoryCanvas;
public Canvas StartMenuCanvas;
public Canvas GameCanvas;
public Canvas FinishCanvas;
SaveGameObjects.AsianMonkSavingGame asianMonkSavingGame;
public SaveGameObjects.AsianMonkSavingGame asianMonkSavingGame { get; private set; }



// Start is called before the first frame update
void Start()
Expand All @@ -18,14 +21,15 @@ void Start()
GameCanvas.gameObject.SetActive(false);
FinishCanvas.gameObject.SetActive(false);


// Load Asian Monk game data
asianMonkSavingGame = (SaveGameObjects.AsianMonkSavingGame)SaveGameMechanic.getSaveGameObjectByPrimaryKey(
new SaveGameObjects.AsianMonkSavingGame(0), "AsianMonkSavingGame", 1);
new SaveGameObjects.AsianMonkSavingGame(0, 300.0f), "AsianMonkSavingGame", 1);

if (asianMonkSavingGame == null)
{
// If no saved data is found, create a new instance
asianMonkSavingGame = new SaveGameObjects.AsianMonkSavingGame(0);
asianMonkSavingGame = new SaveGameObjects.AsianMonkSavingGame(0, 300.0f);
}
}

Expand All @@ -46,12 +50,25 @@ public void ChangeToMenu()

public void ChangeToGame()
{
Debug.Log("Changing to GameCanvas"); // Add this line
// Increase level and adjust speed
asianMonkSavingGame.currentLevel++;
asianMonkSavingGame.obstacleSpeed *= 1.2f; // Adjust this value based on your preference

// Save Asian Monk game data
SaveGameMechanic.saveSaveGameObject(asianMonkSavingGame, "AsianMonkSavingGame", asianMonkSavingGame.primaryKey);

// Do not create a new instance here
// asianMonkSavingGame = new SaveGameObjects.AsianMonkSavingGame(asianMonkSavingGame.currentLevel, asianMonkSavingGame.obstacleSpeed);

StoryCanvas.gameObject.SetActive(false);
StartMenuCanvas.gameObject.SetActive(false);
GameCanvas.gameObject.SetActive(true);
FinishCanvas.gameObject.SetActive(false);
}



public void ChangeToComplete()
{
StoryCanvas.gameObject.SetActive(false);
Expand All @@ -60,6 +77,14 @@ public void ChangeToComplete()
FinishCanvas.gameObject.SetActive(true);
}

public void ChangeToStory()
{
StoryCanvas.gameObject.SetActive(true);
StartMenuCanvas.gameObject.SetActive(false);
GameCanvas.gameObject.SetActive(false);
FinishCanvas.gameObject.SetActive(false);
}

public void SaveAsianMonkData()
{
// Save Asian Monk game data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,33 @@

public class ObstacleMovement : MonoBehaviour
{
public float speed = 5f; // Adjust this to control the speed of the obstacle
// public float speed = 1000.0f; // Adjust this to control the speed of the obstacle
SaveGameObjects.AsianMonkSavingGame asianMonkSavingGame;

// Update is called once per frame
void Update()
void Start()
{
Vector3 movement = Vector3.back * speed * Time.deltaTime;
transform.Translate(movement);
// Find the AsianMonkUI script in the scene and get the reference to asianMonkSavingGame
asianMonkSavingGame = FindObjectOfType<AsianMonkUI>().asianMonkSavingGame;

// Alternatively, you can assign the reference through inspector if it's already set there.
// asianMonkSavingGame = GetComponent<AsianMonkUI>().asianMonkSavingGame;

if (asianMonkSavingGame == null)
{
Debug.LogWarning("AsianMonkSavingGame reference not found.");
}
}
}

void Update()
{
if (asianMonkSavingGame != null)
{
Vector3 movement = Vector3.back * asianMonkSavingGame.obstacleSpeed * Time.deltaTime * 1.2f;
transform.Translate(movement);
}
else
{
Debug.LogWarning("AsianMonkSavingGame is not initialized.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void Start()
{
//TimerContainer.SetActive(false);
//countTimerUI.gameObject.SetActive(false);
totalTime = 90f; // Set the total time in seconds (1 minute and 30 seconds)
totalTime = 10f; // Set the total time in seconds (1 minute and 30 seconds)
UpdateTimerUI(totalTime);
}

Expand Down
4 changes: 2 additions & 2 deletions FontanQuest/ProjectSettings/EditorBuildSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ EditorBuildSettings:
path: Assets/Scenes/WorkoutsAndMiniGames(Alisa)/Scenes/MedalOverview.unity
guid: eadc739c053d1864997a4e2915e43598
- enabled: 1
path: Assets/Scenes/Exergame/Minigame-DoodleJump/Scene/DoodleJump.unity
path: Assets/Scenes/Exergame/Minigame-DoodleJump/Scene/GameSceneAndFinishScene/DoodleJump.unity
guid: f094b8d5745d8544285a6306e7a6268f
- enabled: 1
path: Assets/Scenes/Exergame/Minigame-DoodleJump/Scene/DoodleJumpFinishScene.unity
path: Assets/Scenes/Exergame/Minigame-DoodleJump/Scene/GameSceneAndFinishScene/DoodleJumpFinishScene.unity
guid: ee215eecd4b30f744bc539ce475e8204
- enabled: 1
path: Assets/Scenes/Exergame/Minigame-DoodleJump/Scene/DoodleJumpStoryScene.unity
Expand Down