Ejemplo n.º 1
0
    public bool canSeePlayer()
    {
        if (fow.objToCheckList.Count > 0)
        {
            if (!chasingPlayer)
            {
                //TODO : SPREAD
                Collider2D[] guardsinRdaius = Physics2D.OverlapCircleAll(transform.position, spreadRadius);
                for (int x = 0; x < guardsinRdaius.Length; x++)
                {
                    Transform guard = guardsinRdaius[x].transform;

                    if (guard.name != this.name && ((1 << guard.gameObject.layer) & guardMask) != 0)
                    {
                        if (Outils.CalculatePathLength(guard.position, transform.position, this.gameObject) < spreadRadius * 1.5)
                        {
                            guard.GetComponent <GuardIAController_v2>().PlayerNoiseDetected(fow.objToCheckList[0].position);
                        }
                    }
                }
            }

            pointToGo.Clear();
            pointToGo.Add(fow.objToCheckList[0].position);
            agent.SetDestination(fow.objToCheckList[0].position);

            ChasinPlayerIni();

            return(true);
        }
        else
        {
            if (chasingPlayer)
            {
                switch (guardType)
                {
                case GUARD_TYPE.Normal:
                    CheckingZoneIni();
                    break;

                case GUARD_TYPE.Elite:
                    Bounds CameraBound = OrthographicBounds(Camera.main);
                    CameraBound.center = new Vector3(CameraBound.center.x, CameraBound.center.y, 0);
                    CameraBound.size   = new Vector3(CameraBound.size.x, CameraBound.size.y, 0);
                    Vector2 IABound = (Vector2)transform.position;
                    if (!CameraBound.Contains(IABound))
                    {
                        chasingPlayer = false;
                        inAlertMode   = true;

                        playerSpottedSprite.enabled = false;
                        checkingZoneSprite.enabled  = true;

                        GetComponent <FOV_vBT>().viewAngle = alertviewAngle;

                        alertModeTime_tmp = alertModeTime;
                        SetUpPatrollPoints();
                    }
                    else
                    {
                        pointToGo.Clear();
                        pointToGo.Add(ObjectRefs.Instance.player.transform.position);
                        agent.SetDestination(ObjectRefs.Instance.player.transform.position);
                    }

                    break;
                }
            }
            if (!chasingPlayer && !checkingtheZone)
            {
                GetComponent <FOV_vBT>().viewAngle = baseviewAngle;
            }
            return(false);
        }
    }