- Home /
Question by
Ashxaqw · Dec 11, 2014 at 01:53 PM ·
c#scripting problemerrormonodevelop
Hey guys, im starting do make a RPG game and in the Level system script(I called it "PlayerStatsController") i have an error: Parser Error : Unexpected symbol `public'. My script above:
using UnityEngine;
using System.Collections;
public class PlayerStatsController : MonoBehaviour {
public static PlayerStatsController intance;
public int xpMultiply = 1;
public float xpFirstLevel = 100;
public float difficultFactor = 1.5f;
// Use this for initialization
void Start () {
intance = this;
DontDestroyOnLoad (gameObject);
Application.LoadLevel ("GamePlay");
}
// Update is called once per frame
void Update () {
}
public static void AddXp(float xpAdd){
float newXp = (GetCurrentXp () + xpAdd) * PlayerStatsController.intance.xpMultiply;
if(newXp >= GetNextXp()){
AddLevel();
newXp = 0;
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);
}
public static float GetNextXp(){
return PlayerStatsController.intance.xpFirstLevel * (GetCurrentLevel () + 1) * PlayerStatsController.intance.difficultFactor;
}
void OnGui(){
GUI.Label (new Rect (0, 0, 200, 50), "Current XP = " + GetCurrentXp ());
GUI.Label (new Rect (0, 15, 200, 50), "Current Level = " + GetCurrentLevel ());
GUI.Label (new Rect (0, 30, 200, 50), "Current Next Xp = " + GetNextXp ());
}
}
Comment
$$anonymous$$aybe it helps when you give the full error ins$$anonymous$$d of a part.
Answer by Baste · Dec 11, 2014 at 02:22 PM
AddXP is missing the right bracket ( } ) at the end of the method.