Skip to content

Commit

Permalink
Messing with abstract class/interface...
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoon committed Sep 20, 2013
1 parent 6f07bed commit 7cfe2d8
Show file tree
Hide file tree
Showing 21 changed files with 848 additions and 38 deletions.
11 changes: 11 additions & 0 deletions CookieClickerClone/CookieClickerClone/AlchemyLab.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Imports Microsoft.VisualBasic

Public Class AlchemyLab
Inherits Generator

Private baseCost As Integer = 200000 'cost of the first one purchased
Private CpS As Double = 400.0 'cookies per second generated by one of this object
Private amount As Integer = 0 'number of this type of generator created
Private total As Double = 0 'number of cookies produced since beginning of game
Private currentCost As Long = baseCost 'base cost * 1.15 (accurate for non-cursors?)
End Class
11 changes: 11 additions & 0 deletions CookieClickerClone/CookieClickerClone/AntimatterCondenser.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Imports Microsoft.VisualBasic

Public Class AntimatterCondenser
Inherits Generator

Private baseCost As Long = 3999999999 'cost of the first one purchased
Private CpS As Double = 999999.0 'cookies per second generated by one of this object
Private amount As Integer = 0 'number of this type of generator created
Private total As Double = 0 'number of cookies produced since beginning of game
Private currentCost As Long = baseCost 'base cost * 1.15 (accurate for non-cursors?)
End Class
1 change: 1 addition & 0 deletions CookieClickerClone/CookieClickerClone/ClassDiagram1.cd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

546 changes: 519 additions & 27 deletions CookieClickerClone/CookieClickerClone/CookieClicker.Designer.vb

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions CookieClickerClone/CookieClickerClone/CookieClicker.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="pbCookie.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="picCookie.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="tmrCounter.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="pbCookie.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
104 changes: 97 additions & 7 deletions CookieClickerClone/CookieClickerClone/CookieClicker.vb
Original file line number Diff line number Diff line change
@@ -1,25 +1,115 @@
Public Class CookieClicker
Dim currentCookies As Integer = 0
Dim alltimeCookies As Integer = 0
Dim currentCookies As Long = 0
Dim alltimeCookies As Long = 0
Dim buildingsOwned As Integer = 0
Dim CpS As Double = 0.0 'cookies per second
Dim cookiesPerClick As Integer = 1
Dim handMadeCookies As Integer = 0
Dim cookiesPerClick As Long = 1
Dim handMadeCookies As Long = 0
Dim goldenCookies As Integer = 0

Dim time As Double = 0
Shadows cursor As New Cursor
Dim grandma As New Grandma
Dim farm As New Farm
Dim factory As New Factory
Dim mine As New Mine
Dim shipment As New Shipment
Dim alchemyLab As New AlchemyLab
Dim portal As New Portal
Dim timeMachine As New TimeMachine
Dim antimatterCondenser As New AntimatterCondenser


'Keeping track of the generators listed on the form (pic, button, label)
Const NUMBER_OF_GENERATORS = 10
Dim generatorArray(NUMBER_OF_GENERATORS, 3) As Object 'each element of generatorArray contains: [pic, button, label]
Dim typeArray() As Generator = {cursor, grandma, farm, factory, mine, shipment, alchemyLab, portal, timeMachine, antimatterCondenser}

Dim time As Integer = 0

Public Shared Sub Main()

Dim form As CookieClicker = New CookieClicker()
form.tmrCounter.Start()
Application.Run(form)

'persistantly check for which things can be purchased
Dim enableButtonsThread As New System.Threading.Thread(AddressOf form.enableButtons)
enableButtonsThread.IsBackground = True
enableButtonsThread.Start()

End Sub

'timer will tick every tenth of a second
Private Sub tmrCounter_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrCounter.Tick
time += 0.1
Label1.Text = time
'update values
time += 1
currentCookies += CpS / 10
alltimeCookies += CpS / 10

'update displays
lblCurrentCookies.Text = currentCookies

