none
Certain buildings must be constructed to unlock new construction options

    Question

  • Hello all, I am able to disable the comboboxes which was the easy part but I have reached the advanced section: I want to for instance the combo box "tanks" I want disabled and should unlocked depending on what building is constructed in the combobox "building" so I as soon as the player constructs a war factory I receive an indication that the war factory is constructed and I have available construction options. 

    Here is a screenshot of how it looks to provide insight to anyone who can help me answer my question. 


    WRA

    Thursday, April 13, 2017 10:44 AM

Answers

  • Hi

    Without knowing how you have set up various things, I assume you have a set of properties aligned to each player - perhaps a Player Class?

    '

    If you do, then you could have a Property for each player that holds the 'level' of construction that the Player owns - perhaps an integer that corresponds to the list of buildings available. If a player tries to build a Tank and his construction 'level' is not high enough then he fails to build the Tank.

    '

    If you don't have such a Class, then what do you have to hold the different player Properties?


    Regards Les, Livingston, Scotland

    • Marked as answer by Waliur Rahman Thursday, April 13, 2017 6:05 PM
    Thursday, April 13, 2017 12:52 PM
  • Wali, 

    The easiest way to do this kind of thing is to set a variable that keeps track of the stages your game is at. Just like we do in the other thread to determine if the attacker has been selected before selecting the target.

    You can just have lots of global variables like IsWarFactoryCreated.

    When the building is first made you IsWarFactoryCreated.= true

    then in the dialog form load or whatever,

       If IsWarFactoryCreated = true

     makemorefactoriesoption.enabled = true

       else

            makemorefactoriesoption.enabled = false

       End if   


    Need to draw something?

       If IsWarFactoryCreated = true
             draw factory


    You should make a class of all the game control variables. ie

    Public sub MyGameClass

     Public attacksprite as picturebox
     Public IsWarFactoryCreated as boolean
     Public selectedsprite
     Public backgroundimage as bitmap
     Public playeronepoints as integer
     Public playertwopoints as integer
    end sub

    Then you have all your flags collected in one place. You just declare the class in your main form. Then you can pass the flags to other subroutines that are out of scope, ie in other forms. yOu just pass the MyGame class to the routines.

    So a class to group things would be good but not required. You can just leave the variables independent single things if you want. It just makes it easier in the long run to use a class. Plus a class can do a lot more besides save variables which you will learn soon enough when the time is right.

    • Marked as answer by Waliur Rahman Thursday, April 13, 2017 6:05 PM
    Thursday, April 13, 2017 12:58 PM

