how to pass on effects from Tech Tree Item unlocks?

Hi all,

As part of my “learning stuff” I’m playing around with implementing a “tech tree” themed loosely on a RTS style game. I’m using UnityScript for now, but I can usually understand/convert from c# if needs be :).

I’ve built a Player gameObject(GO)/script which holds a Resources datatype (which is a basic (int, int, int) structure with overloaded operators) and a coroutine which ticks up the resources each second. The Player GO is parent to a TechTree script/GO which is parent to GOs with attached TechTreeItems scripts. The tree handles the OnGUI for some “unlock” buttons / labels based on the state of each TechTreeItem etc. Each TechTreeItem has it’s own requirements array set from the inspector, it’s own unlock cost in Resources and functions to work out if you can afford to unlock and have the prereqs to unlock each item etc.

All this is working fine :smile:. I can happily watch the resources tick up until the costs are met for each TechTreeItem and unlock them in order of their prereqs etc.

I’ve hit a wall when it comes to giving the TechTreeItems some sort of effect. In this basic example the only effect they can really have is increasing the resource generation rate for the player which could be achieved by having a SendMessage to the Player GO calling an “increaseGen” function with a Resources struct for the parameter, but in a “real” game the TechTreeItems would need to unlock units and unit abilities, change unit stats and all kinds of things as well. So I’m trying to conceptualise a more general system for passing effects from the tech tree to other “things” be that a player’s buildings, units or whatever.

Anyone got any pointers on this one before I jump down the rabbit hole of trying to work out an intermediary “effects” class?

I guess it goes along the lines of this post.

http://forum.unity3d.com/threads/176786-Spell-casting-system-!-Any-ideas

As I said at topic above, model each effect as additive behavior that can be plugged by common interfaces into generic effects manager.
Also search about dispatcher/observer programming pattern for it can help your implementation, mainly about anonymous dispatchers.

ah excellent, knowing the name of the design pattern really helps searches :smile:

Thanks!