⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 agentcontroller.vb

📁 Samples are organized by chapter, and then by "application" or example name. You should open a proje
💻 VB
字号:
Public Class AgentController

    ' Agent variable.
    Private AgentChar As AgentObjects.IAgentCtlCharacterEx

    ' Name of the initialized character.
    Private CharacterName As String

    ' Balloon constants
    Const BalloonOn As Short = 1
    Const SizeToText As Short = 2
    Const AutoHide As Short = 4
    Const AutoPace As Short = 8


    Public Sub New(ByVal AgentHost As AxAgentObjects.AxAgent, _
                   ByVal Character As String)

        AgentHost.Characters.Load(Character)
        AgentChar = AgentHost.Characters(Character)

        CharacterName = Character

        ' You could put your own options in this menu, if desired.
        AgentChar.AutoPopupMenu = False


        ' Set balloon style.
        AgentChar.Balloon.Style = AgentChar.Balloon.Style Or BalloonOn
        AgentChar.Balloon.Style = AgentChar.Balloon.Style Or SizeToText
        AgentChar.Balloon.Style = AgentChar.Balloon.Style Or AutoHide
        AgentChar.Balloon.Style = AgentChar.Balloon.Style And (Not AutoPace)

    End Sub

    Public Sub Dispose()
        If AgentChar.Visible = True Then
            AgentChar.StopAll()
            AgentChar.Hide()
        End If
    End Sub

    Public Sub Show()
        AgentChar.Show()
    End Sub

    Public Sub Hide()
        AgentChar.Hide()
    End Sub

    Public Sub StopAll()
        AgentChar.StopAll()
    End Sub

    Public Sub Speak(ByRef Text As String)
        AgentChar.StopAll()
        AgentChar.Speak(Text, "")
    End Sub

    Public Sub Think(ByRef Text As String)
        AgentChar.StopAll()
        AgentChar.Think(Text)
    End Sub

    Public Sub Animate(ByVal Animation As String)
        AgentChar.StopAll()
        AgentChar.Play(Animation)
    End Sub

    Public Sub MoveTo(ByVal x As Single, ByVal y As Single)
        AgentChar.MoveTo(x, y)
    End Sub

    Public Sub GestureAt(ByVal x As Single, ByVal y As Single)
        AgentChar.GestureAt(x, y)
    End Sub

    Public Function GetAnimations() As Array
        Dim List As New ArrayList()
        Dim AnimationName As String
        For Each AnimationName In AgentChar.AnimationNames
            List.Add(AnimationName)
        Next
        Return List.ToArray(GetType(String))
    End Function

    ' Tests if the agent is visible.
    ' If the agent is not visible it will be shown.
    Private Function IsAgentVisible() As Boolean
        If AgentChar.Visible Then
            IsAgentVisible = True
        Else
            IsAgentVisible = False
            AgentChar.Show()
        End If
    End Function

End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -