Пример #1
0
    public void processDragGesture(Vector2 beginPos, Vector2 endPos)
    {
        float distance = Vector3.Distance(beginPos, endPos);

        //
        // Cut Flies
        //

        RaycastHit2D[] rch2ds = Physics2D.RaycastAll(beginPos, (endPos - beginPos), distance);
        foreach (RaycastHit2D rch2d in rch2ds)
        {
            FlyController fc = rch2d.collider.gameObject.GetComponent <FlyController>();
            if (fc)
            {
                fc.splat();
            }
        }

        //
        // Display the slash
        //2017-11-20: copied from Stonicorn.TeleportStreakUpdater.position()
        //

        //Instantiate the effect
        GameObject cutGO = GameObject.Instantiate(cutPrefab);

        //Set the size
        Vector3 size       = cutGO.GetComponent <SpriteRenderer>().bounds.size;
        float   baseWidth  = size.x;
        float   baseHeight = size.y;

        //Set the position
        cutGO.transform.position = new Vector3(beginPos.x, beginPos.y, 1);
        float   newSize = distance;
        Vector3 newV    = new Vector3(newSize / baseWidth, 1.5f * baseHeight / baseHeight);

        cutGO.transform.localScale = newV;

        //Set the angle
        float angle = AngleSigned(endPos - beginPos, Vector3.left, Vector3.back);

        cutGO.transform.rotation = Quaternion.Euler(0, 0, angle);
    }
Пример #2
0
    /// <summary>
    /// Processes the tap gesture with the given position in World Space
    /// </summary>
    /// <param name="tapPos"></param>
    public void processTapGesture(Vector2 tapPos)
    {
        int splats = 0;

        foreach (CircleCollider2D cc2d in FindObjectsOfType <CircleCollider2D>())
        {
            if (cc2d.OverlapPoint(tapPos))
            {
                FlyController fc = cc2d.gameObject.GetComponent <FlyController>();
                if (fc)
                {
                    splats++;
                    fc.splat();
                    if (splats == splatsPerTap)
                    {
                        break;
                    }
                }
            }
        }
    }