Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by raouligen · Jun 24, 2017 at 05:22 AM · methods

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);
 }


}

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image raouligen · Jun 24, 2017 at 03:20 AM 0
Share

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

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

65 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges