Esempio n. 1
0
        protected override void ComputeSingleStep()
        {
            if (i >= toCheck.Length)
            {
                Done = true;
                return;
            }
            Index2 tile = toCheck[i];

            i++;
            Angle angle = ToAngle(lightPosition - tile);

            if (obstacles[tile.X, tile.Y] > 0)
            {
                float increment = MathHelper.TwoPi / (8 * (tile - lightPosition).Length());
                obstructedArea.Add(new AnglePair(angle - 0.5f * increment, angle + 0.5f * increment));
                ComputeSingleStep();
                return;
            }
            if (obstructedArea.ContainsAny(angle))
            {
                ComputeSingleStep();
                return;
            }
            Current = tile;
        }
Esempio n. 2
0
    void CacheHooks()
    {
        hooksCache    = new AngleCollection();
        lastCacheTime = Time.time;

        foreach (GameObject hookObj in GameObject.FindGameObjectsWithTag("Hook"))
        {
            if (Vector3.Distance(gunObj.position, hookObj.transform.position) < maxDistance)
            {
                if (!Physics2D.Linecast(gunObj.position, hookObj.transform.position, 1 << LayerMask.NameToLayer("Ground")))
                {
                    Vector3 delta = hookObj.transform.position - gunObj.position;
                    hooksCache.Add(hookObj, Mathf.Atan2(delta.y, delta.x) * 180 / Mathf.PI);
                }
            }
        }
    }