【发布时间】:2015-04-18 18:44:31
【问题描述】:
我有一个名为 factory 的类,它继承了一个名为 Block 的类。块反过来继承对象面板。在每个工厂中,我有 3 个面板用于生产按钮。当点击制作按钮时,会触发制作计时器。
我的问题是,例如,当我单击混凝土工厂的 1 分钟生产时,我的钢铁生产开始了。这对所有工厂的所有按钮都是一样的;它们都会触发钢铁生产。
我需要知道的是,当我在混凝土工厂点击我的 1 分钟按钮时,我如何确定它来自混凝土工厂的按钮,而不是钢制按钮?
这是工厂类中按钮的处理程序事件:
min = New Block(Me, 0, 0, 20, 20, Color.Maroon, My.Resources._1min)
hour = New Block(Me, 40, 0, 20, 20, Color.Maroon, My.Resources._1hour)
fifteenHour = New Block(Me, 80, 0, 20, 20, Color.Maroon, My.Resources._15hour)
AddHandler min.Click, AddressOf startProduction1min
AddHandler hour.Click, AddressOf startProduction1hour
AddHandler fifteenHour.Click, AddressOf startProduction15hour
这是我的 startProduction1min()
Sub startProduction1min(ByVal sender As Object, ByVal e As EventArgs)
If stlFac.Bounds.Contains(sender.Bounds) Then
prodCost = (1 / 30)
If Not prodCost > goldVol Then
goldVol -= prodCost
Else
Return
End If
startProduction(steelProduction, 60)
ElseIf conFac.Bounds.Contains(sender.Bounds) Then
prodCost = (1 / 60)
If Not prodCost > goldVol Then
goldVol -= prodCost
Else
Return
End If
startProduction(concreteProduction, 60)
ElseIf gldFac.Bounds.Contains(sender.Bounds) Then
prodCost = (0.005)
If Not prodCost > goldVol Then
goldVol -= prodCost
Else
Return
End If
startProduction(goldProduction, 60)
End If
End Sub
问题似乎出在:
If stlFac.Bounds.Contains(sender.Bounds) Then
有什么建议吗?
谢谢
【问题讨论】: