473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

dynamically loop through tiers in picturebox control

Samishii23
246 100+
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...
Jun 10 '10 #1
10 2216
GaryTexmo
1,501 Expert 1GB
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...

Expand|Select|Wrap|Line Numbers
  1. public void TalentClick(object sender, TalentClickEventArgs e)
  2. {
  3.   Talent t = sender as Talent;
  4.   if (t != null)
  5.   {
  6.     t.Spent.Increment(e.Increment);
  7.  
  8.     foreach (Talent tChild in t.ChildTalents)
  9.     {
  10.       tChild.Enabled = (t.Spent == t.MaximumPoints);
  11.     }
  12.   }
  13. }
Would something like that work?
Jun 10 '10 #2
Samishii23
246 100+
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...
Expand|Select|Wrap|Line Numbers
  1. function checkEnabled(treeNum) {
  2.     calcTreePts(); // Updates the counters for use...
  3.  
  4.     var tree = talentTrees[treeNum]; // gets the tree object
  5.     for(var talentNum = 0, len = tree.talents.length; talentNum < len; ++talentNum) { // cycle through each talent
  6.  
  7.         var talent = tree.talents[talentNum]; // current talent object
  8.         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
  9.  
  10.         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
  11.             enabled = false;
  12.  
  13.         // (original comment) Dependent talents have special cases
  14.         if(enabled && !checkDependentTalent(talent))
  15.             enabled = false;
  16.  
  17.         if(enabled) {
  18.             enableTalent(talent);
  19.             enableArrows(talent);
  20.  
  21.         } else {
  22.             disableTalent(talent);
  23.             disableArrows(talent);
  24.         }
  25.     }
  26. }
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. =\
Jun 10 '10 #3
GaryTexmo
1,501 Expert 1GB
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#?
Jun 10 '10 #4
Samishii23
246 100+
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.
Jun 10 '10 #5
GaryTexmo
1,501 Expert 1GB
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...

Expand|Select|Wrap|Line Numbers
  1. 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
Jun 10 '10 #6
Samishii23
246 100+
@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
Jun 11 '10 #7
Samishii23
246 100+
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.

Expand|Select|Wrap|Line Numbers
  1. public void HandleChange_TreeCount(object X, EventArgs EX) {
  2.   ToolStripStatusLabel Obj = X as ToolStripStatusLabel;
  3.  
  4.   if (Obj == null)
  5.     return;
  6.  
  7.   int id = s2i(Obj.Name.Substring(4, 1)), // Example Name "Tree1Counter"
  8.       CurPts = s2i(Obj.Text), // .Text property holds the total tree count
  9.       CurTier = (CurPts / 5) + 1, // This defines what Tier the current amount of points would suggest
  10.       TreeStart = (id - 1) * 44, // ID: 0 thru 2, want starting numbers like this: 0, 44, 88
  11.       TreeEnd = (TreeStart + 43);
  12.  
  13.   if (CurTier == 1) // Do nothing if its the 1st tier
  14.     return;
  15.  
  16.   for (int x = TreeStart; x < TreeEnd; x++) {
  17.     bool Enable = false;
  18.  
  19.     // First Tier and Figures out next tier
  20.     if (TD.Tier[x] == 0 && CurPts >= (TD.Tier[x] * 5))
  21.       Enable = true;
  22.  
  23.     if (Enable)
  24.       Talent_Enable(x);
  25.     else
  26.       Talent_Disable(x);
  27.     }
  28.   }
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.
Jun 16 '10 #8
Samishii23
246 100+
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
Jun 16 '10 #9
GaryTexmo
1,501 Expert 1GB
lol :D

Glad you got it figured out!
Jun 16 '10 #10
Samishii23
246 100+
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
Jun 16 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
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")
2
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...
6
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...
4
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....
8
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...
48
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...
7
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...
3
prn
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...
1
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...
1
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"...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.