Example #1
0
    //Wiresphere already exists

    /// <summary>
    ///     - Draws a cylinder.
    /// </summary>
    /// <param name='start'>
    ///     - The position of one end of the cylinder.
    /// </param>
    /// <param name='end'>
    ///     - The position of the other end of the cylinder.
    /// </param>
    /// <param name='radius'>
    ///     - The radius of the cylinder.
    /// </param>
    public static void DrawCylinder(Vector3 start, Vector3 end, float radius = 1.0f)
    {
        Vector3 up      = (end - start).normalized * radius;
        Vector3 forward = Vector3.Slerp(up, -up, 0.5f);
        Vector3 right   = Vector3.Cross(up, forward).normalized *radius;

        //Radial circles
        DebugExtension.DrawCircle(start, up, radius);
        DebugExtension.DrawCircle(end, -up, radius);
        DebugExtension.DrawCircle((start + end) * 0.5f, up, radius);

        //Side lines
        Gizmos.DrawLine(start + right, end + right);
        Gizmos.DrawLine(start - right, end - right);

        Gizmos.DrawLine(start + forward, end + forward);
        Gizmos.DrawLine(start - forward, end - forward);

        //Start endcap
        Gizmos.DrawLine(start - right, start + right);
        Gizmos.DrawLine(start - forward, start + forward);

        //End endcap
        Gizmos.DrawLine(end - right, end + right);
        Gizmos.DrawLine(end - forward, end + forward);
    }
Example #2
0
 void OnDrawGizmosSelected()
 {
     if (distanceToTarget > 0)
     {
         DebugExtension.DrawCircle(transform.position, Vector3.up, Color.white, distanceToTarget);
     }
 }
Example #3
0
 public void OFF()
 {
     isPose = false;
     DebugExtension.DrawCircle(transform.position, radius, Color.red, 3f);
     PauseScreen(false);
     SwitchBehaviour(false);
 }
    void OnDrawGizmosSelected()
    {
        Vector3 directionA = Vector3.zero;
        Vector3 directionB = Vector3.zero;

        //Calculer les deux vecteurs représentants l'angle de tir
        if (Application.isPlaying)
        {
            directionA = GeneralFunction.rotateVector(targetDirection.normalized, shootingAngle * Mathf.Deg2Rad);
            directionB = GeneralFunction.rotateVector(targetDirection.normalized, -shootingAngle * Mathf.Deg2Rad);
        }
        else
        {
            directionA = GeneralFunction.rotateVector(transform.forward, shootingAngle * Mathf.Deg2Rad);
            directionB = GeneralFunction.rotateVector(transform.forward, -shootingAngle * Mathf.Deg2Rad);
        }

        //Dessiner la portée de tir
        Gizmos.color = Color.yellow;
        DebugExtension.DrawCircle(transform.position, Vector3.up, Gizmos.color, shootingRange);

        //Dessiner l'angle de tir
        Gizmos.color = Color.gray;
        Gizmos.DrawRay(transform.position, directionA * detectionRange);
        Gizmos.DrawRay(transform.position, directionB * detectionRange);

        //Tracer un trait vers la cible
        if (targetPosition != Vector3.zero)
        {
            Gizmos.DrawLine(transform.position, targetPosition);
        }
    }
