Problem is not reproducible or outdated
How to track variables by reference..
I have an Event system in my game that allows me to add things at certain times in the game - and they popup in an event log on screen.
Things such as:
"Research of xxx complete"
"Production of xxx complete"
"You are under attack"
and so forth.
I now want to add another level, so that an event can be triggered by a variable somewhere else in the game reaching a certain value.
My example in this instance, once a particular Ship has been researched, after 8 days (in game time) a new type of Ship Research becomes available.
My Game Events (GEvent) are structure as follows:
public GEvent(string eTitle, string eContent, float trigger, float triggervalue, TimeSpan delay, bool bPayload)
{
this.eAnnounced = false;
this.eSeen = false;
this.eTitle = eTitle;
this.eContent = eContent;
this.trigger = trigger;
this.triggervalue = triggervalue;
this.delay = delay;
this.bPayload = bPayload;
}
public GEvent(DateTime eTime, string eTitle)
{
this.eTime = eTime;
this.eAnnounced = false;
this.eSeen = false;
this.eTitle = eTitle;
this.eContent = null;
this.added = true;
}
And I am adding an Event to the array as such:
EventsArray.Add(new GEvent(new DateTime(2200, 3, 30, 03, 15, 0, 0), "30th March 03:15 Alert"));
EventsArray.Add(new GEvent(
"Waverider research available",
"Waverider research now available and can be found under Transport in the Research screen.",
Convert.ToUInt32(Colonies.ColoniesArray.Find(x => x.Name.Contains("Moon")).ProductsArray.Find(x => x.pName.Contains("Grazer")).Researched), 1f,
TimeSpan.FromDays(8),
Colonies.ColoniesArray.Find(x => x.Name.Contains("Moon")).ProductsArray.Find(x => x.pName.Contains("Waverider")).rAvailable));}
The first type of event works perfectly.
The second is just storing the current VALUE of the referenced variable (ie .Researched is true if it has been researched.)
So when the Grazer (referenced in the second event) is .Researched==true, it should trigger this event to appear in 8 days and to make the .rAvailable (Research Available) variable on the Waverider also == true.
Because i'll be using various arrays and values throughout the game to trigger events, I need to store a REFERENCE to the variable in the gEvent rather than its value.
Does anybody have any suggestions?
Thanks
Follow this Question
Related Questions
Using a reference for another script in a method issue. 0 Answers
C# Unity dot syntax exercise correct solution? 1 Answer
[SOLVED]bool is getting reset by no reason 2 Answers
¿How can i add a fixed joint configured by script? 0 Answers
How do i change a variable from one Class to another Class? 0 Answers