Hi! Cheers for clicking on me ![]()
So I’m really new to C# so this might be a really easy fix but I’m completely stuck, this is the first code I’ve written.
Explanation of the code
Okay so basically this is just a normal clicker game.
The weapon is a variable that ranges from 1 and continues up.
So if Weapon=1 then Weapon then the text should equal Stick and so on. (this is how I use to do it in Python xD)
I know I repeated public int Weapon = 1; (it doesn’t seem to make a difference, it was done to fix an error about script referencing and seemed to fix it)
Okay, any solutions are okay, I just really need some help ![]()
This is WeaponBuy (the button that clicked upgrades the weapon)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class WeaponBuy : MonoBehaviour
{
public int Weapon = 0;
public GameObject textBox;
public GameObject statusBox;
public void ClickaButton()
{
if (Weapon == 0)
{
if (GlobalCash.MoneyAmount < 40)
{
Weapon = 1;
}
else
{
statusBox.GetComponent<Text>().text = "You don't have enough cash!";
statusBox.GetComponent<Animation>().Play("StatusAnim");
}
}
}
}
This is WeaponType (checks what weapon is so it knows what their weapon is eg. stick gun ect. Only stick is in there for now)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class WeaponType : MonoBehaviour
{
public int Weapon = 0;
public GameObject WeaponDisplay;
void Update()
{
if (Weapon == 0)
{
WeaponDisplay.GetComponent<Text>().text = "Stick";
}
}
}
Thank you ![]()