Example #5
0
    public void OnDebugRender()
    {
        for (int ob = 0; ob < m_Obstacles.Count; ++ob)
        {
            DebugExtension.DrawCircle(m_Obstacles[ob].VPos(), Color.red, m_Obstacles[ob].BRadius());
        }

        if (m_pCellSpace != null)
        {
            m_pCellSpace.OnDebugRender();
        }
        else
        {
            Vector3 size = Vector3.zero;

            size.x = cxClient;
            size.z = cyClient;

            Vector3 center = Vector3.zero;

            center.x = cxClient * 0.5f;
            center.z = cyClient * 0.5f;

            DebugExtension.DrawLocalCube(space, size, Color.blue, center);
        }
    }
    private void OnDrawGizmos()
    {
        if (debug)
        {
            Gizmos.color = Color.red;
            float curAngle = Vector3.SignedAngle(transform.forward, Vector3.right, Vector3.up);

            Gizmos.DrawRay(transform.position, MathHelpers.DegreeToVector3(curAngle + sightAngle / 2) * sightDistance);
            Gizmos.DrawRay(transform.position, MathHelpers.DegreeToVector3(curAngle - sightAngle / 2) * sightDistance);
            DebugExtension.DrawCircle(transform.position, transform.up, Color.red, sightDistance);

            DebugExtension.DrawCircle(transform.position, transform.up, Color.blue, listeningDistance);


            if (lastPlayerLocation != Vector3.one * -10000)
            {
                DebugExtension.DrawPoint(lastPlayerLocation);
            }

            Vector3    toPlayerVec = player.transform.position - transform.position;
            RaycastHit hit;

            if (Physics.Raycast(transform.position, toPlayerVec.normalized, out hit, sightDistance, seeableObject))
            {
                if (hit.transform.gameObject == player &&
                    Vector3.Angle(transform.forward, toPlayerVec) < sightAngle / 2 &&
                    Vector3.Distance(player.transform.position, transform.position) < sightDistance)
                {
                    Gizmos.color = Color.green;
                }
                Gizmos.DrawLine(transform.position, hit.point);
            }
        }
    }
Example #7
0
    void OnDrawGizmos()
    {
        DebugExtension.DrawCircle(transform.position, transform.forward, Color.white, mRadius);

        DebugExtension.DrawCircle(transform.position + transform.right * mRadius, transform.up, Color.white, mThickness / 2);
        DebugExtension.DrawCircle(transform.position - transform.right * mRadius, transform.up, Color.white, mThickness / 2);

        DebugExtension.DrawCircle(transform.position + transform.up * mRadius, transform.right, Color.white, mThickness / 2);
        DebugExtension.DrawCircle(transform.position - transform.up * mRadius, transform.right, Color.white, mThickness / 2);

        Vector3 pos = transform.position + (transform.up * mRadius + transform.right * mRadius) / Mathf.Sqrt(2);

        DebugExtension.DrawCircle(pos, transform.up - transform.right, Color.white, mThickness / 2);

        pos = transform.position - (transform.up * mRadius + transform.right * mRadius) / Mathf.Sqrt(2);
        DebugExtension.DrawCircle(pos, transform.up - transform.right, Color.white, mThickness / 2);

        pos = transform.position + (transform.up * mRadius - transform.right * mRadius) / Mathf.Sqrt(2);
        DebugExtension.DrawCircle(pos, transform.up + transform.right, Color.white, mThickness / 2);

        pos = transform.position - (transform.up * mRadius - transform.right * mRadius) / Mathf.Sqrt(2);
        DebugExtension.DrawCircle(pos, transform.up + transform.right, Color.white, mThickness / 2);

        DebugExtension.DrawArrow(transform.position, transform.forward, Color.white);
    }
 void OnDrawGizmos()
 {
     if (debugCircle)
     {
         DebugExtension.DrawCircle(sightStart.position, sightStart.up, Color.gray, radius);
     }
 }
 private void OnDrawGizmos()
 {
     if (groundCheck != null)
     {
         DebugExtension.DrawCircle(groundCheck.transform.position, Vector3.forward, Color.magenta, 0.2f);
     }
 }
Example #10
0
    /// <summary>
    ///     - Draws a cone.
    /// </summary>
    /// <param name='position'>
    ///     - The position for the tip of the cone.
    /// </param>
    /// <param name='direction'>
    ///     - The direction for the cone to get wider in.
    /// </param>
    /// <param name='angle'>
    ///     - The angle of the cone.
    /// </param>
    public static void DrawCone(Vector3 position, Vector3 direction, float angle = 45)
    {
        float length = direction.magnitude;

        Vector3 _forward = direction;
        Vector3 _up      = Vector3.Slerp(_forward, -_forward, 0.5f);
        Vector3 _right   = Vector3.Cross(_forward, _up).normalized *length;

        direction = direction.normalized;

        Vector3 slerpedVector = Vector3.Slerp(_forward, _up, angle / 90.0f);

        float dist;
        var   farPlane = new Plane(-direction, position + _forward);
        var   distRay  = new Ray(position, slerpedVector);

        farPlane.Raycast(distRay, out dist);

        Gizmos.DrawRay(position, slerpedVector.normalized * dist);
        Gizmos.DrawRay(position, Vector3.Slerp(_forward, -_up, angle / 90.0f).normalized *dist);
        Gizmos.DrawRay(position, Vector3.Slerp(_forward, _right, angle / 90.0f).normalized *dist);
        Gizmos.DrawRay(position, Vector3.Slerp(_forward, -_right, angle / 90.0f).normalized *dist);

        DebugExtension.DrawCircle(position + _forward, direction, (_forward - (slerpedVector.normalized * dist)).magnitude);
        DebugExtension.DrawCircle(position + (_forward * 0.5f), direction, ((_forward * 0.5f) - (slerpedVector.normalized * (dist * 0.5f))).magnitude);
    }
Example #11
0
        /// <summary>
        /// 爆破時の処理
        /// 周囲のコライダーを取得して四散させ、ダメージを与える
        /// 取得するコライダーはActorBaseがアタッチされたもの
        /// </summary>
        protected void AddExprForce()
        {
            DebugExtension.DrawCircle(transform.position, exprRadius, Color.green, 1f);

            //周囲のコライダー取得
            var targets = Physics2D.OverlapCircleAll(transform.position, exprRadius)
                          .Where(c =>
            {
                var component = c.GetComponent <ActorBase>();
                if (component == null)
                {
                    return(false);
                }
                return(component.HP > 0);
            })
                          .Select(c =>
            {
                Vector2 dir = c.transform.position - transform.position;
                return(new { col = c, direction = dir });
            });

            //吹き飛ばしとダメージを与える処理
            foreach (var target in targets)
            {
                AddForce(target.col, target.direction, exprPower);
                target.col.SendMessage("ExprDamaged");
            }
        }
Example #12
0
 void OnDrawGizmosSelected()
 {
     // Display the explosion radius when selected
     DebugExtension.DrawCircle(transform.position, transform.up, Color.yellow, chaseRange);
     DebugExtension.DrawCircle(transform.position, transform.up, Color.green, aggroRange);
     DebugExtension.DrawCircle(transform.position, transform.up, Color.red, attackRange);
 }
Example #13
0
        protected override void Draw()
        {
            Gizmos.color = Color;

            if (Collider.edgeRadius == 0)
            {
                for (int i = 0; i < PointsLenght - 1; i++)
                {
                    Gizmos.DrawLine(MultipliedPoints[i], MultipliedPoints[i + 1]);
                }
            }
            else
            {
                float radius = Collider.edgeRadius;

                for (int i = 0; i < PointsLenght - 1; i++)
                {
                    Vector2 HelperVector = MultipliedPoints[i + 1] - MultipliedPoints[i];
                    HelperVector.Normalize();
                    HelperVector *= radius;

                    Gizmos.DrawLine(new Vector3(MultipliedPoints[i].x - HelperVector.y, MultipliedPoints[i].y + HelperVector.x), new Vector3(MultipliedPoints[i + 1].x - HelperVector.y, MultipliedPoints[i + 1].y + HelperVector.x));
                    Gizmos.DrawLine(new Vector3(MultipliedPoints[i].x + HelperVector.y, MultipliedPoints[i].y - HelperVector.x), new Vector3(MultipliedPoints[i + 1].x + HelperVector.y, MultipliedPoints[i + 1].y - HelperVector.x));

                    DebugExtension.DrawCircle(MultipliedPoints[i], Vector3.forward, Color, radius);
                }

                DebugExtension.DrawCircle(MultipliedPoints[PointsLenght - 1], Vector3.forward, Color, Collider.edgeRadius);
            }
        }
    private void OnDrawGizmos()
    {
        Vector3 circleCenter = transform.rotation * new Vector3(0, 0, WanderDistance) + transform.position;

        DebugExtension.DrawCircle(circleCenter, Vector3.up, Color.red, WanderRadius);
        Debug.DrawLine(transform.position, circleCenter, Color.yellow);
        Debug.DrawLine(transform.position, target, Color.blue);
    }
 private void OnDrawGizmosSelected()
 {
     if (tankDirection != Vector3.zero && speed != 0)
     {
         DebugExtension.drawArrow(transform.position, tankDirection.normalized * speed, Color.white);
         DebugExtension.DrawCircle(transform.position, Vector3.up, Color.white, speed);
     }
 }
 void OnDrawGizmosSelected()
 {
     //Dessiner la zone d'explosion
     if (landPosition != Vector3.zero)
     {
         DebugExtension.DrawCircle(landPosition, Vector3.up, Color.green, explosionRange);
     }
 }
Example #17
0
    protected override void OnDrawGizmos()
    {
        base.OnDrawGizmos();
        Vector3 aCircleCenter = transform.rotation * new Vector3(0.0f, 0.0f, mWanderDistance) + transform.position;

        DebugExtension.DrawCircle(aCircleCenter, Vector3.up, Color.green, mWanderRadius);
        Debug.DrawLine(transform.position, mTarget, Color.yellow);
        DebugExtension.DrawArrow(transform.position, transform.forward * mWanderDistance, Color.grey);
    }
Example #18
0
 void Update()
 {
     DebugExtension.DrawMesh(_mesh, new Vector3(0, 2, 0), Color.cyan, Vector3.one * 0.75f);
     DebugExtension.DrawWireSphere(new Vector3(1, -1f, 0), 0.5f, Color.green);
     DebugExtension.DrawCircle(new Vector3(-0.75f, -1.25f, 0), new Vector3(1, 1, 1), 0.75f, Color.magenta);
     DebugExtension.DrawRectangularPrism(new Vector3(0, 0f, 0.5f), new Vector3(2f, 1, -0.5f),
                                         Color.blue);
     DebugExtension.DrawCube(new Vector3(-1.5f, 0.5f, 0), 1, Color.red);
 }
Example #19
0
 void OnDrawGizmos()
 {
     if (!hideGizmos)
     {
         DebugExtension.DrawCircle(transform.position, Vector3.up, Color.yellow, colliderDetectRadius + sheepStrength / 3);
         DebugExtension.DrawCircle(transform.position, Vector3.right, Color.yellow, colliderDetectRadius + sheepStrength / 3);
         DebugExtension.DrawCircle(transform.position, Vector3.forward, Color.yellow, colliderDetectRadius + sheepStrength / 3);
     }
 }
Example #20
0
    public void OnDebugRender()
    {
        if (On(behaviour_type.wander))
        {
            Vector3 m_vTCC = MathUtil.PointToWorldSpace(m_fWanderDistance * Vector3.forward,
                                                        m_entity.Heading(),
                                                        m_entity.Side(),
                                                        m_entity.VPos());

            //draw the wander circle
            DebugExtension.DrawCircle(m_vTCC, Color.green, m_fWanderRadius);

            Vector3 target = (m_vWanderTarget + m_fWanderDistance * Vector3.forward);

            target = MathUtil.PointToWorldSpace(
                target,
                m_entity.Heading(),
                m_entity.Side(),
                m_entity.VPos());

            DebugExtension.DrawLineArrow(m_entity.VPos(), target);

            DebugExtension.DrawCircle(target, Color.red, 3);
        }

        if (On(behaviour_type.arrive) || On(behaviour_type.flee))
        {
            DebugExtension.DrawLineArrow(m_entity.VPos(), m_entity.VTarget());
            DebugExtension.DrawCircle(m_entity.VTarget(), Color.red, 3);
        }

        if (On(behaviour_type.follow_path))
        {
            m_pPath.OnDebugRender();
        }

        if (On(behaviour_type.obstacle_avoidance))
        {
            float length = Prm.MinDetectionBoxLength
                           + (m_entity.Speed() / m_entity.MaxSpeed())
                           * Prm.MinDetectionBoxLength;

            Matrix4x4 matTransform = Matrix4x4.TRS(m_entity.VPos(), Quaternion.LookRotation(m_entity.Heading(), Vector3.up), Vector3.one);

            Vector3 size = Vector3.zero;
            size.x = m_entity.BRadius();
            size.y = 0f;
            size.z = length;
            Vector3 center = Vector3.zero;
            center.x = 0f;
            center.y = 0f;
            center.z = length * 0.5f;

            DebugExtension.DrawLocalCube(matTransform, size, Color.black, center);
        }
    }
Example #21
0
        private void OnDrawGizmos()
        {
            if (!circleCollider)
            {
                circleCollider = this.GetComponent <CircleCollider2D>();
            }
            Vector2 center = transform.localToWorldMatrix.MultiplyPoint3x4(circleCollider.offset);

            DebugExtension.DrawCircle(center, Vector3.forward, Color.green * 0.8f, circleCollider.radius);
        }
    private void OnDrawGizmos()
    {
        Vector3 circleCenter = transform.rotation * new Vector3(0.0f, 0.0f, WanderDistance) + transform.position;

        DebugExtension.DrawCircle(circleCenter, Vector3.forward, Color.green, WanderRadius);

        Debug.DrawLine(transform.position, target, debugColor);

        DebugExtension.DebugArrow(transform.position, transform.forward * WanderDistance, Color.red);
    }
Example #23
0
 private void OnDrawGizmos()
 {
     if (showRingGizmos && RoundDatas != null)
     {
         DebugExtension.DrawCircle(new Vector3(initialRingCenter.x, 0, initialRingCenter.y), Color.cyan, initialRingRadius);
         DebugExtension.DrawCircle(new Vector3(finalPositionCenter.x, 0, finalPositionCenter.y), Color.magenta, finalPositionRadius);
         if (RoundDatas != null)
         {
             DrawDebugRingGizmos(RoundDatas);
         }
     }
 }
Example #24
0
 void OnDrawGizmos()
 {
     foreach (Interaction interaction in interactions)
     {
         if (interaction.enabled && interaction.showGizmo)
         {
             DebugExtension.DrawCircle(transform.position, Vector3.up, interaction.gizmoColor, interaction.maxRange);
             DebugExtension.DrawCircle(transform.position, Vector3.right, interaction.gizmoColor, interaction.maxRange);
             DebugExtension.DrawCircle(transform.position, Vector3.forward, interaction.gizmoColor, interaction.maxRange);
         }
     }
 }
Example #25
0
 protected virtual void OnDrawGizmos()
 {
     if (debugTrigger == true)
     {
         if (!circle)
         {
             circle = this.GetComponent <CircleCollider2D>();
         }
         Vector2 center = transform.localToWorldMatrix.MultiplyPoint3x4(circle.offset);
         DebugExtension.DrawCircle(center, Vector3.forward, Color.green * 0.5f, circle.radius);
     }
 }
    void OnDrawGizmosSelected()
    {
        //Dessiner la portée de tir
        DebugExtension.DrawCircle(transform.position, Vector3.up, Color.green, shootingRange);
        DebugExtension.DrawCircle(transform.position, Vector3.up, Color.red, minShootingRange);

        //Dessiner spawnPos et foward
        if (cannon != null)
        {
            DebugExtension.drawArrow(cannon.transform.position, cannon.transform.forward, Color.white);
        }
    }
Example #27
0
 protected override void OnDrawGizmos()
 {
     base.OnDrawGizmos();
     if (isGizmoOn && leafParticles != null)
     {
         Vector2 pos;
         for (int i = 0; i < leafParticles.Count; i++)
         {
             pos = transform.localToWorldMatrix.MultiplyPoint3x4(leafParticles[i].Position);
             DebugExtension.DrawCircle(pos, Vector3.forward, gizmoColor, base.leafRadius);
         }
     }
 }
