Hey I have the following Script. Almost Everything is working fine but in Line 87 there is the error-code: “errer CS0201: only assignment call increment decrement and new object expressions can be used as a statement”.
I really don´t know what the problem is. Please help and say what I should make instead. Thx for every answer.
Here the script:
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour
{
public bool isCounting = true;
public float timer = 0f;
public int score = 0;
public int upgradePoints;
public int hiScore;
private GUIStyle guiStyle = new GUIStyle();
public GameObject DethScreen;
public bool showScoreInTheMiddle = false;
public bool takeScore;
public bool scoreIsTakable;
public int requiredPoints;
public bool upgradable;
public bool notEnoughPointsGUI;
public float notEnoughPointsGUIShowCounter;
public bool showGUI;
public bool showHealthOnScreen;
public int healthInThisScript;
void Start()
{
hiScore = PlayerPrefs.GetInt("HighScore");
requiredPoints = PlayerPrefs.GetInt("requiredPoints");
upgradePoints = PlayerPrefs.GetInt("upgradePoints");
scoreIsTakable = true;
takeScore = false;
GameObject kugel = GameObject.Find("Kugel");
KugelCollider kugelCollider = kugel.GetComponent<KugelCollider>();
}
void Update()
{
if (isCounting)
{
timer += Time.deltaTime;
if (timer > 1f)
{
score += 1;
timer -= 1f;
}
}
if (DethScreen.activeInHierarchy)
{
isCounting = false;
takeScore = true;
showHealthOnScreen = true;
}else
{
showHealthOnScreen = false;
}
if (takeScore == true)
{
if (scoreIsTakable == true)
{
upgradePoints = upgradePoints + score;
scoreIsTakable = false;
}
}
//Upgrade Funktion beginnt hier
playerScript.health = healthInThisScript;
if (upgradePoints >= requiredPoints)
{
upgradable = true;
}else
{
upgradable = false;
}
PlayerPrefs.SetInt("requiredPoints", requiredPoints);
PlayerPrefs.SetInt("upgradePoints", upgradePoints);
}
public void upgradeHealthButton()
{
if (upgradable == true)
{
requiredPoints = requiredPoints * 2;
playerScript.healthInThisScript + 10; //HERE IS THE PROBLEME!!!
upgradePoints = upgradePoints - requiredPoints;
}else
{
notEnoughPointsGUI = true;
}
}
void FixedUpdate()
{
if (score > hiScore)
{
hiScore = score;
PlayerPrefs.SetInt("HighScore", hiScore);
}
if (DethScreen.activeInHierarchy)
{
showScoreInTheMiddle = true;
}
//Upgrade Funktion beginnt hier
if (notEnoughPointsGUI == true)
{
notEnoughPointsGUIShowCounter += 1f;
showGUI = true;
notEnoughPointsGUI = false;
}else
{
notEnoughPointsGUIShowCounter = 0;
}
if (notEnoughPointsGUIShowCounter >= 3)
{
showGUI = false;
}
}
void OnGUI()
{
guiStyle.fontSize = 60;
GUI.Label(new Rect(105, 22, 100, 100), score.ToString(), guiStyle);
GUI.Label(new Rect(205, 22, 100, 100), hiScore.ToString(), guiStyle);
if (showScoreInTheMiddle == true)
{
GUI.Label(new Rect(515, 290, 100, 100), score.ToString(), guiStyle);
}
if (showHealthOnScreen == true)
{
GUI.Label(new Rect(105, 22, 100, 100), playerScript.health.ToString(), guiStyle);
GUI.Label(new Rect(105, 22, 100, 100), upgradePoints.ToString(), guiStyle);
}
}
}