method calls
hi guys for some reason i cant do this i cant call the method inside taskonclick any ideas?
using UnityEngine; using System.Collections; using System.Linq; using UnityEngine.UI; using UnityEngine.EventSystems;// Required when using Event data.
public class CivClick2 : MonoBehaviour, IPointerExitHandler// required interface when using the OnPointerExit method. { private static CivClick2 Planet;
public Text CreditdsValue;
public Text AntiMatter;
public Text DihydronicOre;
public GlobalAttributes Global_Attributes;
public GameObject CivilianButt;
public GameObject CivilianButtR;
public int ClickTimes2;
public GameObject InfoBoxCivResearch;
public Text CivResearch;
public Earth CivilianSupport;
public Button yourButton;
public SelectionManager currentlySelectedEarth;
public bool Timer;
public int CivInfoIncreaseX1;
public int CivInfoMax;
public ResourceTier[] resourceTierList;
public GameObject ResearchProgressBar;
//public ProgessBar StartResearching;
public bool ImResearching;
public ProgressBar ShowProgressBar;
//public Player player;
//Do this when the cursor exits the rect area of this selectable UI object.
public void OnPointerExit(PointerEventData eventData)
{
{
CivilianButt.SetActive (true);
CivilianButtR.SetActive (false);
InfoBoxCivResearch.SetActive (false);
}
}
void Update(){
CivResearch.text = ClickTimes2.ToString ();
//Increases PlanetPopulation for Earth
}
void Awake(){
Planet = this;
InfoBoxCivResearch.SetActive (false);
}
void Start()
{
ResourceTier firstAvailable = resourceTierList.FirstOrDefault (x => !x.hasBeenPurchased);
ResearchProgressBar.SetActive (false);
Timer = false;
ClickTimes2 = 0;
CivInfoIncreaseX1 = 0;
CivInfoMax = 2;
Button btn = yourButton.GetComponent<Button>();
btn.onClick.AddListener(TaskOnClick);
}
public static void SelectPlanet(Earth SelectedEarth, ResourceTier firstAvailable){
Planet.CivilianSupport = SelectedEarth;
if (Planet.ClickTimes2 == 0) {
SelectedEarth.PlanetPopulation = 560;
Planet.CreditdsValue.text = "Level 1 550 Credits";
Planet.AntiMatter.text = "Level 1 150 Anti-Matter";
Planet.DihydronicOre.text = "Level 1 150 Anti-Matter";
}
if (Planet.ClickTimes2 == 1) {
//StartResearching.ResearchProgressBar = true;
SelectedEarth.PlanetPopulation = 1120;
Planet.CreditdsValue.text = "Level 2 650 Credits";
Planet.AntiMatter.text = "Level 2 175 Anti-Matter";
Planet.DihydronicOre.text = "Level 2 125 Anti-Matter";
}
if (Planet.ClickTimes2 == 2) {
SelectedEarth.PlanetPopulation = 2240;
Planet.CreditdsValue.text = "Level 3 650 Credits";
Planet.AntiMatter.text = "Level 3 200 Anti-Matter";
Planet.DihydronicOre.text = "Level 3 175 Anti-Matter";
}
if (Planet.ClickTimes2 == 3) {
SelectedEarth.PlanetPopulation = 4480;
Planet.CreditdsValue.text = "Level 4 750 Credits";
Planet.AntiMatter.text = "Level 4 225 Anti-Matter";
Planet.DihydronicOre.text = "Level 4 225 Anti-Matter";
}
if (firstAvailable == null) {
return;
}
if (SelectedEarth.Credits > firstAvailable.CreditRequirement &&
SelectedEarth.Resource1 > firstAvailable.Resource1Requirement &&
SelectedEarth.Resource2 > firstAvailable.Resource2Requirement) {
//CreditdsValue.text = "Level " + ClickTimes2 + " "+ firstAvailable.CreditRequirement.ToString () + " Credits";
// AntiMatter.text = "Level " + ClickTimes2 + " " + firstAvailable.Resource1Requirement.ToString () + " Anti-Matter";
//DihydronicOre.text = "Level " + ClickTimes2 + " " + firstAvailable.Resource2Requirement.ToString () + " Dihydronic Ore";
firstAvailable.hasBeenPurchased = true;
SelectedEarth.Credits = SelectedEarth.Credits - firstAvailable.CreditRequirement;
SelectedEarth.Resource1 = SelectedEarth.Resource1 - firstAvailable.Resource1Requirement;
SelectedEarth.Resource2 = SelectedEarth.Resource2 - firstAvailable.Resource2Requirement;
//ResearchProgressBar.SetActive (true);
//ShowProgressBar.HideProgressBar.SetActive (true);
//ImResearching = true;
//ClickTimes2++;
} else {
//Global_Attributes.RunNoFundsMessage = true;
}
}
public void TaskOnClick ()
{
if (ImResearching == false) {
if (ClickTimes2 == 4) {
Global_Attributes.RunMaxReaseachMessage = true;
}
SelectPlanet(Earth currentlySelectedEarth, Earth resourceTierList);
//ResourceTier firstAvailable = resourceTierList.FirstOrDefault (x => !x.hasBeenPurchased);
}
}
public static void OnMouseDown(Earth SelectedEarth, ResourceTier firstAvailable){
//SelectPlanet (Earth SelectedEarth, ResourceTier firstAvailable);
}
}
Also just so people know i have tried to put all the code inside taskonclick but so far i have not found a way for tasktonclick to hold the method pass's ie earth etc
Your answer
Follow this Question
Related Questions
Calling a method twice in Start without overwriting 0 Answers
About Character moviment methods 0 Answers
Interval of x seconds between two method invokes. 0 Answers
Creating a Scientific notation method 0 Answers
Unity returns InvalidCastException when attempting to run a method from another file 2 Answers