using UnityEngine;
using System.Collections;
public class LevelController : MonoBehaviour {
public static LevelController intance;
public int xpMultiply = 1;
public float xpFirstLevel = 100;
public float difficultFactor = 1.5f;
private float xpNextLevel;
// Use this for initialization
void Start () {
intance = this;
DontDestroyOnLoad (gameObject);
Application.LoadLevel("GamePlay");
xpNextLevel = xpFirstLevel * (GetCurrentLevel () + 1) * difficultFactor;
Debug.Log (xpNextLevel);
PlayerPrefs.DeleteAll ();
}
Debug.Log (xpNextLevel);
AddXp(10);
Debug.Log(GetCurrentXp());
}
// Update is called once per frame
void Update () {
}
public static void AddXp(float xpAdd){
float newXp = (PlayerPrefs.GetFloat("currentXp")+xpAdd)*LevelController.intance.xpMultiply;
PlayerPrefs.SetFloat("currentXp", newXp);
}
public static float GetCurrentXp(){
return PlayerPrefs.GetFloat ("currentXp");
}
public static int GetCurrentLevel(){
return PlayerPrefs.GetInt ("currentLevel");
}
public static void AddLevel(){
int newLevel = GetCurrentLevel()+1
PlayerPrefs.SetInt("currentLevel", newLevel);
}
}
and the problem you are having is… ? what?
edit: lines 28-36 aren’t within a function and the closing } on line 37 doesn’t have an opening one… probably something to do with that at a guess…
Thank solved some problems but not all. I will post a picture of errors.
the level system is from a game I am creating with my friends. we are beginners but we intend to finish this game
As suggested in a previous thread, start by doing the tutorials & working through them. Then go back & start adding & changing things in those games. You will learn how to structure & code. The mistake you made here is similar to the one you made previously so please, stop & go do the tutorials.
