예제 #1
0
        private void DrawBehaviourModeRuleGizmos(TargetObject _target, BehaviourModeRuleObject _rule)
        {
                        #if UNITY_EDITOR
            if (_target == null || _target.IsValid == false || _rule == null)
            {
                return;
            }

            Vector3 _owner_position         = m_Owner.transform.position;
            Vector3 _target_pos             = _target.TargetPosition;
            Vector3 _target_move_position   = _target.TargetMovePosition;
            float   _target_stop_distance   = _target.TargetStopDistance;
            float   _target_selection_range = _target.Selectors.SelectionRange;
            //float _target_selection_angle = _target.Selectors.SelectionAngle;

            DrawOwnerGizmos();

            if (Application.isPlaying)
            {
                DrawPathGizmos();
                DrawMoveGizmos();
            }

            float _level = GetLevel();

            _owner_position.y       = _level;
            _target_pos.y           = _level;
            _target_move_position.y = _level;

            if (_rule.Move.Type == MoveType.DEFAULT)
            {
            }
            else if (_rule.Move.Type == MoveType.AVOID)
            {
                MoveContainer _move = _rule.Move;
                //float _radius = _target_selection_range  + 0.25f;// _move.Avoid.MaxAvoidDistance;//( _target_selection_range / 2 ) + 0.25f;
                //float _angle = _move.Avoid.MaxDirectionAngle;

                Gizmos.color = MoveAvoidColor;
                UnityEditor.Handles.color = Gizmos.color;

                //DrawDirectionAngle( m_Owner.transform, _radius, _angle );
                //DrawDirectionAngle( _target.TargetGameObject.transform, _radius, _angle );

                Vector3 _right           = Vector3.Cross(_target.TargetGameObject.transform.up, _target.TargetGameObject.transform.forward);
                Vector3 _avoid_pos_right = _target_pos + (_right * _move.Avoid.AvoidDistance);
                Vector3 _avoid_pos_left  = _target_pos + (_right * -_move.Avoid.AvoidDistance);

                CustomGizmos.OffsetPath(_target_pos, 0, _avoid_pos_right, _move.MoveStopDistance);
                CustomGizmos.DottedCircle(_avoid_pos_right, _move.MoveStopDistance, 5, 2);
                CustomGizmos.OffsetPath(_target_pos, 0, _avoid_pos_left, _move.MoveStopDistance);
                CustomGizmos.DottedCircle(_avoid_pos_left, _move.MoveStopDistance, 5, 2);

                if (Application.isPlaying)
                {
                    /*
                     * Gizmos.color = Color.blue;
                     * Gizmos.DrawLine( _target_pos, CreatureControl.Creature.Move.AvoidMovePosition );
                     * Gizmos.color = Color.red;
                     * Gizmos.DrawLine( _target_pos, CreatureControl.Creature.Move.MovePosition );
                     */
                }
            }
            else if (_rule.Move.Type == MoveType.ESCAPE)
            {
                MoveContainer _move             = _rule.Move;
                float         _inner_radius     = (_target_selection_range / 2) + 0.25f;
                float         _outer_radius     = _inner_radius + _rule.Move.MoveSegmentLength;
                float         _outer_radius_max = _inner_radius + _rule.Move.MoveSegmentLengthMax;
                float         _outer_radius_min = _inner_radius + _rule.Move.MoveSegmentLengthMin;

                float _inner_angle = 0;
                float _outer_angle = _inner_angle + _move.Escape.RandomEscapeAngle;

                Gizmos.color = MoveEscapeColor;

                Vector3 _left_inner_pos  = Tools.GetDirectionPosition(_target.TargetGameObject.transform, -_inner_angle, _inner_radius);
                Vector3 _right_inner_pos = Tools.GetDirectionPosition(_target.TargetGameObject.transform, _inner_angle, _inner_radius);
                Vector3 _left_outer_pos  = Tools.GetDirectionPosition(_target.TargetGameObject.transform, -_outer_angle, _outer_radius);
                Vector3 _right_outer_pos = Tools.GetDirectionPosition(_target.TargetGameObject.transform, _outer_angle, _outer_radius);

                _target_pos.y      = _level;
                _left_inner_pos.y  = _level;
                _right_inner_pos.y = _level;
                _left_outer_pos.y  = _level;
                _right_outer_pos.y = _level;

                Gizmos.DrawLine(_target_pos, _left_inner_pos);
                Gizmos.DrawLine(_target_pos, _right_inner_pos);

                Gizmos.DrawLine(_left_inner_pos, _left_outer_pos);
                Gizmos.DrawLine(_right_inner_pos, _right_outer_pos);

                CustomGizmos.Arc(_target.TargetGameObject.transform, _inner_radius, 1, -_inner_angle, _inner_angle, _level, false);
                CustomGizmos.Arc(_target.TargetGameObject.transform, _outer_radius, 1, -_outer_angle, _outer_angle, _level, false);

                CustomGizmos.Arc(_target.TargetGameObject.transform, _outer_radius_min, 1, -_outer_angle, _outer_angle, _level, true);
                CustomGizmos.Arc(_target.TargetGameObject.transform, _outer_radius_max, 1, -_outer_angle, _outer_angle, _level, true);

                // DENGER ZONE BEGIN
                _inner_radius += 0.25f;
                float _degree = CustomGizmos.GetBestDegrees(_inner_radius, _inner_angle);
                CustomGizmos.ArrowArc(_target.TargetGameObject.transform, _inner_radius, _degree, -_inner_angle, _inner_angle, _level);

                Transform _target_transform = _target.TargetGameObject.transform;
                Vector3   _center           = _target_transform.position;
                Vector3   _center_pos       = Tools.GetDirectionPosition(_target_transform, 0, _inner_radius + (_inner_radius / 10));
                Vector3   _left_pos         = Tools.GetDirectionPosition(_target_transform, -_inner_angle, _inner_radius);
                Vector3   _right_pos        = Tools.GetDirectionPosition(_target_transform, _inner_angle, _inner_radius);

                _center.y     = _level;
                _center_pos.y = _level;
                _left_pos.y   = _level;
                _right_pos.y  = _level;

                Gizmos.DrawLine(_center, _center_pos);
                Gizmos.DrawLine(_center, _left_pos);
                Gizmos.DrawLine(_center, _right_pos);
            }
            else if (_rule.Move.Type == MoveType.ORBIT)
            {
                MoveContainer _move    = _rule.Move;
                float         _degrees = CreatureControl.Creature.Move.OrbitDegrees;
                float         _radius  = _move.Orbit.Radius;

                if (Application.isPlaying)
                {
                    _move   = CreatureControl.Creature.Move.CurrentMove;
                    _radius = CreatureControl.Creature.Move.OrbitRadius;
                }

                Gizmos.color = MoveOrbitColor;
                CustomGizmos.Orbit(m_Owner.transform.position, _target_move_position, _radius, _degrees, _move.Orbit.RadiusShift, _move.Orbit.MinDistance, _move.Orbit.MaxDistance, _level);
            }
            else if (_rule.Move.Type == MoveType.DETOUR)
            {
                Vector3 _detour_pos = _rule.Move.Detour.Position;

                _detour_pos.y = _level;

                Gizmos.color = MoveDetourColor;
                CustomGizmos.OffsetPath(_detour_pos, _rule.Move.MoveStopDistance, _target_move_position, _target_stop_distance);
                CustomGizmos.Circle(_detour_pos, _rule.Move.MoveStopDistance, 5, false);                   // STOP DISTANCE RANGE
                //DrawMoveGizmos( Vector3 _initial_position, Vector3 _move_position, float _stop_distance, float _random_range, Vector3 _target_position, float _target_stop_distance )
            }
                        #endif
        }