Hi Guys,
I need help with a Score.
I try to create a Score with 3 different types of Points: 70,100 and 150
Here is the code:
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour {
//public static int score = 0;
public static int score;
public static int highscore;
public int scoreSmall = 70;
public int scoreMid = 100;
public int scoreBig = 150;
static public void AddSeventy() {
score += scoreSmall;
}
static public void AddHundred() {
score += scoreMid;
}
static public void AddHfifty() {
score += scoreBig;
}
static public void AddPoint() {
if (score > highscore){
highscore = score;
}
PlayerPrefs.SetInt ("highscore", highscore);
PlayerPrefs.Save ();
PlayerPrefs.SetInt ("score", score);
PlayerPrefs.Save ();
}
void Start () {
score = PlayerPrefs.GetInt ("score", 0);
//score = 0;
highscore = PlayerPrefs.GetInt("highscore", 0);
}
//void onDestroy() {
//PlayerPrefs.SetInt ("weirdestever", weirdestever);
//PlayerPrefs.Save ();
//}
// Update is called once per frame
void Update () {
guiText.text = "Score: " + score + "
Highscore: " + highscore;
guiText.fontSize = 20;
}
}
And the Second Part (same with 100 and 150):
using UnityEngine;
using System.Collections;
public class Gift70 : MonoBehaviour {
public static int highscore = 0;
public static int score = 0;
void OnTriggerEnter2D (Collider2D col) {
if(col.tag == "Player"){
Score.AddSeventy();
Destroy(gameObject);
}
}
}
Mistake:
Assets/Scripts/Score.cs(15,26): error CS0120: An object reference is required to access non-static member `Score.scoreSmall’
Please help me