📄 cenemy.cls
字号:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "cEnemy"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Public Frame As cFrame
Public Terminating As Boolean
Private I_nMaxHitpoints As Long
Public ComponentX As Long
Public ComponentY As Long
Public ComponentParent As cEnemy
Private I_nCurrentHitpoints As Long
Public ExplosionSize As Long
Public PowerUpStyle As Long
Public NoCollide As Boolean
Public NoHit As Boolean
Public ScoreValue As Long
Public IsPowerup As Boolean
Public Hitpoints As Long
Public Animated As Boolean
Public Directed As Boolean
Public Targetting As Boolean
Public Shooting As Boolean
Public Parent As cEnemies
Private I_oWayPoints As cWaypoints
Public Active As Boolean
Public State As cWaypoint
Public LifeCount As Long
Public TriggerAt As Long
Public PositionX As Single
Public PositionY As Single
Public Weapon As Long
Private I_nShooting As Long
Private I_nTerminateCount As Long
Public Sub InitHitpoints()
I_nMaxHitpoints = Hitpoints
I_nCurrentHitpoints = Hitpoints
End Sub
Public Property Get Waypoints() As cWaypoints
Set Waypoints = I_oWayPoints
End Property
Public Property Set Waypoints(oWaypoints As cWaypoints)
Set I_oWayPoints = oWaypoints
End Property
Public Sub Initialize()
Set I_oWayPoints = New cWaypoints
Set I_oWayPoints.Parent = Me
End Sub
Public Sub Terminate()
End Sub
Public Sub Render()
Dim L_nCurrentFrame As Long
Dim L_nDX As Single
Dim L_nDY As Single
Dim L_nDirection As Single
Dim L_nAngle As Single
With Frame
If Animated Then
L_nCurrentFrame = (Parent.Parent.Parent.FrameCount Mod (.TileCount * .AnimationDelay)) \ .AnimationDelay
End If
If Directed Then
L_nCurrentFrame = State.Direction \ (360 / (.TileCount + 1))
End If
If Targetting Then
L_nDX = Parent.Parent.Parent.Player.PositionX - PositionX
L_nDY = Parent.Parent.Parent.Player.PositionY - PositionY
If L_nDX = 0 Then L_nDX = 1
If L_nDX >= 0 And L_nDY >= 0 Then
L_nAngle = 90 + Abs(Atn(L_nDY / L_nDX)) * 57.297469
End If
If L_nDX < 0 And L_nDY >= 0 Then
L_nAngle = 270 - Abs(Atn(L_nDY / L_nDX)) * 57.297469
End If
If L_nDX >= 0 And L_nDY < 0 Then
L_nAngle = 90 - Abs(Atn(L_nDY / L_nDX)) * 57.297469
End If
If L_nDX < 0 And L_nDY < 0 Then
L_nAngle = 270 + Atn(L_nDY / L_nDX) * 57.297469
End If
L_nCurrentFrame = L_nAngle \ (360 / (.TileCount + 1))
End If
If Shooting Then
L_nCurrentFrame = IIf(I_nShooting > 0, I_nShooting \ Frame.AnimationDelay, 0)
If I_nShooting > 0 Then
I_nShooting = I_nShooting + 1
If I_nShooting = Frame.TileCount * Frame.AnimationDelay Then I_nShooting = 0
End If
End If
If Not .RenderToViewport(PositionX \ 10 - Frame.Width \ 2, PositionY \ 10 - Frame.Height \ 2, L_nCurrentFrame) Then
If ComponentParent Is Nothing Then
If State.Style = 0 Then
If Parent.Parent.Parent.Level.Stopper Is Me Then Set Parent.Parent.Parent.Level.Stopper = Nothing
Active = False
Dim L_oEnemy As cEnemy
For Each L_oEnemy In Parent
If L_oEnemy.ComponentParent Is Me Then
L_oEnemy.Active = False
End If
Next
End If
End If
End If
If Parent.Parent.Parent.DebugMode Then
If ComponentParent Is Nothing Then
L_nDirection = (IIf(State.Direction - 90 < 0, State.Direction - 90 + 360, State.Direction - 90) * PIFACTOR)
L_nDX = (State.Speed * Cos(L_nDirection) * 10)
L_nDY = (State.Speed * Sin(L_nDirection) * 10)
Parent.Parent.Parent.Viewport.Surface.SetForeColor RGB(255, 100, 100)
Parent.Parent.Parent.Viewport.Surface.DrawLine PositionX / 10, PositionY / 10, PositionX / 10 + L_nDX, PositionY / 10 + L_nDY
End If
End If
End With
End Sub
Public Sub Update()
Dim L_nDY As Single
Dim L_nDX As Single
Dim L_nDirection As Single
Dim L_oShot As cShot
If Active Then
If ComponentParent Is Nothing Then
L_nDirection = (IIf(State.Direction - 90 < 0, State.Direction - 90 + 360, State.Direction - 90) * PIFACTOR)
L_nDX = (State.Speed * Cos(L_nDirection))
L_nDY = (State.Speed * Sin(L_nDirection))
PositionX = PositionX + L_nDX
PositionY = PositionY + L_nDY
Else
Set State = ComponentParent.State
If ComponentParent.Terminating Then
Terminating = True
Parent.Parent.Effects.Add "EXPLO3", Int(PositionX), Int(PositionY), 0, 0
End If
PositionX = ComponentParent.PositionX + ComponentX * 10
PositionY = ComponentParent.PositionY + ComponentY * 10
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -