Ejemplo n.º 1
0
    //============================= DEBUGG GIZMOS =============================================

    #region Snippet for Debugg

#if (UNITY_EDITOR)
    protected virtual void OnDrawGizmosSelected()
    {
        if (Debug_Gizmos)
        {
            var currentPosition = transform.position;

            if (Debug_LineOFSight)
            {
                if (sight.target != null)
                {
                    Gizmos.color = sight.IsInSight() ? Color.green : Color.red;   //Target In Sight es un bool en una clase Externa.
                    float distanceToTarget = sight.positionDiference.magnitude;   //mySight es una instancia de la clase LineOfSight.
                    if (distanceToTarget > sight.range)
                    {
                        distanceToTarget = sight.range;
                    }
                    sight.dirToTarget.Normalize();
                    Gizmos.DrawLine(currentPosition, currentPosition + sight.dirToTarget * distanceToTarget);
                }

                Gizmos.color = Color.yellow;
                Gizmos.DrawLine(currentPosition, currentPosition + Quaternion.Euler(0, sight.angle + 1, 0) * transform.forward * sight.range);
                Gizmos.DrawLine(currentPosition, currentPosition + Quaternion.Euler(0, -sight.angle - 1, 0) * transform.forward * sight.range);

                //Gizmos.color = Color.gray;
                //Gizmos.DrawLine(currentPosition, currentPosition + Quaternion.Euler(0, minForwardAngle + 1, 0) * transform.forward * sight.range);
                //Gizmos.DrawLine(currentPosition, currentPosition + Quaternion.Euler(0, -minForwardAngle - 1, 0) * transform.forward * sight.range);

                Gizmos.color   = Color.white;
                Gizmos.matrix *= Matrix4x4.Scale(new Vector3(1, 0, 1));
                Gizmos.DrawWireSphere(currentPosition, sight.range);
            }

            if (Debug_Attacks)
            {
                Gizmos.color   = Color.red;
                Gizmos.matrix *= Matrix4x4.Scale(new Vector3(1, 0, 1));
                Gizmos.DrawWireSphere(currentPosition, AttackRange);
            }

            if (Debug_DetectionRanges)
            {
                Gizmos.color   = Color.yellow;
                Gizmos.matrix *= Matrix4x4.Scale(new Vector3(1, 0, 1));
                Gizmos.DrawWireSphere(currentPosition, minDetectionRange);

                Gizmos.color   = Color.magenta;
                Gizmos.matrix *= Matrix4x4.Scale(new Vector3(1, 0, 1));
                Gizmos.DrawWireSphere(currentPosition, MediumRange);

                Gizmos.color   = Color.magenta;
                Gizmos.matrix *= Matrix4x4.Scale(new Vector3(1, 0, 1));
                Gizmos.DrawWireSphere(currentPosition, HighRange);
            }
        }
    }
Ejemplo n.º 2
0
 void Update()
 {
     if (los.IsInSight(ship) && posSaved == false)
     {
         SaveEnemyPosition();
         Debug.Log("1");
         posSaved = true;
     }
     if (los.IsInSight(ship) && posSaved == true)
     {
         ActivateChild();
         Debug.Log("2");
     }
     if (!los.IsInSight(ship))
     {
         Movement();
         posSaved = false;
         Debug.Log("3");
     }
 }
Ejemplo n.º 3
0
    bool IsInSightToChase()
    {
        var isSight = lineOfSight.IsInSight(player.transform);

        if (keepChasing)
        {
            if (Vector3.Distance(transform.position, player.transform.position) > 7)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }


        return(isSight);
    }
    public void CheckLineOfSight()
    {
        for (int i = 0; i < enemiesMinionList.Count; i++)
        {
            var newEnemy = enemiesMinionList[i].GetComponent <MinionController>();

            if (newEnemy != null)
            {
                lineOfSight.SetTarget(newEnemy.gameObject);              // Sets current target.
                lineOfSight.IsInSight();                                 // Runs Line of Sight.

                if (lineOfSight.SawTarget() && teamBoss.isFlee == false) // If saw Target and BOSS not flee.
                {
                    currentEnemy = newEnemy.transform;
                    AlertAllies(); // Transition Allies to Pursuit.
                }
            }
        }
    }