Hey guys,
today I have been working around this issue like half of a day. I would like to see some comparison between some methods. First I will try to explain you what did I do. I am developing Tower-defense game. Currently I am creating new tower system. My basic vision is this: 1 type of towers - 1 superior script. This script would contain every attribute of every upgrade level. (Sale price, price, range, firerate ...) and single towers (gameobjects) - tower script. This tower script would get attributes from superior script from the first instance of this. E.g. price of the first level. And then if someone press the button Upgrade on the same tower it gets again attributes from superior script but from the second instance. E.g. dmg of second level. I want to spare disk, memory space and performance so I figured out that I have to have one source and general script on every tower that can load everything from source. But I am wondering whats the best solution for this and certainly its not the GetComponent method. Trust me I tried it and it sucks. I figured out how to make it happen with static method and variables of the class in the source (superior script). Basically everytime player wants to build or upgrade the tower then it calls a static method of superior script with index. Next the method will load appropriate (by index) values to static variables. Last the variables of subordinate script will set their values based on static variables.
The question is: Is really neccessary to create a class with static variables or is better to use maybe static two dimensional array. One two-dimension array can represent one type of towers. I mean whats the best solution for this static solution? In comparison with speed, space usage and so on...
Btw. I will share here this tower system once it is done. (I guess in 2 days, I have no time tomorrow so..)
↧