If time Mod 10 = 0 Then 'one second has passed

End If
End Sub

Private Sub picCookie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picCookie.Click
'update values
currentCookies += 1
alltimeCookies += 1

'update displays
lblCurrentCookies.Text = currentCookies

'enable necessary buttons
enableButtons()

End Sub

Private Sub cursor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picCursor.Click, btnCursor.Click, lblCursor.Click

End Sub

'continuously enable/disable all generators that can/can't be purchased with the current amount of currency possessed
Private Sub enableButtons()
'each element of generatorArray contains: [pic, button, label]
'the following code populates the list of generators
Dim index() As Integer = {0, 0, 0} 'keep track of number of [pic, button, label] seen

'For Each obj As Object In pnlRight.Controls
'If TypeOf obj Is PictureBox Then
'End If
'Next

For Each item As Control In pnlRight.Controls
If TypeOf item Is PictureBox Then
generatorArray(index(0), 0) = item
index(0) += 1
ElseIf TypeOf item Is Button Then
generatorArray(index(1), 1) = item
index(1) += 1
ElseIf TypeOf item Is Label Then
generatorArray(index(2), 2) = item
index(2) += 1
End If
Next

'code for enabling/disabling buttons
While (True)
For i As Integer = 0 To NUMBER_OF_GENERATORS - 1
'if player has enough money to buy a generator, the correspoding button, etc. should be enabled & vise-versa
If currentCookies < typeArray(i).getCost() Then
TryCast(generatorArray(i, 0), PictureBox).Enabled = False
TryCast(generatorArray(i, 1), Button).Enabled = False
TryCast(generatorArray(i, 2), Label).Enabled = False
Else
TryCast(generatorArray(i, 0), PictureBox).Enabled = True
TryCast(generatorArray(i, 1), Button).Enabled = True
TryCast(generatorArray(i, 2), Label).Enabled = True
End If
Next

End While
End Sub
End Class
17 changes: 17 additions & 0 deletions CookieClickerClone/CookieClickerClone/CookieClickerClone.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,21 @@
<Import Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="AlchemyLab.vb" />
<Compile Include="AntimatterCondenser.vb" />
<Compile Include="CookieClicker.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="CookieClicker.Designer.vb">
<DependentUpon>CookieClicker.vb</DependentUpon>
<SubType>Form</SubType>
</Compile>
<Compile Include="Cursor.vb" />
<Compile Include="Factory.vb" />
<Compile Include="Farm.vb" />
<Compile Include="Generator.vb" />
<Compile Include="Grandma.vb" />
<Compile Include="Mine.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
Expand All @@ -94,6 +102,9 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Portal.vb" />
<Compile Include="Shipment.vb" />
<Compile Include="TimeMachine.vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="CookieClicker.resx">
Expand All @@ -107,6 +118,8 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="ClassDiagram1.cd" />
<None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
Expand All @@ -119,8 +132,12 @@
</ItemGroup>
<ItemGroup>
<None Include="My Project\cookie.png" />
<None Include="My Project\bg.png" />
<Content Include="Plans.txt" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
11 changes: 11 additions & 0 deletions CookieClickerClone/CookieClickerClone/Cursor.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Public Class Cursor
Inherits Generator

Private baseCost As Integer = 15 'cost of the first one purchased
Private CpS As Double = 0.1 'cookies per second generated by one of this object
Private amount As Integer = 0 'number of this type of generator created
Private total As Double = 0 'number of cookies produced since beginning of game
Private currentCost As Long = baseCost 'base cost * 1.15 (accurate for non-cursors?)

End Class

11 changes: 11 additions & 0 deletions CookieClickerClone/CookieClickerClone/Factory.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Imports Microsoft.VisualBasic

Public Class Factory
Inherits Generator

