Ok so, I'm trying to make an .exe version of a World of Warcraft system. The Talent builder. I'm hoping that no one points and laughs too much... But anyways, this is the problem I'm having...
Theres 11 tiers of my PictureBox[] Control, 44 total. The 1st tier is "Free" while each subsequent tier needs 5 points into the previous tier to make the next tier available.
Right now I have the intentions of putting this code into a TextChanged() event handler on the total points holder (a Label). And this loop will check each time a point is put in, or taken out, and enable or disable a tier based on the amount of points that are in all of the 11 tiers combined.
I'm having a really hard time figuring you how to make a dynamic loop to be able to do this with out manually code each tier opening up after X points were placed into it...
I know the game is either loved or hated, but I'm learning C# based on this project. So I'm hoping that I can get some help with this loop without any criticism.
Thanks...
10 2216
Hey, as a fellow WoW player I say to heck with the haters! :P Glad to see you're still working on this, actually.
I'm not sure what you mean here though. Why do you need a loop? When you click a certain talent, couldn't you just do the checks there and enable/disable other talents based on that event? Some quick pseudo... - public void TalentClick(object sender, TalentClickEventArgs e)
-
{
-
Talent t = sender as Talent;
-
if (t != null)
-
{
-
t.Spent.Increment(e.Increment);
-
-
foreach (Talent tChild in t.ChildTalents)
-
{
-
tChild.Enabled = (t.Spent == t.MaximumPoints);
-
}
-
}
-
}
Would something like that work?
Well basicly what little theory is actually coming to me is this.
Theres 44 Talents in the tree. So every 4 talents is 1 tier.
Current Tier = (Total Points / 5) + 1
On Change:
- Check Points
- Cycle through current tier and next to see if next tier can be enabled or disabled, based current amount of points.
- enable and disable as needed.
I have the offical code for the website version. But honestly, not sure how to push that to exactly what I'm doing. lol
This is Javascript btw, and i'm adding comments to the areas I understand... - function checkEnabled(treeNum) {
-
calcTreePts(); // Updates the counters for use...
-
-
var tree = talentTrees[treeNum]; // gets the tree object
-
for(var talentNum = 0, len = tree.talents.length; talentNum < len; ++talentNum) { // cycle through each talent
-
-
var talent = tree.talents[talentNum]; // current talent object
-
var enabled = (talent.tier == 0 || tree.pts >= (talent.tier * talentVars.pointsPerTier)); // if first tier is true or current points is more or same as points needed for next tier
-
-
if(enabled && talent.pts == 0 && (talentVars.pts >= talentVars.maxPts || pageMode != "calc")) // if enabled and cur talent has 0 points and (im guessing current total points accross whole calc) is more then allowed total points
-
enabled = false;
-
-
// (original comment) Dependent talents have special cases
-
if(enabled && !checkDependentTalent(talent))
-
enabled = false;
-
-
if(enabled) {
-
enableTalent(talent);
-
enableArrows(talent);
-
-
} else {
-
disableTalent(talent);
-
disableArrows(talent);
-
}
-
}
-
}
I'm sorry. This looks simple, but when I try to put the loop together in my head before in the editor, I go blank. I don't know why. =\
Ah, I misunderstood what you meant by dependency. I was thinking of just the arrows :)
I don't really know web development much, but that loop looks like it updates the whole tree when a point is changed, is that correct?
That loop does seem pretty straight forward... enable a talent if it's tier is less than the total number of points in the tree divided by the points per tier.
Are you not sure how to convert this to C#?
Kinda. The biggest problem is that I want to add checks for if theres only, say for example 10 points. Check up to 3 tiers. I believe thats where I'm starting to over think it and why I'm going blank. lol
I mean pulling 44 loops when clicking on the talent quickly, would probably end up badly.
Well, yes and no... that's not terribly many as far as a computer is concerned, and if you're not doing a lot of work you're probably ok. As for stopping when you have no more talents, just put a break in there when the count is greater than the total number of spent talents.
You don't have to constrain yourself to how they did it though... like I said, this looks like a full refresh. Could you simply update when you click on a specific talent? That's kinda what I was getting at in that pseudo code I posted above.
* Talent was clicked
* Update the talent itself
* Enable/disable any talents above or below as necessary
It could work if your talent array supported it... - List<Talent>[] talents = new List<Talent>[MAX_TIERS]();
?
I'm not trying to tell you to rewrite your code or anything, just throwing out ideas :D
@GaryTexmo
Yea right now, I have the Individual talent counters working. Its enabling the next tier for the counting that is what I'm getting stuck on. I'm pushing some code on the side for it. I'll probably get it posted tomorrow. Have family things to tend to. :P
This is what I came up with. It seems to work. But there is a noticable amount of lag cycling through the whole tree each click. - public void HandleChange_TreeCount(object X, EventArgs EX) {
-
ToolStripStatusLabel Obj = X as ToolStripStatusLabel;
-
-
if (Obj == null)
-
return;
-
-
int id = s2i(Obj.Name.Substring(4, 1)), // Example Name "Tree1Counter"
-
CurPts = s2i(Obj.Text), // .Text property holds the total tree count
-
CurTier = (CurPts / 5) + 1, // This defines what Tier the current amount of points would suggest
-
TreeStart = (id - 1) * 44, // ID: 0 thru 2, want starting numbers like this: 0, 44, 88
-
TreeEnd = (TreeStart + 43);
-
-
if (CurTier == 1) // Do nothing if its the 1st tier
-
return;
-
-
for (int x = TreeStart; x < TreeEnd; x++) {
-
bool Enable = false;
-
-
// First Tier and Figures out next tier
-
if (TD.Tier[x] == 0 && CurPts >= (TD.Tier[x] * 5))
-
Enable = true;
-
-
if (Enable)
-
Talent_Enable(x);
-
else
-
Talent_Disable(x);
-
}
-
}
Now I just need to think about say, stop the loop if maybe it's already enabled, or if just on the 2nd tier in terms of points, just cycle through to the next tier only cut out the extra cpu usage.
Oooook... Apparently I already implemented the Next tier thing without realizing it... Ugh. Sorry to have created a, now, useless thread... lol
The above code has been scrapped... heh
lol :D
Glad you got it figured out!
Apparently I already covered all the points I needed to in my Add Point method, since it already covered all the Talents anyways, it was fine without me knowing it.
Now the only thing I have to do is, basicly do the same thing but now figure out not "Enabling" the next tier. Its the doing an image swap. Which I had already put into use, but it doesn't seem to work.
Woo. lol. Thanks for the support Gary
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nathan Bullock |
last post by:
Okay I have two files:
a.py:
-----
class cla_a(object): pass
class cla_c(object): pass
if __name__ == "__main__":
mod = __import__("b")
|
by: Chad |
last post by:
I am trying to burn copies of our website on CDROM's and
having problems because the ASP's cannot work without the
existance of a server that supports ASP's.
Does anyone have a suggestion or know...
|
by: jonefer |
last post by:
It seems that the following code should work - (if not why is the event there?)
(Do I need some sort of client side script to awaken it?)
Private Sub chkRefresh_CheckedChanged(ByVal sender As...
|
by: jgill |
last post by:
Having problem with the following HTML code in IE7, everything works fine in IE6:
<option value='215001' label='250000,15,10,1'>215001 |A.J. Longo & Associates</option>
In IE6 I see “215001 |A.J....
|
by: Jarekb |
last post by:
I've been searching around for a bit and can't find a solution to this problem. I've got a subform that show a list of requests that need to be processed in datasheet view. One of the fields on the...
|
by: Nathan Sokalski |
last post by:
Ever since I found out that they didn't give us a way to install both IE6
and IE7 on the same machine, I have been more frustrated and annoyed with
Microsoft than I ever have been with any company...
|
by: themastertaylor |
last post by:
Hi, I work for a construction company and part of my job is sourcing
materials. currently we have a spreadsheet based system whereby each
site has a worksheet in the workbook with the standard...
|
by: prn |
last post by:
Hi folks,
I've got something that's driving me crazy here. If you don't want to read a long explanation, this is not the post for you.
My problematic Access app is a DB for keeping track of...
|
by: okonita |
last post by:
Hello all,
I have a Java problem that I hope can be answered here. Very new to DB2 UDB and UDF (we are on DB2v9.5, Linux and Windows), I have managed to get the UDF registered but having problem...
|
by: ced69 |
last post by:
having trouble getting marquee to work get object required errors
tring t <title>This Month at the Chamberlain Civic Center</title>
<link href="styles.css" rel="stylesheet"...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |