示例#1
0
    public e_EnemyAI[] GetEnemiesOnScreen(float maxRange, LayerMask whatIsEnemy)
    {
        List <Collider> colls = new List <Collider>(Physics.OverlapSphere(Body.position, maxRange, whatIsEnemy));
        Vector2         screenPos;

        for (int i = colls.Count - 1; i >= 0; i--)
        {
            if (Cam_t.InverseTransformVector(colls[i].transform.position - Cam_t.position).z < 0 || Physics.Raycast(Cam_t.position, (colls[i].transform.position - Cam_t.position), (colls[i].transform.position - Cam_t.position).magnitude, Game_NG.GroundLayerMask))
            {
                colls.Remove(colls[i]);
            }
            else
            {
                screenPos = Cam.WorldToScreenPoint(colls[i].transform.position);
                if (screenPos.x < -20f || screenPos.x > Screen.width + 20f)
                {
                    colls.Remove(colls[i]);
                }
                else if (screenPos.y < -20f || screenPos.y > Screen.height + 20f)
                {
                    colls.Remove(colls[i]);
                }
            }
        }
        List <e_EnemyAI> enemies = new List <e_EnemyAI>();

        for (int i = 0; i < colls.Count; i++)
        {
            enemies.Add(colls[i].GetComponentInParent <e_EnemyAI>());
        }

        return(enemies.ToArray());
    }
示例#2
0
    protected override void Awake()
    {
        base.Awake();

        R        = Body.GetComponent <Rigidbody>();
        BodyColl = Body.Find("BodyColl").GetComponent <CapsuleCollider>();

        CamPivot       = transform.Find("CamPivot");
        CamSecondPivot = CamPivot.Find("CamSecondPivot");
        CamArm         = CamSecondPivot.Find("CamArm");
        AnimPivot      = CamArm.Find("AnimPivot");
        Cam_t          = AnimPivot.Find("Camera");
        Cam            = Cam_t.GetComponent <Camera>();


        LockArrow = transform.Find("LockArrowCanvas");

        CC = GetComponent <p_CameraController>();
        MC = GetComponent <p_MovementController>();
        AC = GetComponent <p_AttackController>();
        IC = GetComponent <p_InteractionController>();
        V  = GetComponent <p_Visual>();
        PB = (p_PlayerBeing)LB;

        C = GetComponent <p_Controller>();
    }
示例#3
0
 void ApplyRots()
 {
     CamPivot.localEulerAngles       = CamPivot.localEulerAngles.SetY(eulerRot.y);
     CamSecondPivot.localEulerAngles = CamSecondPivot.localEulerAngles.SetX(eulerRot.x);
     Cam_t.eulerAngles = Vector3.zero;
     Cam_t.LookAt(Cam_t.position + CamSecondPivot.forward);
 }