Private baseCost As Integer = 3000 'cost of the first one purchased
Private CpS As Double = 10.0 'cookies per second generated by one of this object
Private amount As Integer = 0 'number of this type of generator created
Private total As Double = 0 'number of cookies produced since beginning of game
Private currentCost As Long = baseCost 'base cost * 1.15 (accurate for non-cursors?)
End Class
11 changes: 11 additions & 0 deletions CookieClickerClone/CookieClickerClone/Farm.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Imports Microsoft.VisualBasic

Public Class Farm
Inherits Generator

Private baseCost As Integer = 500 'cost of the first one purchased
Private CpS As Double = 2.0 'cookies per second generated by one of this object
Private amount As Integer = 0 'number of this type of generator created
Private total As Double = 0 'number of cookies produced since beginning of game
Private currentCost As Long = baseCost 'base cost * 1.15 (accurate for non-cursors?)
End Class
54 changes: 54 additions & 0 deletions CookieClickerClone/CookieClickerClone/Generator.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'An abstract class for objects that auto-generate cookies every second.
Public MustInherit Class Generator
Private baseCost As Integer 'cost of the first one purchased
Private CpS As Double 'cookies per second generated by one of this object
Private amount As Integer 'number of this type of generator created
Private total As Double 'number of cookies produced since beginning of game
Private currentCost As Long 'base cost * 1.15 (accurate for non-cursors?)

'Allows retrieval/editing of the CpS for a single generator of this type
Public ReadOnly Property getCpS() As Double
Get
Return CpS
End Get
End Property


'Returns the base cost of the first object purchased
Public ReadOnly Property getBaseCost() As Integer
Get
Return baseCost
End Get
End Property


'Allows retrieval/editing of the quantity of this generator in existance
Public Property Quantity() As Integer
Get
Return amount
End Get
Set(ByVal value As Integer)
amount += value
End Set
End Property

'Allows for retrieval/editing of the total Cookies produced by this generator type
Public Property TotalProduced() As Double
Get
Return total
End Get
Set(ByVal value As Double)
total += value
End Set
End Property

Public ReadOnly Property getCost() As Integer
Get
Return currentCost
End Get
End Property

Public Sub updateCost()
currentCost *= 1.15
End Sub
End Class
9 changes: 9 additions & 0 deletions CookieClickerClone/CookieClickerClone/Grandma.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Public Class Grandma
Inherits Generator

Private baseCost As Integer = 100 'cost of the first one purchased
Private CpS As Double = 0.5 'cookies per second generated by one of this object
Private amount As Integer = 0 'number of this type of generator created
Private total As Double = 0 'number of cookies produced since beginning of game
Private currentCost As Long = baseCost 'base cost * 1.15 (accurate for non-cursors?)
End Class
11 changes: 11 additions & 0 deletions CookieClickerClone/CookieClickerClone/Mine.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Imports Microsoft.VisualBasic

Public Class Mine
Inherits Generator

Private baseCost As Integer = 10000 'cost of the first one purchased
Private CpS As Double = 40.0 'cookies per second generated by one of this object
Private amount As Integer = 0 'number of this type of generator created
Private total As Double = 0 'number of cookies produced since beginning of game
Private currentCost As Long = baseCost 'base cost * 1.15 (accurate for non-cursors?)
End Class

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="bg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>bg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="cookie" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>cookie.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="strPerSecond" xml:space="preserve">
<value>per second:</value>
<comment>left panel, displays CpS</comment>
</data>
</root>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified CookieClickerClone/CookieClickerClone/My Project/cookie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions CookieClickerClone/CookieClickerClone/Portal.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Imports Microsoft.VisualBasic

Public Class Portal
Inherits Generator

Private baseCost As Integer = 1666666 'cost of the first one purchased
Private CpS As Double = 6666.0 'cookies per second generated by one of this object
Private amount As Integer = 0 'number of this type of generator created
Private total As Double = 0 'number of cookies produced since beginning of game
Private currentCost As Long = baseCost 'base cost * 1.15 (accurate for non-cursors?)
End Class
Loading

0 comments on commit 7cfe2d8

Please sign in to comment.