Search Unity

Only assignment, call, increment, decrement, await, and new object expressions can be used as a stat

Discussion in 'Scripting' started by BKGamesStudio, Jul 4, 2017.

  1. BKGamesStudio

    BKGamesStudio

    Joined:
    Dec 9, 2016
    Posts:
    12
    Can someone help show me how to fix these errors?
    upload_2017-7-4_17-56-56.png
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine.UI;
    4. using UnityEngine;
    5.  
    6. public class Functions : MonoBehaviour {
    7.  
    8.     public int wins = 0;
    9.     public int RandomValue = 0;
    10.     public int TimesPlayed;
    11.     public int TotalEarnings = 0;
    12.     public float WinAverage = 0;
    13.     public float WinPercentage = 0;
    14.     public Button Button1;
    15.     public Button Button2;
    16.     public Button Button3;
    17.     public Text GamesPlayed;
    18.     public Text WinPercent;
    19.     public Text WinAve;
    20.  
    21.  
    22.     // Use this for initialization
    23.     void Start () {
    24.         GamesPlayed.text = "0";
    25.         WinPercent.text = "0";
    26.         WinAve.text = "0";  
    27.     }
    28.    
    29.     // Update is called once per frame
    30.     void Update () {
    31.        
    32.     }
    33.     public void Play()
    34.     {
    35.         GenerateRandom;
    36.         TimesPlayed;
    37.         PrizeWon;
    38.         CalculateAverages;
    39.         GamesPlayed.text = TimesPlayed.ToString();
    40.         WinPercent.text = WinPercentage.ToString();
    41.         WinAve.text = WinAverage.ToString();
    42.     }
    43.     public void GenerateRandom()
    44.     {
    45.         RandomValue = Random.Range(1,11); //10
    46.     }
    47.     void WonGame()
    48.     {
    49.         wins += 1;
    50.     }
    51.     void GamePlayed()
    52.     {
    53.         TimesPlayed += 1;
    54.     }
    55.     void PrizeWon()
    56.     {
    57.         TotalEarnings += 2;
    58.     }
    59.     void CalculateAverages()
    60.     {
    61.         WinPercentage = wins / TimesPlayed;
    62.         WinAverage = TotalEarnings/TimesPlayed;
    63.     }
    64.        
    65.        
    66. }
    67.  
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    You have things like:
    PrizeWon;
    when you need:
    Code (csharp):
    1.  PrizeWon();
     
    Kiwasi likes this.