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 WinterstoneStudios · Jan 11, 2016 at 06:29 AM · variablesif-statementssystemquestrpg-game

Unity quest system a better way?

Hello here is my code it is many variables and if-statments. I wondered if it were a better way of doing it. It is getting hard to have that type of system and find things with many variables and if-statments. Hope you can help :)

 #pragma strict
 
 public var text : String = "";
 public var text2 : String = "";
 public var text3 : String = "";
 public var text4 : String = "";
 
 public static var SpidersKilled : int;
 public static var Crates : int;
 public static var BanditsKilled : int;
 public static var Empty2 : int;
 
 public static var PosText1 : int = 140;
 public static var PosText2 : int = 240;
 public static var PosText3 : int = 340;
 public static var PosText4 : int = 440;
 
 public static var HasDoneQuest1 : boolean = false;
 public static var HasDoneQuest2 : boolean = false;
 public static var HasDoneQuest3 : boolean = false;
 public static var HasDoneQuest4 : boolean = false;
 
 public static var Ree1 : boolean = false;
 public static var Ree2 : boolean = false;
 public static var Ree3 : boolean = false;
 
 public static var QuestActive1 : boolean = false;
 public static var QuestActive2 : boolean = false;
 public static var QuestActive3 : boolean = false;
 public static var QuestActive4 : boolean = false;
 
 function Update ()
 {
 if(HasDoneQuest1 == true && Ree1 == false)
 {
 PosText2 -= 100;
 PosText3 -= 100;
 PosText4 -= 100;
 Ree1 = true;
 }
 
 if(HasDoneQuest2 == true && Ree2 == false)
 {
 PosText3 -= 100;
 PosText4 -= 100;
 Ree2 = true;
 }
 
 if(HasDoneQuest3 == true && Ree3 == false)
 {
 
 PosText4 -= 100;
 Ree3 = true;
 }
 
 //Quest 1
 if(QuestActive1 == true)
 {
 text = "Economic trouble: Hello, the spiders in the mine prevent us from gather the riches. Without it our economy is ruined, could you kill 4 spiders? Spiders killed: " + SpidersKilled;
 }
 
 //Quest 2
 if(QuestActive2 == true)
 {
 text2 = "The robbery: Last night some bandits came and robbed the food storage, could you get the 4 crates of food back? Crates" + Crates;
 }
 
 //Quest 3
 if(QuestActive3 == true)
 {
 text3 = "The bandits in the woods:" + BanditsKilled;
 }
 
 //Quest 4
 if(QuestActive4 == true)
 {
 text4 = "" + SpidersKilled;
 }
 
 //Quest done 1
 if(QuestActive1 == false)
 {
 text = "";
 }
 
 //Quest done 2
 if(QuestActive2 == false)
 {
 text2 = "";
 }
 
 //Quest done 3
 if(QuestActive3 == false)
 {
 text3 = "";
 
 }
 
 //Quest done 4
 if(QuestActive4 == false)
 {
 text4 = "";
 }
 }
 
 function OnGUI ()
 {
 if(Input.GetKey(KeyCode.Tab))
 {
 GUI.Box(Rect (10,140,400,360),"");
 GUI.Label (Rect (10,PosText1,400,360), "" + text);
 GUI.Label (Rect (10,PosText2,400,360), "" + text2);
 GUI.Label (Rect (10,PosText3,400,360), "" + text3);
 GUI.Label (Rect (10,PosText4,400,360), "" + text4);
 }
 
 }

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by WinterstoneStudios · Jan 20, 2016 at 07:06 PM

I tried using Arrays and inheritance, but i got a error that says it don't got a visible constructor that matches the arguement list String[] The error is in the script "QuestLager". Here is the code:

pragma strict

public class QuestFabrikk { public var Quests : String[]; public var Booleans : Boolean[]; public var Ints : int[]; public var Position : int[];

 public function Quest()
 {
     Quests[0] = "";
     Debug.Log("1st Fruit Constructor Called");
 }
 
     //This is the second constructor for the Fruit class
     //and is not inherited by any derived classes.
 public function Quest(newQuests : String[])
     {
         Quests = newQuests;
         Debug.Log("2nd Fruit Constructor Called");
     }
 
 public function GetQuest()
 {

     Debug.Log("The fruit has been chopped." + Quests[0] );     
 }
 
 public function SayHello()
 {
     Debug.Log("Hello, I am a fruit.");
 }

     function Start () {

     }

     function Update () {

     }

 }

pragma strict

public var Quests : String[]; var Quest1 = new Quest(Quests[0]);

function Start () {

}

function Update () {

}

Comment
Add comment · Share
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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Problem while using several tags in a OnTriggerEnter (Collider other) 0 Answers

If statement unexpectedly changing value. 0 Answers

Referencing variables in another script on the same game object 0 Answers

Need a object to react different when clicked mutliple times 1 Answer

RaycastHit2D ground detection 1 Answer


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