Hello fellow Unity Users!
I have a bit of an abstract question - I do have a sketch of the flow, and I’'l post that as well.
Here goes:
I have a “game” that has non-linear levels. Meaning, the level progression isn’t 1 - 2 - 3 - 4 - etc.
It works like this:
Level one is unlocked (we know this is the ONLY level the user can choose and complete).
Once level one is complete, it unlocks level 2, 3 and 4. This is where it gets tricky:
The User can now choose to complete either 2 or 3 or 4. Once they have completed ANY ONE of those levels, level 5 and 6 become unlocked. Now, there are 2 levels complete (Level 1 + another one) and 4 levels unlocked. The user can now choose any one of the 4 remaining levels. Once they make their choice and complete it, levels 7 and 8 become unlocked. Luckily, my game only has 8 levels, so once levels 7 and 8 become unlocked, it may be easier to keep track of.
Now, in addition to this unlocking of levels, I also want the user to earn a badge for the type of level they have completed. For example, they complete the first level, they earn the Shrink badge. When they complete the next level - if they choose level 4 for example, they’ll earn the Fire badge, but if they choose level 2, they would earn the Fall badge.
My Unity project is laid out like this:
I have what I call a SCENARIOS scene, this is the scene where my level icons are laid out.
Then I have a separate scene for each level. i.e.: a scene for SHRINK (Level 1), one for FIRE (Level 4) etc. there are 8 of these types of Scenes. Each of these scenes are a self-contained game.
Then I have a scene called BADGES - this is where the individual badge icons live once they are earned.
So, if you look at the schematic drawing:
- is the first known level.
- are the 3 choices that get unlocked after the first level is complete. One of these 3 will be completed, then
- are the next 2 choice that get unlocked after the one from 2. is complete. this leaves 4 levels to choose from
- are the next 2 levels to be unlocked, after one of the 4 choices have been completed.
Anyway, I hope that makes sense.
Now, I have been trying to figure this out. LET ME PREFACE: I am NOT a programmer, but Im trying to learn. Please be gentle.
I have tried this:
using UnityEngine;
using System.Collections;
public class GameManager : MonoBehaviour {
// This is The Highlander -- there can be only one.
// This is a singleton object.
private static GameManager instance = null;
private bool completedShrink = false;
private bool completedSlipFall = false;
private int sceneCount = 0;
void Awake()
{
// Implement the singleton pattern
if (instance == null)
{
// This is the first object
instance = this;
DontDestroyOnLoad(gameObject);
Debug.Log("Game Manager Object Singleton has been set");
}
else if (instance != this)
{
// This is not the first instance
Destroy(gameObject);
Debug.Log("Game Manager Object Imposter destroyed");
}
}
public static GameManager Instance
{
get
{
return GameManager.instance;
}
}
public void CompleteShrink()
{
completedShrink = true;
sceneCount++;
Debug.Log("Shrink scene completed, scene count = " + sceneCount.ToString());
}
public void CompleteSlipFall()
{
completedSlipFall = true;
sceneCount++;
Debug.Log("Slip and Fall Prevention scene completed, scene count = " + sceneCount.ToString());
}
public bool IsShrinkComplete()
{
return completedShrink;
}
public bool IsSlipFallComplete()
{
return completedSlipFall;
}
}
This code only shows 2 scenarios, in the effort to be brief. This code is attached to an Empty Game object called GameManagerObject.
Then I have this:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ScenariosUIManager : MonoBehaviour {
public GameObject ShrinkLocked;
public GameObject ShrinkActive;
public GameObject ShrinkAward;
public GameObject SlipFallLocked;
public GameObject SlipFallActive;
public GameObject SlipFallAward;
public GameObject ProductRotationLocked;
public GameObject ProductRotationActive;
public GameObject ProductRotationAward;
public GameObject FireSafetyLocked;
public GameObject FireSafetyActive;
public GameObject FireSafetyAward;
// Use this for initialization
void Start () {
if (GameManager.Instance.IsShrinkComplete() == true)
{
ShrinkActive.SetActive (false);
ShrinkAward.SetActive (true);
SlipFallActive.SetActive (true);
ProductRotationActive.SetActive (true);
FireSafetyActive.SetActive (true);
}
if (GameManager.Instance.IsSlipFallComplete() || GameManager.Instance.IsProductRotationComplete() || GameManager.Instance.IsFireSafetyComplete())
{
ProShopliftingActive.SetActive (true);
ErgonomicsActive.SetActive (true);
}
if (GameManager.Instance.IsSlipFallComplete())
{
SlipFallActive.SetActive (false);
SlipFallAward.SetActive (true);
}
if (GameManager.Instance.IsProductRotationComplete())
{
ProductRotationActive.SetActive (false);
ProductRotationAward.SetActive (true);
}
if (GameManager.Instance.IsFireSafetyComplete())
{
FireSafetyActive.SetActive (false);
FireSafetyAward.SetActive (true);
}
}
// Update is called once per frame
void Update () {
}
}
This was attached to the UI of the Scenarios scene.
Anyway… needless to say: it does;t work… AND I never even addressed the badges.
I feel like I’m close, but as a non-programmer, I feel like I’m stumbling around in the dark. Or perhaps a better analogy is this: I’m trying to write a book in German, but I don’t understand the language, so I’m just typing words on the screen, and hoping they make sentences.
Would anyone care to hold my hand?
Respectfully,
Kimber
@Mavina