Example #28
0
    // Use this for debuging
    void OnDrawGizmosSelected()
    {
        if (Application.isPlaying)
        {
            if (valueScript.showMouvementGizmos)
            {
                Gizmos.color = valueScript.mouvementGizmosColor;

                //Dessiner les directions normales
                for (int i = 0; i < valueScript.nbDirection; i++)
                {
                    if (directionsValues[i] >= 0)
                    {
                        Vector3 arrowDirection = directions[i] * (directionsValues[i] + 1);
                        DebugExtension.drawArrow(this.transform.position, arrowDirection, Color.white);
                    }
                    else
                    {
                        Vector3 arrowDirection = directions[i] * (-directionsValues[i]);
                        DebugExtension.drawArrow(this.transform.position, arrowDirection, Color.red);
                    }
                }

                //Dessiner la direction immobile
                if (showimmobileDirection)
                {
                    if (immobileValue > 0)
                    {
                        DebugExtension.drawArrow(this.transform.position, Vector3.up * immobileValue, Color.white);
                    }
                    else if (immobileValue < 0)
                    {
                        DebugExtension.drawArrow(this.transform.position, Vector3.up * -immobileValue, Color.red);
                    }
                }

                //Dessiner la position du prochain update
                if (distanceUntilNextUpdate != 0)
                {
                    DebugExtension.DrawCircle(this.transform.position, Vector3.up, Gizmos.color, distanceUntilNextUpdate);                          //Draw distance
                    DebugExtension.drawArrow(this.transform.position, this.transform.forward * distanceUntilNextUpdate, Gizmos.color);              //Draw forward direction
                }

                //Draw a ray to the current waypoint
                if (valueScript.enemyAI.waypointTarget != Vector3.zero)
                {
                    Gizmos.DrawLine(this.transform.position, valueScript.enemyAI.waypointTarget);
                }
            }
        }
    }
Example #29
0
        private void OnDrawGizmos()
        {
            if (showDebugGizmos)
            {
                DebugExtension.DrawCircle(new Vector3(mapCenter.x, altitude, mapCenter.y), Color.cyan, centerRadius);
                DebugExtension.DrawCircle(new Vector3(mapCenter.x, altitude, mapCenter.y), Color.magenta, allowDropRadius);

                Gizmos.color = Color.green;
                Gizmos.DrawLine(new Vector3(startDropPosition.x, altitude, startDropPosition.y), new Vector3(endDropPosition.x, altitude, endDropPosition.y));
                Gizmos.color = Color.yellow;
                Gizmos.DrawLine(new Vector3(launchPosition.x, altitude, launchPosition.y), new Vector3(startDropPosition.x, altitude, startDropPosition.y));
                Gizmos.color = Color.red;
                Gizmos.DrawLine(new Vector3(endDropPosition.x, altitude, endDropPosition.y), new Vector3(destinationPosition.x, altitude, destinationPosition.y));
            }
        }
        void OnDrawGizmos()
        {
            for (int i = 0; i < sheepSpawnerPlayer1.Count; i++)
            {
                DebugExtension.DrawPoint(sheepSpawnerPlayer1[i].transform.position, Color.red, 1);
                DebugExtension.DrawCircle(sheepSpawnerPlayer1[i].transform.position, Vector3.up, Color.red, spawnerRadius);
            }
            for (int i = 0; i < sheepSpawnerPlayer2.Count; i++)
            {
                DebugExtension.DrawPoint(sheepSpawnerPlayer2[i].transform.position, Color.blue, 1);
                DebugExtension.DrawCircle(sheepSpawnerPlayer2[i].transform.position, Vector3.up, Color.blue, spawnerRadius);
            }

            DebugExtension.DrawPoint(spawnerPlayer1.transform.position, Color.red, 3);
            DebugExtension.DrawPoint(spawnerPlayer2.transform.position, Color.blue, 3);
        }