Пример #1
0
    public void Update()
    {
        if (this.IsActive)
        {
            // Update which waypoint the AI is heading toward
            m_pathfindingComponent.Update();

            // Compute a throttle and a facing toward the waypoint
            m_steeringComponent.Update();

            // Make a local copy of our position
            {
                Point2d pixelPosition = new Point2d(m_characterWidget.LocalX, m_characterWidget.LocalY);

                m_position = GameConstants.ConvertPixelPositionToRoomPosition(pixelPosition);
            }

            // Make a local copy of our facing, if we're moving
            if (!m_steeringComponent.Throttle.IsAlmostZero)
            {
                m_facing.Copy(m_steeringComponent.Facing);
            }

            // Update the animation based on our desired facing and velocity
            m_characterWidget.UpdateAnimation(m_facing, m_steeringComponent.Throttle);
        }
    }
Пример #2
0
    public void Update()
    {
        if (this.IsActive)
        {
            // Update which waypoint the AI is heading toward
            m_pathfindingComponent.Update();

            // Compute a throttle and a facing toward the waypoint
            m_steeringComponent.Update();

            // Make a local copy of our position
            {
                Point2d pixelPosition = new Point2d(m_mobWidget.LocalX, m_mobWidget.LocalY);

                m_position = GameConstants.ConvertPixelPositionToRoomPosition(pixelPosition);
            }

            // Make a local copy of our facing, if we're moving
            if (!m_steeringComponent.Throttle.IsAlmostZero)
            {
                m_facing.Copy(m_steeringComponent.Facing);
            }

            // Update the animation based on our desired facing and velocity
            m_mobWidget.UpdateAnimation(m_facing, m_steeringComponent.Throttle);

            // Hide the vision cone while we' re moving
            m_mobWidget.SetVisionConeVisible(m_steeringComponent.Throttle.IsAlmostZero);

            // Hide the dialog if it timed out
            if (m_dialogTimer >= 0.0f && (Time.time - m_dialogTimer) >= DIALOG_DISPLAY_DURATION)
            {
                m_mobWidget.HideDialog();
                m_dialogTimer = -1.0f;
            }
        }
    }