Class Cell
Private Shared Layer As Layer
Public ID As Short
Private Shared ELEMENTS_COUNT As Short
Private Shared ELEMENTS As List(Of BasicElement)
Sub New(ByVal Layer As Layer, ByVal br As BinaryReader)
Layer = Layer
ID = Reader.readShort(br)
ELEMENTS_COUNT = Reader.readShort(br)
ELEMENTS = New List(Of BasicElement)
For i As Integer = 0 To ELEMENTS_COUNT - 1
Dim item = BasicElement.getElementFromType(Reader.ReadByte(br), Me, br)
ELEMENTS.Add(item)
Next
End Sub
End Class
Class BasicElement
Private Shared Cell As Cell
Dim value As Integer
Public Function getValue()
Return value
End Function
Public Shared Function fromInt(ByVal value As Integer)
'for (ElementTypesEnum v : values()) {
' If v.value = value Then Return v
'}
Return value
End Function
Public Sub BasicElement(ByVal Cell As Cell)
setCell(Cell)
End Sub
Public Shared Function getElementFromType(ByVal id As Byte, ByVal Cell As Cell, ByVal reader As BinaryReader)
Select Case fromInt(id)
Case 2 'GRAPHICAL
Return New GraphicalElement(Cell, reader)
Case &H21 'SOUND
Return New SoundElement(Cell, reader)
Case Else
Console.WriteLine("Element inconnu ID : " & id & " CellID : " & Cell.ID)
End Select
Return 0 ' erreur
End Function
Public Sub setCell(ByVal Cell As Cell)
Cell = Cell
End Sub
Public Function getCell()
Return Cell
End Function
End Class