Ejemplo n.º 1
0
        private void DrawDirectionAngle(Transform _center, float _inner_radius, float _outer_radius, float _outer_radius_max, float _outer_radius_min, float _inner_angle, float _outer_angle)
        {
            Vector3 _center_pos = _center.position;
            float   _level      = GetLevel();

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

            _center_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(_center_pos, _left_inner_pos);
            Gizmos.DrawLine(_center_pos, _right_inner_pos);

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

            CustomGizmos.Arc(_center, _inner_radius, 1, -_inner_angle, _inner_angle, _level, false);
            CustomGizmos.Arc(_center, _outer_radius, 1, -_outer_angle, _outer_angle, _level, false);

            CustomGizmos.Arc(_center, _outer_radius_min, 1, -_outer_angle, _outer_angle, _level, true);
            CustomGizmos.Arc(_center, _outer_radius_max, 1, -_outer_angle, _outer_angle, _level, true);
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Draws regular polygons animation
    /// </summary>
    private void Polygons()
    {
        int     sidesCount       = 3 + (int)(sidesCountAmplitude * (sinParam + 1) / 2);
        Vector3 currentDirection = Quaternion.AngleAxis(doubleSinParam * normalAmplitude, new Vector3(-1, 0, 1).normalized) * Vector3.up;

        CustomGizmos.DrawRegularPoligon(new Vector3(6, 0, 2) + Vector3.right * sinParam * positionAmplitude, Vector3.right, polygonsRadius, sidesCount, currentDirection);
    }
Ejemplo n.º 3
0
        private void DrawDirectionAngle(Transform _center, float _radius, float _angle, float _max = 0, float _min = 0)
        {
            Vector3 _center_pos = _center.position;
            float   _level      = GetLevel();

            Vector3 _left_pos  = Tools.GetDirectionPosition(_center, -_angle, _radius);
            Vector3 _right_pos = Tools.GetDirectionPosition(_center, _angle, _radius);

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

            Gizmos.DrawLine(_center_pos, _left_pos);
            Gizmos.DrawLine(_center_pos, _right_pos);

            CustomGizmos.Arc(_center, _radius, 1, -_angle, _angle, _level, false);

            if (_min > 0 && _min < _radius)
            {
                CustomGizmos.Arc(_center, _min, 1, -_angle, _angle, _level, true);
            }
            if (_max > _radius)
            {
                CustomGizmos.Arc(_center, _max, 1, -_angle, _angle, _level, true);
            }
        }
Ejemplo n.º 4
0
    /// <summary>
    /// Calculates arrow head position and draws it
    /// </summary>
    private void ArrowHead()
    {
        Vector3 arrowHeadPos     = Vector3.up * (sinParam * arrowHeadAmplitude + arrowHeadOffset) + new Vector3(0.5f, 0, 0.5f);
        Vector3 currentDirection = Quaternion.AngleAxis(currentAngle, Vector3.up) * Vector3.forward;

        CustomGizmos.DrawArrowTip(arrowHeadPos, Vector3.down, arrowTipSize, currentDirection);
    }
    /// <summary>
    /// Raises the draw gizmos event.
    /// </summary>
    public void OnDrawGizmos()
    {
        if (!ShowGrid)
        {
            return;
        }

        Gizmos.color = GridColor;

        int _size = 5;

        for (int i = 0; i < 10; i++)
        {
            Vector3 _pos_x1 = new Vector3(m_GridMovePosition.x - (GridSize * _size), 1, m_GridMovePosition.z - (GridSize * _size) + (GridSize * i));
            Vector3 _pos_x2 = new Vector3(m_GridMovePosition.x + (GridSize * _size), 1, m_GridMovePosition.z - (GridSize * _size) + (GridSize * i));
            Vector3 _pos_z1 = new Vector3(m_GridMovePosition.x - (GridSize * _size) + (GridSize * i), 1, m_GridMovePosition.z - (GridSize * _size));
            Vector3 _pos_z2 = new Vector3(m_GridMovePosition.x - (GridSize * _size) + (GridSize * i), 1, m_GridMovePosition.z + (GridSize * _size));

            Gizmos.DrawLine(_pos_x1, _pos_x2);
            Gizmos.DrawLine(_pos_z1, _pos_z2);

            for (int a = 1; a <= 10; a++)
            {
                Vector3 _node_point = _pos_x1 + new Vector3(GridSize * a, 0, 0);
                Vector3 _offset     = new Vector3(-GridSize * 0.25f, 10, GridSize * 0.5f);

                CustomGizmos.Text("" + _node_point.x + ":" + _node_point.z, _node_point + _offset, GridColor, 14, FontStyle.Normal);
            }
        }
    }
Ejemplo n.º 6
0
 /// <summary>
 /// Resets memory footprint for bezier if necessary
 /// </summary>
 private void MemoryReset()
 {
     if (resetMemory)
     {
         resetMemory = false;
         CustomGizmos.ResetBezierMemory();
     }
 }
Ejemplo n.º 7
0
    /// <summary>
    /// Calculates and draws a rectangle
    /// </summary>
    private void Rectangle()
    {
        float   rectSinParam = Mathf.Sin(lerpingHalfParam * 2 * Mathf.PI);
        float   rectCosParam = Mathf.Cos(lerpingHalfParam * 2 * Mathf.PI);
        Vector2 halfSizes    = new Vector2(
            1.5f * (rectSinParam * rectSizeAmplitude + (1 - rectSizeAmplitude)),
            1 * (rectCosParam * rectSizeAmplitude + (1 - rectSizeAmplitude))
            );

        CustomGizmos.DrawCrossedRect(new Vector3(4, 0, 1.5f), Vector3.forward, Vector3.right, halfSizes, 5);
    }
Ejemplo n.º 8
0
 private void DrawGridClear()
 {
     // Iterate over XY dimensions
     for (int y = 0; y < grid.height; y++)
     {
         for (int x = 0; x < grid.width; x++)
         {
             // Draw default wire grid
             CustomGizmos.DrawWireSquare(GetWorldPosition(x, y) + new Vector3(0.5f, 0.5f, 0.0f), Vector3.one * grid.cellSize, Color.white, Color.clear, "");
         }
     }
 }
Ejemplo n.º 9
0
        public void DrawOwnerGizmos()
        {
                        #if UNITY_EDITOR
            Vector3 _owner_pos = m_Owner.transform.position;
            _owner_pos.y = GetLevel();

            CustomGizmos.Triangle(_owner_pos, m_Owner.transform.forward, 2, 35);

            if (m_creature_control.Creature.Move.FieldOfView > 0)
            {
                float _angle    = m_creature_control.Creature.Move.FieldOfView;
                float _distance = m_creature_control.Creature.Move.VisualRange;

                if (_distance == 0)
                {
                    _distance = 1.5f;
                }

                float _degree = CustomGizmos.GetBestDegrees(_distance, _angle);
                CustomGizmos.ArrowArc(m_Owner.transform, _distance, _degree, -_angle, _angle, GetLevel());

                if (_angle < 180)
                {
                    Vector3 _left_pos  = Tools.GetDirectionPosition(m_Owner.transform, -_angle, _distance);
                    Vector3 _right_pos = Tools.GetDirectionPosition(m_Owner.transform, _angle, _distance);

                    CustomGizmos.OffsetPath(m_Owner.transform.position, 2, _left_pos, 1);
                    CustomGizmos.OffsetPath(m_Owner.transform.position, 2, _right_pos, 1);
                }
            }

            if (m_creature_control.Creature.Move.GroundOrientation == GroundOrientationType.NONE || m_creature_control.Creature.Move.GroundOrientation == GroundOrientationType.QUADRUPED)
            {
                if (m_creature_control.Creature.Move.GroundOrientationPlus)
                {
                    UnityEditor.Handles.CubeCap(0, m_creature_control.Creature.Move.FrontLeftPositionGround, m_Owner.transform.rotation, 0.1f);
                    UnityEditor.Handles.CubeCap(0, m_creature_control.Creature.Move.BackLeftPositionGround, m_Owner.transform.rotation, 0.1f);
                    UnityEditor.Handles.CubeCap(0, m_creature_control.Creature.Move.FrontRightPositionGround, m_Owner.transform.rotation, 0.1f);
                    UnityEditor.Handles.CubeCap(0, m_creature_control.Creature.Move.BackRightPositionGround, m_Owner.transform.rotation, 0.1f);

                    Gizmos.DrawLine(m_creature_control.Creature.Move.FrontLeftPositionGround, m_creature_control.Creature.Move.FrontLeftPosition);
                    Gizmos.DrawLine(m_creature_control.Creature.Move.BackLeftPositionGround, m_creature_control.Creature.Move.BackLeftPosition);
                    Gizmos.DrawLine(m_creature_control.Creature.Move.FrontRightPositionGround, m_creature_control.Creature.Move.FrontRightPosition);
                    Gizmos.DrawLine(m_creature_control.Creature.Move.BackRightPositionGround, m_creature_control.Creature.Move.BackRightPosition);

                    UnityEditor.Handles.CubeCap(0, m_creature_control.Creature.Move.FrontLeftPosition, m_Owner.transform.rotation, 0.1f);
                    UnityEditor.Handles.CubeCap(0, m_creature_control.Creature.Move.BackLeftPosition, m_Owner.transform.rotation, 0.1f);
                    UnityEditor.Handles.CubeCap(0, m_creature_control.Creature.Move.FrontRightPosition, m_Owner.transform.rotation, 0.1f);
                    UnityEditor.Handles.CubeCap(0, m_creature_control.Creature.Move.BackRightPosition, m_Owner.transform.rotation, 0.1f);
                }
            }
                        #endif
        }
Ejemplo n.º 10
0
    /// <summary>
    /// Calculates and draws a bezier curve with arrow
    /// </summary>
    private void BezierArrow()
    {
        Vector3        currentDirection = Quaternion.AngleAxis(currentAngle, new Vector3(-1, 0, 1).normalized) * Vector3.up;
        List <Vector3> bezierPoints     = new List <Vector3>();

        bezierPoints.Add(new Vector3(3, 0, 4));
        bezierPoints.Add(new Vector3(1, 0, 4));
        bezierPoints.Add(new Vector3(2, 0, 5));
        bezierPoints.Add(new Vector3(0, 0, 5));
        float bezSinParam = Mathf.Sin(lerpingHalfParam * 2 * Mathf.PI);

        CustomGizmos.BezierWithArrow(bezierPoints, 10, (bezSinParam + 1) / 2, arrowTipSize, currentDirection);
    }
Ejemplo n.º 11
0
    void OnDrawGizmos()
    {
        if (visualizing)
        {
            Vector3 position = new Vector3(200, Screen.height - 100, 0);
            CustomGizmos.drawUIString(currentGesture.NumberPoints + "", position, Color.green);
            position += Vector3.down * 20;
            foreach (string error in currentErrors)
            {
                CustomGizmos.drawUIString(error, position, Color.green);
                position += Vector3.down * 20;
            }

            currentGesture.DrawGizmos();
        }
    }
Ejemplo n.º 12
0
 private void DrawGridAirSealed()
 {
     // Iterate over XY dimensions
     for (int y = 0; y < grid.height; y++)
     {
         for (int x = 0; x < grid.width; x++)
         {
             // Draw grid indicating air sealed spaces
             if (StaticMaps.worldTileData[x, y].IsSealed())
             {
                 CustomGizmos.DrawWireSquare(GetWorldPosition(x, y) + new Vector3(0.5f, 0.5f, 0.0f), Vector3.one * grid.cellSize, Color.white, new Color(0.0f, 0.0f, 0.75f, 0.4f), "");
             }
             else
             {
                 CustomGizmos.DrawWireSquare(GetWorldPosition(x, y) + new Vector3(0.5f, 0.5f, 0.0f), Vector3.one * grid.cellSize, Color.white, Color.clear, "");
             }
         }
     }
 }
Ejemplo n.º 13
0
 private void DrawGridBuildingBlocked()
 {
     // Iterate over XY dimensions
     for (int y = 0; y < grid.height; y++)
     {
         for (int x = 0; x < grid.width; x++)
         {
             // Draw grid indicating tiles which cannot be built upon
             if (StaticMaps.worldTileData[x, y].GetCanBuildUpon())
             {
                 CustomGizmos.DrawWireSquare(GetWorldPosition(x, y) + new Vector3(0.5f, 0.5f, 0.0f), Vector3.one * grid.cellSize, Color.white, Color.clear, "");
             }
             else
             {
                 CustomGizmos.DrawWireSquare(GetWorldPosition(x, y) + new Vector3(0.5f, 0.5f, 0.0f), Vector3.one * grid.cellSize, Color.white, new Color(0.75f, 0.0f, 0.0f, 0.4f), "");
             }
         }
     }
 }
        public override void DrawGizmos(bool _draw)
        {
            if (!_draw || !this.enabled || Entity == null)
            {
                return;
            }

            CustomGizmos.Color(GizmoColor);
            Gizmos.DrawSphere(this.transform.position, GizmoSize);
            //Gizmos.DrawWireCube( this.transform.position, Vector3.one );

            if (Entity.EntityType == ICE.World.EnumTypes.EntityClassType.Waypoint)
            {
                ICECreatureWaypoint _waypoint = Entity as ICECreatureWaypoint;

                if (_waypoint != null && _waypoint.Links.Enabled)
                {
                    foreach (WaypointLinkObject _link in _waypoint.Links.Links)
                    {
                        if (_link.Enabled && _link.Waypoint != null)
                        {
                            float _dist = 0.25f;

                            Vector3 _pos_origin = this.transform.position;
                            Vector3 _pos_target = _link.Waypoint.transform.position;
                            Vector3 _dir        = (_pos_target - _pos_origin).normalized;
                            //_dir.y = 0;
                            Vector3 _rot_dir = _dir;
                            _rot_dir.y = 0;
                            _rot_dir   = Quaternion.Euler(0, 90, 0) * _rot_dir;

                            Gizmos.DrawLine(_pos_origin + (_rot_dir * _dist), _pos_target + (_rot_dir * _dist));
                            //CustomGizmos.Arrow( _pos_origin + ( _rot_dir * _dist ) + ( _dir * 2 ),  _dir );
                            CustomGizmos.ArrowHead(_pos_origin + (_rot_dir * _dist) + (_dir * 1.0f), _dir, _dist * 2, _dist * 100);
                            CustomGizmos.ArrowHead(_pos_origin + (_rot_dir * _dist) + (_dir * 1.5f), _dir, _dist * 2, _dist * 100);
                            CustomGizmos.ArrowHead(_pos_origin + (_rot_dir * _dist) + (_dir * 2.0f), _dir, _dist * 2, _dist * 100);
                            //CustomGizmos.Arrow( 0,  _pos_origin + ( _rot_dir * _dist ) + ( _dir * 1 ), Quaternion.LookRotation( _dir ), _dist * 10 );
                        }
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public void DrawMoveGizmos()
        {
                        #if UNITY_EDITOR
            if (m_Owner == null || m_creature_control.Creature.Move.CurrentTarget == null)
            {
                return;
            }

            TargetObject _target = m_creature_control.Creature.Move.CurrentTarget;

            Vector3 _move_position         = m_creature_control.Creature.Move.MovePosition;
            Vector3 _target_move_position  = _target.TargetMovePosition;
            float   _move_stop_distance    = m_creature_control.Creature.Move.CurrentMove.MoveStopDistance;
            float   _move_lateral_variance = m_creature_control.Creature.Move.CurrentMove.MoveLateralVariance;

            Vector3 _owner_pos = m_Owner.transform.position;
            _owner_pos.y            = GetLevel();
            _move_position.y        = GetLevel();
            _target_move_position.y = GetLevel();



            CustomGizmos.OffsetPath(_owner_pos, 2, _move_position, _move_stop_distance);      // PATH FROM CREATURE TO NEXT MOVE POSITION
            CustomGizmos.Circle(_move_position, _move_stop_distance, 5, false);               // STOP DISTANCE RANGE

            if (m_creature_control.Creature.Move.CurrentMove.Type != MoveType.ESCAPE)
            {
                CustomGizmos.OffsetPath(_move_position, _move_stop_distance, _target_move_position, _target.TargetStopDistance);                      // PATH NEXT MOVE POSITION TO TARGET MOVE POSITION
            }
            if (_move_lateral_variance > 0)
            {
                float _max_range = _move_stop_distance + _move_lateral_variance;

                CustomGizmos.ZickZackCircle(_move_position, _move_lateral_variance, "", false); // RANDOM RANGE
                CustomGizmos.Circle(_move_position, _max_range, 5, true);                       // MAX MOVE RANGE
            }
                        #endif
        }
Ejemplo n.º 16
0
        private void OnDrawGizmos()
        {
            if (Astronomy.SunLight == null)
            {
                return;
            }

            if (!Application.isPlaying)
            {
                Astronomy.SunLight.transform.localRotation = Astronomy.Rotation();
            }

            Gizmos.color = Color.blue;
            Gizmos.DrawLine(Astronomy.SunLight.transform.position + (Astronomy.SunLight.transform.forward * Astronomy.Radius * 0.75f), Astronomy.SunLight.transform.position + (Astronomy.SunLight.transform.forward * Astronomy.Radius));
            //Gizmos.DrawLine( Sun.transform.position - ( Sun.transform.forward * Radius * 0.75f ), Sun.transform.position - ( Sun.transform.forward * Radius ) );
            CustomGizmos.Circle(Astronomy.SunLight.transform.position, Astronomy.SunLight.transform.up, Astronomy.Radius);
            CustomGizmos.Arrow(Astronomy.SunLight.transform.position + (Astronomy.SunLight.transform.forward * Astronomy.Radius * 0.75f), Astronomy.SunLight.transform.forward * -2, 10);
            CustomGizmos.HandlesColor(Gizmos.color);
            CustomGizmos.Arrow(0, Astronomy.SunLight.transform.position - (Astronomy.SunLight.transform.forward * Astronomy.Radius), Astronomy.SunLight.transform.rotation, 50);


            if (m_PathPositions.Count > 1000)
            {
                m_PathPositions.RemoveAt(0);
            }

            Vector3 _prior_pos = Vector3.zero;

            foreach (Vector3 _pos in m_PathPositions)
            {
                if (_prior_pos != Vector3.zero)
                {
                    Gizmos.DrawLine(_prior_pos, _pos);
                }

                _prior_pos = _pos;
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Calculates lines positions and draws them
 /// </summary>
 private void Lines()
 {
     CustomGizmos.DrawLine(new Vector3(1f, 0, 0), new Vector3(1f, 0, 1), 1f - sinParam * linesAmplitude - linesOffset, 0);
     CustomGizmos.DrawLine(new Vector3(1.2f, 0, 0), new Vector3(1.2f, 0, 1), sinParam * linesAmplitude + linesOffset);
     CustomGizmos.DrawLine(new Vector3(1.4f, 0, 0), new Vector3(1.4f, 0, 1), 0, 1 - sinParam * linesAmplitude - linesOffset);
 }
        private void DrawRegisterGizmos()
        {
            ICECreatureRegister _register = ICECreatureRegister.Instance;

            if (_register == null)
            {
                return;
            }

            if (!_register.UseDebug)
            {
                return;
            }

            Gizmos.color = new Color(Color.blue.r, Color.blue.g, Color.blue.b, 0.75f);
            Vector3 _s = new Vector3(0.5f, 0.15f, 0.5f);

            Gizmos.DrawCube(transform.position + (Vector3.up * 0.25f), _s);
            Gizmos.DrawCube(transform.position + (Vector3.up * 0.50f), _s);
            Gizmos.DrawCube(transform.position + (Vector3.up * 0.75f), _s);
            Gizmos.color = new Color(Color.blue.r, Color.blue.g, Color.blue.b, 1f);
            CustomGizmos.Text("CREATURE REGISTER", transform.position, Gizmos.color, 14, FontStyle.Bold);

            foreach (ReferenceGroupObject _group in _register.ReferenceGroupObjects)
            {
                if (_group.ReferenceGameObject == null)
                {
                    continue;
                }

                if (_register.RegisterDebug.ShowReferenceGizmos && !_group.Status.isPrefab)
                {
                    Gizmos.color = new Color(_register.RegisterDebug.ColorReferences.r, _register.RegisterDebug.ColorReferences.g, _register.RegisterDebug.ColorReferences.b, 0.25f);
                    Vector3 _pos  = _group.ReferenceGameObject.transform.position;
                    float   _size = Mathf.Clamp(_group.ReferenceGameObject.transform.lossyScale.magnitude, 0.25f, 1) * 0.25f;
                    Gizmos.DrawSphere(_pos, _size);
                    _pos.y += 2;

                    if (_register.RegisterDebug.ShowReferenceGizmosText)
                    {
                        Gizmos.color = new Color(_register.RegisterDebug.ColorReferences.r, _register.RegisterDebug.ColorReferences.g, _register.RegisterDebug.ColorReferences.b, 1f);
                        CustomGizmos.Text(_group.ReferenceGameObject.name + " (SCENE REFERENCE)", _pos, Gizmos.color, 12, FontStyle.Italic);
                    }
                }

                if (_register.RegisterDebug.ShowCloneGizmos)
                {
                    foreach (GameObject _item in _group.ActiveObjects)
                    {
                        if (_group.ReferenceGameObject == _item)
                        {
                            continue;
                        }

                        Gizmos.color = new Color(_register.RegisterDebug.ColorClones.r, _register.RegisterDebug.ColorClones.g, _register.RegisterDebug.ColorClones.b, 0.25f);
                        Vector3 _pos  = _item.transform.position;
                        float   _size = Mathf.Clamp(_item.transform.lossyScale.magnitude, 0.25f, 1) * 0.25f;
                        Gizmos.DrawSphere(_pos, _size);

                        if (_register.RegisterDebug.ShowCloneGizmosText)
                        {
                            _pos.y      += 2;
                            Gizmos.color = new Color(_register.RegisterDebug.ColorClones.r, _register.RegisterDebug.ColorClones.g, _register.RegisterDebug.ColorClones.b, 1f);
                            CustomGizmos.Text(_item.name + " (CLONE)", _pos, Gizmos.color, 12, FontStyle.Italic);
                        }
                    }
                }

                if (_register.RegisterDebug.ShowSpawnPointGizmos && _group.PoolManagementEnabled)
                {
                    foreach (SpawnPointObject _point in _group.ValidSpawnPoints)
                    {
                        if (_point.SpawnPointGameObject == null)
                        {
                            continue;
                        }

                        GameObject[] _objects = _point.GetAllSpawnPointGameObjects();

                        foreach (GameObject _object in _objects)
                        {
                            Gizmos.color = new Color(_register.RegisterDebug.ColorSpawnPoints.r, _register.RegisterDebug.ColorSpawnPoints.g, _register.RegisterDebug.ColorSpawnPoints.b, 0.25f);
                            Vector3 _pos  = _object.transform.position;
                            float   _size = Mathf.Clamp(_object.transform.lossyScale.magnitude, 0.25f, 1) * 0.25f;
                            Gizmos.DrawSphere(_pos, _size);

                            if (_point.UseRandomRect)
                            {
                                CustomGizmos.Box(_object.transform, _point.RandomRect, new Vector3(0, _point.RandomRect.y * 0.5f, 0));
                            }
                            else
                            {
                                CustomGizmos.Circle(_pos, _point.SpawningRangeMin, CustomGizmos.GetBestDegrees(_point.SpawningRangeMin, 360), false);
                                CustomGizmos.BeamCircle(_pos, _point.SpawningRangeMax, CustomGizmos.GetBestDegrees(_point.SpawningRangeMax, 360), false, _point.SpawningRangeMax - _point.SpawningRangeMin, "", false, true);
                            }

                            if (_register.RegisterDebug.ShowSpawnPointGizmosText)
                            {
                                _pos.z      += _point.SpawningRangeMax;
                                _pos.y      += 4;
                                Gizmos.color = new Color(_register.RegisterDebug.ColorSpawnPoints.r, _register.RegisterDebug.ColorSpawnPoints.g, _register.RegisterDebug.ColorSpawnPoints.b, 1f);
                                CustomGizmos.Text(_point.SpawnPointGameObject.name + " (SP)", _pos, Gizmos.color, 12, FontStyle.Italic);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
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
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Draws the interaction.
        /// </summary>
        public void DrawInteraction()
        {
            if (CreatureControl.Creature.Interaction.Interactors.Count == 0 || ShowInteractor == false)
            {
                return;
            }

            for (int i = 0; i < CreatureControl.Creature.Interaction.Interactors.Count; i++)
            {
                InteractorObject _interactor = CreatureControl.Creature.Interaction.Interactors[i];

                if (!_interactor.Enabled)
                {
                    continue;
                }

                List <GameObject> _target_game_objects = GetCreaturesByName(_interactor.Name);

                if (_target_game_objects != null && _target_game_objects.Count > 0)
                {
                    foreach (GameObject _target_game_object in _target_game_objects)
                    {
                        Vector3 _interactor_pos = _target_game_object.transform.position;

                        TargetObject _target = new TargetObject(TargetType.INTERACTOR);

                        _target.TargetGameObject = _target_game_object;
                        _target.BehaviourModeKey = _interactor.BehaviourModeKey;
                        _target.Selectors.Copy(_interactor.Selectors);
                        _target.UpdateOffset(_interactor.DefaultOffset);
                        _target.TargetStopDistance          = _interactor.DefaultStopDistance;
                        _target.TargetRandomRange           = _interactor.DefaultRandomRange;
                        _target.TargetSmoothingMultiplier   = 0;                      //_interactor.DefaultSmoothingMultiplier; // TODO:REWORK TargetSmoothingMultiplier
                        _target.TargetIgnoreLevelDifference = _interactor.DefaultIgnoreLevelDifference;

                        DrawTargetGizmos(_target);

                        // DIRECTION
                        CustomGizmos.Arrow(_target.TargetPosition, _target.TargetDirection * _target.TargetStopDistance, 0.5f, 20);

                        Vector3 _last_move_position = _target.TargetMovePosition;
                        float   _last_stop_distance = _target.TargetStopDistance;

                        _last_move_position.y = GetLevel();

                        Color _default_color = Gizmos.color;
                        Color _target_color  = (_target.Active?ActiveTargetColor:TargetColor);

                        foreach (InteractorRuleObject _rule in _interactor.Rules)
                        {
                            if (!_rule.Enabled)
                            {
                                continue;
                            }

                            _target = new TargetObject(TargetType.INTERACTOR);

                            _target.TargetGameObject = _target_game_object;
                            _target.BehaviourModeKey = _rule.BehaviourModeKey;
                            _target.Selectors.Copy(_rule.Selectors);

                            _target.UpdateOffset(_interactor.DefaultOffset);
                            _target.TargetStopDistance          = _interactor.DefaultStopDistance;
                            _target.TargetRandomRange           = _interactor.DefaultRandomRange;
                            _target.TargetSmoothingMultiplier   = 0;                          //_interactor.DefaultSmoothingMultiplier; // TODO:REWORK TargetSmoothingMultiplier
                            _target.TargetIgnoreLevelDifference = _interactor.DefaultIgnoreLevelDifference;

                            if (_rule.OverrideTargetMovePosition)
                            {
                                _target.UpdateOffset(_rule.Offset);
                                _target.TargetStopDistance          = _rule.StopDistance;
                                _target.TargetRandomRange           = _rule.RandomRange;
                                _target.TargetSmoothingMultiplier   = 0;
                                _target.TargetIgnoreLevelDifference = _rule.IgnoreLevelDifference;
                            }

                            DrawTargetGizmos(_target);

                            Vector3 _move_position = _target.TargetMovePosition;
                            _move_position.y = GetLevel();

                            Gizmos.color = _target_color;
                            if (_last_move_position != Vector3.zero)
                            {
                                CustomGizmos.OffsetPath(_last_move_position, _last_stop_distance, _move_position, _target.TargetStopDistance, true);
                            }

                            _last_stop_distance = _target.TargetStopDistance;
                            _last_move_position = _move_position;
                        }

                        Gizmos.color = _target_color;
                        if (_last_move_position != Vector3.zero)
                        {
                            CustomGizmos.OffsetPath(_last_move_position, _last_stop_distance, _interactor_pos, 0, false);
                        }

                        Gizmos.color = _default_color;
                        //CustomGizmos.OffsetPath( _default_data.OffsetPosition, _default_data.StopDistance, _interactor_pos, 0 );
                    }
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Draws the target gizmos.
        /// </summary>
        /// <param name="_target">_target.</param>
        private void DrawTargetGizmos(TargetObject _target, Color _target_color, Color _selection_color)
        {
                        #if UNITY_EDITOR
            if (_target == null || _target.IsValid == false)
            {
                return;
            }

            Vector3 _target_pos                = _target.TargetPosition;
            Vector3 _target_direction          = _target.TargetDirection;
            Vector3 _target_pos_offset         = _target.TargetOffsetPosition;
            Vector3 _target_pos_move           = _target.TargetMovePosition;
            float   _target_selection_distance = _target.Selectors.SelectionRange;
            float   _target_selection_angle    = _target.Selectors.SelectionAngle;

            Vector3 _target_pos_top    = _target_pos;
            Vector3 _target_pos_bottom = _target_pos;

            float _level = GetLevel();
            _target_pos.y        = GetLevel();
            _target_pos_offset.y = GetLevel();
            _target_pos_move.y   = GetLevel();
            _target_pos_top.y    = GetLevel() + 3;
            _target_pos_bottom.y = 0;

            Color _previous_color = Gizmos.color;
            Gizmos.color = _target_color;
            UnityEditor.Handles.color = _target_color;

            // SELECTION RANGE BEGIN

            /*if( ShowSolidInteractionRange && SolidInteractionAlpha > 0 )
             * {
             *      UnityEditor.Handles.color = _selection_color;
             *      UnityEditor.Handles.DrawWireDisc( _target_pos , Vector3.up, _target_selection_distance );
             *
             *      Color _selection_color_transparent = _selection_color;
             *      _selection_color_transparent.a = SolidInteractionAlpha;
             *      UnityEditor.Handles.color = _selection_color_transparent;
             *      UnityEditor.Handles.DrawSolidDisc( _target_pos , Vector3.up, _target_selection_distance );
             * }
             * else
             * {
             *      UnityEditor.Handles.color = _selection_color;
             *      UnityEditor.Handles.DrawWireDisc( _target_pos , Vector3.up, _target_selection_distance );
             * }*/


            //if( _target_selection_angle > 0 && _target_selection_angle <= 180 )
            {
                if (_target_selection_angle == 0)
                {
                    _target_selection_angle = 180;
                }


                CustomGizmos.ArrowArc(_target.TargetGameObject.transform, _target_selection_distance, CustomGizmos.GetBestDegrees(_target_selection_distance, _target_selection_angle), -_target_selection_angle, _target_selection_angle, _level, true);


                if (_target_selection_angle < 180)
                {
                    Transform _target_transform = _target.TargetGameObject.transform;
                    Vector3   _center           = _target_transform.position;
                    Vector3   _center_pos       = Tools.GetDirectionPosition(_target_transform, 0, _target_selection_distance + (_target_selection_distance / 10));
                    Vector3   _left_pos         = Tools.GetDirectionPosition(_target_transform, -_target_selection_angle, _target_selection_distance - 0.25f);
                    Vector3   _right_pos        = Tools.GetDirectionPosition(_target_transform, _target_selection_angle, _target_selection_distance - 0.25f);

                    _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);                       /**/
                }
            }
            // SELECTION RANGE END



            // TARGET ICON BEGIN
            Gizmos.DrawLine(_target_pos_bottom, _target_pos_top);
            Gizmos.DrawIcon(_target_pos_top, "ice_waypoint.png");
            // TARGET ICON END


            // TARGET STOP DISTANCE BEGIN
            if (_target.TargetIgnoreLevelDifference)
            {
                CustomGizmos.Circle(_target_pos_move, _target.TargetStopDistance, 5, false);                   // IGNORES LEVEL DIFFERNCE SO WE DRAW JUST A CIRCLE
            }
            else
            {
                Gizmos.DrawWireSphere(_target_pos_move, _target.TargetStopDistance);                  // IF THE LEVEL IS IMPORTANT FOR THE STOP DISTANCE WE DRAW A SPHERE
            }
            // TARGET STOP DISTANCE END

            // MAX AND RANDOM RANGE BEGIN
            CustomGizmos.Circle(_target_pos_offset, _target.TargetRandomRange, 5, false);                             // RANDOM RANGE
            CustomGizmos.Circle(_target_pos_offset, _target.TargetRandomRange + _target.TargetStopDistance, 5, true); // MAX RANGE
            // MAX AND RANDOM RANGE END

            // SPECIAL CASES FOR INTERACTOR WHICH COULD HAVE SEVERAL SELECTION RANGES
            if (_target.Type != TargetType.INTERACTOR)
            {
                if (Vector3.Distance(_target_pos_move, _target_pos_offset) <= _target.TargetStopDistance)
                {
                    CustomGizmos.OffsetPath(_target_pos, 0.0f, _target_pos_offset, _target.TargetStopDistance);
                }
                else
                {
                    Gizmos.DrawLine(_target_pos, _target_pos_offset);
                }

                CustomGizmos.OffsetPath(_target_pos_offset, 0.0f, _target_pos_move, _target.TargetStopDistance);

                // DIRECTION
                CustomGizmos.Arrow(_target_pos, _target_direction * _target.TargetStopDistance, 0.5f, 20);
            }

            BehaviourModeObject _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(_target.BehaviourModeKey);
            DrawBehaviourModeGizmos(_target, _mode);

            // PRIVIOUS COLOR
            Gizmos.color = _previous_color;
            UnityEditor.Handles.color = _previous_color;
                        #endif
        }
    }

    /// <summary>
    /// Pointer object.
    /// </summary>
    [System.Serializable]
    public class PathObject : System.Object
    {
        public void NavMeshPath(NavMeshAgent _agent)
        {        /*
                  * GameObject _object = new GameObject();
                  * _object.transform.parent = _agent.gameObject.transform;
                  * LineRenderer _line = _object.AddComponent<LineRenderer>();
                  * _line.SetColors(Color.white,Color.white);
                  * _line.SetWidth(0.1f,0.1f);
                  * //Get def material
                  *
                  * _line.gameObject.renderer.material.color = Color.white;
                  * _line.gameObject.renderer.material.shader = Shader.Find("Sprites/Default");
                  * _line.gameObject.AddComponent<LineScript>();
                  * _line.SetVertexCount(_agent.path.corners.Length+1);
                  * int i = 0;
                  * foreach(Vector3 v in p.corners)
                  * {
                  *     _line.SetPosition(i,v);
                  *     //Debug.Log("position agent"+g.transform.position);
                  *     //Debug.Log("position corner = "+v);
                  *     i++;
                  * }
                  * _line.SetPosition(p.corners.Length,_agent.destination);
                  * _line.gameObject.tag = "ligne";*/
        }
    }
Ejemplo n.º 22
0
    /// <summary>
    /// Draws a rotating circle
    /// </summary>
    private void Circle()
    {
        Vector3 currentDirection = Quaternion.AngleAxis(currentAngle, new Vector3(-1, 0, 1).normalized) * Vector3.up;

        CustomGizmos.DrawRegularPoligon(new Vector3(5, 0, 4), Vector3.right, circleRadius, 30, currentDirection);
    }
Ejemplo n.º 23
0
 protected static void DrawGizmoStringTopRight(string text, Color color)
 {
     CustomGizmos.drawUIString(text, new Vector3(Screen.width - 100, Screen.height - 100, 0), color);
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Draws the patrol.
        /// </summary>
        public void DrawPatrol()
        {
            if (!CreatureControl.Creature.Missions.Patrol.TargetReady() || ShowPatrol == false)
            {
                return;
            }

            TargetObject _target = null;
            Vector3      _target_move_position = Vector3.zero;
            float        _target_stop_distance = 0;

            WaypointObject _last_waypoint_target = CreatureControl.Creature.Missions.Patrol.Waypoints.GetLastValidWaypoint();

            Vector3 _last_target_move_position = Vector3.zero;
            float   _last_target_stop_distance = 0;

            if (_last_waypoint_target != null)
            {
                _last_target_move_position   = _last_waypoint_target.TargetMovePosition;
                _last_target_move_position.y = GetLevel();
                _last_target_stop_distance   = _last_waypoint_target.TargetStopDistance;
            }

            for (int i = 0; i < CreatureControl.Creature.Missions.Patrol.Waypoints.Waypoints.Count; i++)
            {
                _target = (TargetObject)CreatureControl.Creature.Missions.Patrol.Waypoints.Waypoints[i];

                if (_target.IsValid == false)
                {
                    continue;
                }

                _target_move_position   = _target.TargetMovePosition;
                _target_move_position.y = GetLevel();
                _target_stop_distance   = _target.TargetStopDistance;

                if (CreatureControl.Creature.Missions.Patrol.Waypoints.Waypoints[i].Enabled)
                {
                    DrawTargetGizmos(_target);

                    Color _default_color = Gizmos.color;
                    Gizmos.color = MoveProjectedPathColor;
                    CustomGizmos.OffsetPath(_last_target_move_position, _last_target_stop_distance, _target_move_position, _target_stop_distance);
                    Gizmos.color = _default_color;

                    _last_target_move_position = _target_move_position;
                    _last_target_stop_distance = _target_stop_distance;
                }
                else
                {
                    Color _color = TargetColor;
                    _color.a = 0.25f;
                    DrawTargetGizmos(_target, _color);
                }

                if (!Application.isPlaying)
                {
                    BehaviourModeObject _mode = null;
                    _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Missions.Patrol.GetBehaviourModeTravelByIndex(i));
                    DrawBehaviourModeGizmos(_target, _mode);

                    _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Missions.Patrol.GetBehaviourModePatrolByIndex(i));
                    DrawBehaviourModeGizmos(_target, _mode);

                    _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Missions.Patrol.GetBehaviourModeLeisureByIndex(i));
                    DrawBehaviourModeGizmos(_target, _mode);

                    _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Missions.Patrol.GetBehaviourModeRendezvousByIndex(i));
                    DrawBehaviourModeGizmos(_target, _mode);
                }
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Calculates and draws bezier curves
 /// </summary>
 private void Bezier()
 {
     CustomGizmos.Bezier(new Vector3(1, 0, 2), new Vector3(.5f, 0, 3), new Vector3(0, 0, 2), 10);
     CustomGizmos.CubicBezier(new Vector3(1, 0, 3), new Vector3(.5f, 0, 4), new Vector3(0, 0, 3), new Vector3(-1, 0, 4), 10);
 }
Ejemplo n.º 26
0
    /// <summary>
    /// Calculates and draws an H gizmo
    /// </summary>
    private void HGizmo()
    {
        Vector3 currentDirection = Quaternion.AngleAxis(currentAngle, Vector3.forward) * Vector3.up;

        CustomGizmos.DrawH(new Vector3(2, 0, 2), new Vector3(2, 0, 3), arrowTipSize, currentDirection);
    }
Ejemplo n.º 27
0
    /// <summary>
    /// Calculates and draws line arrows
    /// </summary>
    private void LineArrow()
    {
        Vector3 currentDirection = Quaternion.AngleAxis(currentAngle, Vector3.forward) * Vector3.up;

        CustomGizmos.DrawLineArrow(new Vector3(2, 0, 0), new Vector3(2, 0, 1), arrowTipSize, (sinParam + 1) / 2, currentDirection);
    }