Im working on a card prototype game from a book, and i have just written some code with a Parsing Error i don’t understand…
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
//an Enum to track the possible states of Floating SCore
public enum FSState{
idle,
pre,
active,
post
}
//FloatingScore can move itself on the screen following a bezier curve
public class FloatingScore : MonoBehaviour {
public FSState state = FSState.idle;
[Serialize Field]
private int _score = 0; //the score field
public string scoreString;
//The score property also sets scoreString when set
public int score {
get {
return(_score);
}
set {
_score = value;
scoreString = Utils.AddCommasToNumber(_score);
GetComponent<GUIText>().text = scoreString;
}
}
public List<Vector3> bezierPts; //bezier points for movement
public List<float> fontSizes; // bezier points for font scaling
public float timeStart = -1f;
public float timeDuration = 1f;
public string easingCurve = Easing.InOut; //uses easing in Utils.cs
//the gameobject that will recieve the SendMessage when this is done moving
public GameObject reportFinishTo = null;
//Set up the FloatingScore and Movement
//Note the use of parameter defaults for eTimeS & eTimeD
public void Init(List<Vector3> ePts, float eTimeS = 0, float eTimeD = 1) {
bezierPts = new List<Vector3>(ePts);
if (ePts.Count == 1) { // if there's only one point
//then just go there
transform.position = ePts[0];
return;
}
//If eTimes is the default, just start at the currnt time
if (eTimeS == 0) {eTimeS = Time.time;}
timeStart = eTimeS;
timeDuration = eTimeD;
state = FSState.pre; // set it to the pre state, ready to start moving
}
public void FSCallback(FloatingScore fs){
// When this callback is called by SendMessage,
// add the score from the calling FloatingScore
score += fs.score;
}
void Update(){
//If this is not moving, just return
if (state == FSState.idle) return;
// Get u from the current time and duration
//u ranges from 0 to 1 (usually)
float u = (Time.time - timeStart)/timeDuration;
// Use Easign Class from utils to curve the u value
float uC = Easing.Ease (u, easingCurve);
if (u<0) { // if u<0, then we shouldn't move yet
state = FSState.pre;
//Move to the initial point
transform.position = bezierPts[0];
} else {
if (u>=1){//If u>=1, we're done moving
uC = 1; //set uC=1 so we dont overshoot
state = FSState.post;
if (reportFinishTo != null) { //If there's a callback GameObject
//Use the SendMessage to call the FSCallback method with this as a parameter
reportFinishTo.SendMessage("FSCallback", this);
// Now that the message has been sent
// Destroy this gameObject
Destroy (gameObject);
}else {
//if there is nothing to callback then dont destroy this just let it stay still
state = FSState.idle;
}
} else {
// 0<=u<1, which means that this is active and moving
state = FSState.active;
}
//Use Bezier curve to move this to the right point
Vector3 pos = Utils.Bezier(uC, bezierPts);
tranform.position = pos;
if (fontSizes != null && fontSizes.Count>0){
// If fontSizes has values in it
// ...then adjust the fontSize of thsi GUIText
int size = Mathf.RoundToInt(Utils.Bezier(uC, fontSizes));
GetComponent,GUIText>().fontSize = size;
}
}
}
}
and i’m receiving the error
Assets/__Scripts/FloatingScore.cs(110,1): error CS8025: Parsing error