All replies

  • Just to let you know the inputs of the comboboxes come from a datastorage in my access database 

    the code to disable the comboxboxes went under the load form: upgrade_combobox.enabled = false


    WRA

    Thursday, April 13, 2017 10:45 AM
  • Hi

    Without knowing how you have set up various things, I assume you have a set of properties aligned to each player - perhaps a Player Class?

    '

    If you do, then you could have a Property for each player that holds the 'level' of construction that the Player owns - perhaps an integer that corresponds to the list of buildings available. If a player tries to build a Tank and his construction 'level' is not high enough then he fails to build the Tank.

    '

    If you don't have such a Class, then what do you have to hold the different player Properties?


    Regards Les, Livingston, Scotland

    • Marked as answer by Waliur Rahman Thursday, April 13, 2017 6:05 PM
    Thursday, April 13, 2017 12:52 PM
  • Good question posed, I dont have a class created for player controller to determine how the program indicates which player is controlling what sprite colour. 

    WRA

    Thursday, April 13, 2017 12:55 PM
  • Wali, 

    The easiest way to do this kind of thing is to set a variable that keeps track of the stages your game is at. Just like we do in the other thread to determine if the attacker has been selected before selecting the target.

    You can just have lots of global variables like IsWarFactoryCreated.

    When the building is first made you IsWarFactoryCreated.= true

    then in the dialog form load or whatever,

       If IsWarFactoryCreated = true

     makemorefactoriesoption.enabled = true

       else

            makemorefactoriesoption.enabled = false

       End if   


    Need to draw something?

       If IsWarFactoryCreated = true
             draw factory


    You should make a class of all the game control variables. ie

    Public sub MyGameClass

     Public attacksprite as picturebox
     Public IsWarFactoryCreated as boolean
     Public selectedsprite
     Public backgroundimage as bitmap
     Public playeronepoints as integer
     Public playertwopoints as integer
    end sub

    Then you have all your flags collected in one place. You just declare the class in your main form. Then you can pass the flags to other subroutines that are out of scope, ie in other forms. yOu just pass the MyGame class to the routines.

    So a class to group things would be good but not required. You can just leave the variables independent single things if you want. It just makes it easier in the long run to use a class. Plus a class can do a lot more besides save variables which you will learn soon enough when the time is right.

    • Marked as answer by Waliur Rahman Thursday, April 13, 2017 6:05 PM
    Thursday, April 13, 2017 12:58 PM
  • @Tommy

    the combo box list items are from a database with the name for each of the buildings and its price. I cant be able to show a screenshot of the multicolumn combo box but I can say its in this layout. 

    defragmentator | 300 

    Therefore could It be possible by using my button to create an if statement where if this item is selected then this combobox is enabled.

    Just something very simplistic because I got plenty of complexity as it is in my project.


    WRA

    Thursday, April 13, 2017 1:08 PM
  • @Tommy

    the combo box list items are from a database with the name for each of the buildings and its price. I cant be able to show a screenshot of the multicolumn combo box but I can say its in this layout. 

    defragmentator | 300 

    Therefore could It be possible by using my button to create an if statement where if this item is selected then this combobox is enabled.

    Just something very simplistic because I got plenty of complexity as it is in my project.


    WRA

    Its possible. But I really don't understand what you are describing, sorry.

    Sometimes we just have to try it and see if it works.

    Thursday, April 13, 2017 1:36 PM
  • Fair enough, should I give you some more description if that could help you. 

    Dim dt As New DataTable("Infrastructure")
    
    Private Sub Player1_Game_Grid_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
    'This automatically loads the data within the given tables: Elements and CostE
    
            dt.Columns.Add("Elements", GetType(String))
            dt.Columns.Add("CostE", GetType(Integer))
    
            dt.Rows.Add(New Object() {"Defragmentator", 300})
            dt.Rows.Add(New Object() {"Gold Mine", 40})
            dt.Rows.Add(New Object() {"Grand Cannon", 50})
            dt.Rows.Add(New Object() {"Plasma Turret", 80})
            dt.Rows.Add(New Object() {"Research Laboratory", 150})
            dt.Rows.Add(New Object() {"Sentry Turret", 130})
            dt.Rows.Add(New Object() {"War Factory", 100})
    'This implements to my multicolumn combobox
            Build_1.DataSource = dt
            Build_1.DisplayMember = "Elements"
            Build_1.ValueMember = "CostE"

    This is the transaction process for as soon as I select "any" building. This might be the baseline to the solution.

    'This transacts the item selected to how much gold is currently stored 
    
        Private Sub Pay1_BDN_Click(sender As Object, e As EventArgs) Handles Pay1_BDN.Click
            If Loot_G >= Build_1.SelectedItem.item(1) Then
                Loot_G = Loot_G - Build_1.SelectedItem(1)
                Zero_G1.Text = Loot_G
                MsgBox("Purchased")
            Else
                MsgBox("Insufficient funds")
            End If
        End Sub


    WRA

    Thursday, April 13, 2017 1:42 PM
  • I manage to solve it wooooooo. I found how I could do it so along the lines of the name of the combobox.text "name of the specific item" then enabled of another combobox = true then show a msgbox indicating it works. 

    Thanks Ieshay and Tommy for the help outs I have figured out 3 problems in one !!!

    That is the most puzzles to my project solved than I had thought intended. 


    WRA


    Thursday, April 13, 2017 5:37 PM