I need help about object defination.
My click code:
using System.Collections; using UnityEngine; using System.Collections.Generic;
public class Click : MonoBehaviour {
public UnityEngine.UI.Text BPC;
public UnityEngine.UI.Text BoxesDisplay;
public float Boxes = 0f;
public int Boxesperclick = 1;
public object CurrencyConverter { get; private set; }
void Update ()
{
BoxesDisplay.text = "Boxes: " + CurrencyConverter.Instance.GetCurrency
BPC.text = Boxesperclick + " boxes/click";
}
public void Clicked()
{
Boxes += Boxesperclick;
}
}
My CurrencyConverter Code:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CurrencyConverter : MonoBehaviour { private static CurrencyConverter instance; public static CurrencyConverter Instance { get { return instance; } }
void Awake()
{
CreateIntance();
}
void CreateIntance()
{
if (instance == null)
{
instance = this;
}
}
public string GetCurrencyIntoString(float valueToConvert, bool currencyPerSec, bool currencyPerClick)
{
string converted;
if (valueToConvert >= 1000000)
{
converted = (valueToConvert / 1000000f).ToString("f3") + " Mil";
}
else if (valueToConvert >= 1000)
{
converted = (valueToConvert / 1000f).ToString("f3") + " K";
}
else
{
converted = "" + valueToConvert;
}
if (currencyPerSec == true)
{
converted = converted + " BPS ";
}
if (currencyPerClick == true)
{
converted = converted + " BPC";
}
return converted;
}
}
Answer by Vilogrec · Dec 01, 2017 at 01:41 PM
{ BoxesDisplay.text = "Boxes: " + CurrencyConverter.Instance.GetCurrencyIntoString(Boxes, false, false); BPC.text = Boxesperclick + " boxes/click"; }
This is correct one.
Your answer
Follow this Question
Related Questions
My Game not listed with other games. 0 Answers
Can you change fillAmount to a float value? 0 Answers
Why does my item change its cost to 1 whenever i buy it? 0 Answers
stopping the game and show an animation to user for the points 1 Answer
How to create a 2D slot game in unity step wise step as same as in jetpack joyride? -2 Answers