Public Sub Tick (GS As X2GameStep)
Dim touch As X2Touch = Multitouch.GetSingleTouch(PanelForTouch)
If touch.IsInitialized Then
For Each bw As X2BodyWrapper In X2.GetBodiesIntersectingWithWorldPoint(X2.ScreenPointToWorld(touch.X, touch.Y))
If bw.Name.StartsWith("door") Then
Dim dd As DoorData = bw.Tag
Select dd.State
Case DOOR_CLOSED
'open door
dd.State = DOOR_OPENING
bw.SwitchFrameIntervalMs = 50
bw.X2.AddFutureTask(Me, "DoorOpened_Completed", bw.SwitchFrameIntervalMs * bw.NumberOfFrames, bw)
Case DOOR_OPENED
'close door
dd.State = DOOR_CLOSING
bw.X2.AddFutureTask(Me, "DoorClosing_Process", 50, bw)
End Select
End If
Next
End If
End Sub
Private Sub DoorClosing_Process (ft As X2FutureTask)
Dim bw As X2BodyWrapper = ft.Value
If bw.CurrentFrame = 0 Then
bw.Tag.As(DoorData).State = DOOR_CLOSED
Else
bw.CurrentFrame = bw.CurrentFrame - 1
bw.X2.AddFutureTask(Me, "DoorClosing_Process", 50, bw)
End If
End Sub
Private Sub DoorOpened_Completed (ft As X2FutureTask)
Dim bw As X2BodyWrapper = ft.Value
bw.Tag.As(DoorData).State = DOOR_OPENED
bw.SwitchFrameIntervalMs = 0
End Sub