Search Unity

Value

Discussion in '2D' started by SEVEN-ARTS, Feb 21, 2021.

  1. SEVEN-ARTS

    SEVEN-ARTS

    Joined:
    Aug 31, 2020
    Posts:
    40
    Hello, I am currently working on a "Cookie Clicker" and I have a problem with this project. and I would like, if I buy a "human" one time, that the value in the script increases (every time I buy another person). Here is the script that gives the player the money after a while:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class Points : MonoBehaviour
    7. {
    8.     public Text PeopleAmount;
    9.     public Text scoreText;
    10.     public float peopleCounter;
    11.     public float scoreAmount;
    12.     public float pointIncreasedPerSecond;
    13.     public float ShopWithDraw;
    14.  
    15.     void Start()
    16.     {
    17.         scoreAmount = 15f;
    18.         pointIncreasedPerSecond = 0.0f;
    19.     }
    20.  
    21.     void Update()
    22.     {
    23.         scoreText.text = "" + (int)scoreAmount;
    24.         scoreAmount += pointIncreasedPerSecond * Time.deltaTime;
    25.  
    26.         if (scoreAmount > PlayerPrefs.GetInt("Highscore"))
    27.         {
    28.             PlayerPrefs.SetInt("Highscore", (int)scoreAmount);
    29.         }
    30.     }
    31.  
    32.     public void WithdrawCurrency()
    33.     {
    34.         if (scoreAmount >= 15)
    35.         {
    36.             Debug.Log("siis0");
    37.             scoreAmount -= 15;
    38.             peopleCounter++;
    39.             PeopleAmount.text = "" + (int)peopleCounter;
    40.         }
    41.     }
    42. }
    43.  
     
  2. SEVEN-ARTS

    SEVEN-ARTS

    Joined:
    Aug 31, 2020
    Posts:
    40
    Couldn't really look for my problem either, because I have no idea what to call it.