Exemple #1
0
    public override void Fire()
    {
        if (stats.ShotsInClip > 0)
        {
            base.Fire();

            //Debug.Log("BOOM");

            Ray screenRay = MainCam.ScreenPointToRay(new Vector3(ret.currentAimPosition.x, ret.currentAimPosition.y, 0));



            if (Physics.Raycast(screenRay, out RaycastHit hit, stats.Range, stats.layerMask))
            {
                hitPoint = hit.point;
                Vector3 hitDir = hit.point - MainCam.transform.position;
                Debug.DrawRay(MainCam.transform.position, hitDir * stats.Range, Color.red);

                //OnDrawGizmos(hit.point);
            }
        }
        else
        {
            sock.StopFiring();
            sock.StartReload();
        }
    }
    public override void GrabUpdate()
    {
        base.GrabUpdate();
#if UNITY_EDITOR
        float mmag = (Input.mousePosition - _prevPosition).magnitude;
        for (int i = 0; i < mmag - 1f; i += BrushSize / 4)
        {
            Ray        r   = MainCam.ScreenPointToRay(Vector3.Lerp(_prevPosition, Input.mousePosition, i / mmag));
            RaycastHit rch = PaintableObject.Instance.CleanRay(r, BrushStrength, BrushSize, Bubbles);
            if (rch.transform != null && UnityEngine.Random.Range(0f, 1f) < .01f)
            {
                GameObject g = Instantiate(SudsPrefab, rch.point, Quaternion.identity);
                g.transform.parent = rch.transform;
                g.GetComponent <SudsMaster>().PlaceSuds(rch.normal);
            }
        }
        _prevPosition = Input.mousePosition;
        PaintableObject.Instance.ApplyUpdates();
        return;
#endif

        Touch   t   = GetFingerTouch();
        Vector3 pos = t.position;
        float   mag = (pos - _prevPosition).magnitude;
        for (int i = 0; i < mag - 1f; i += BrushSize / 4)
        {
            Ray r = MainCam.ScreenPointToRay(Vector3.Lerp(_prevPosition, t.position, i / mag));
            PaintableObject.Instance.CleanRay(r, .96f, BrushSize, Bubbles);
            RaycastHit rch = PaintableObject.Instance.CleanRay(r, BrushStrength, BrushSize, Bubbles);
            if (rch.transform != null && UnityEngine.Random.Range(0f, 1f) < .01f)
            {
                GameObject g = Instantiate(SudsPrefab, rch.point, Quaternion.identity);
                g.transform.parent = rch.transform;
                g.GetComponent <SudsMaster>().PlaceSuds(rch.normal);
            }
        }
        PaintableObject.Instance.ApplyUpdates();
        _prevPosition = t.position;
    }