473,831 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamically loop through tiers in picturebox control

Samishii23
246 New Member
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 2248
GaryTexmo
1,501 Recognized Expert Top Contributor
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 New Member
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 Recognized Expert Top Contributor
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 New Member
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 Recognized Expert Top Contributor
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 New Member
@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 New Member
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 New Member
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 Recognized Expert Top Contributor
lol :D

Glad you got it figured out!
Jun 16 '10 #10

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

Similar topics

4
3434
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
2136
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 of a way I can make this work? Thanks, Chad
6
1695
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 System.Object, ByVal e As System.EventArgs) Handles chkRefresh.CheckedChanged If chkRefresh.Checked = True Then Me.txtRefreshDate.Text = "" Me.txtRefreshDate.Enabled = False Else Me.txtRefreshDate.Enabled = True
4
2612
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. Longo & Associates” in the drop down list so that the user can make the selection but in IE7 I see '250000,15,10,1' in the drop down list instead of “215001 |A.J. Longo & Associates”. I been trying to figure out why is this happening??? So if someone...
8
3050
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 subform is a status which is a combo box with three choices (pending, withdrawn, processed). The subform shows the requests that have pending in the status field. When someone changes that status to something besides pending I'd like that record to...
48
3357
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 (and for someone who has loved Microsoft as much as me, that takes something pretty bad!). I am a web developer, and only have access to one computer, which makes it hard to test for both IE6 and IE7. But even for people that have access to...
7
1503
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 types of stone in the first column, then across the top we have the main 6 or 7 suppliers and input their price for each material into the grid. I want to develop a system in access basically so that i can search for situations where a supplier...
3
2445
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 software test data. Each instance of a test is associated with a "test case", that is, a test item. Each test instance (or "run") may have a number of other characteristics too, such as browser used, OS (XP, Vista, Linux, Mac OSX, etc.), etc., but for...
1
5995
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 getting the Java code to work. I need assistance to get this Double Metaphone Java UDF to work pretty quickly. Here is what I tried to run and the error message that resulted: SQL select nm_frst, NM_LST,...
1
2691
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" type="text/css" /> <script src="Dunbarlab9.js" type="text/javascript"></script> <script type="text/javascript">
0
9794
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10496
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10538
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5788
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3077
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.