Example #1
0
    public static bool isInRange(PowerManager iSource, PowerManager iTarget, bool longLink)
    {
        LINK_RANGE linkRange = getLinkRange(iSource, iTarget);

        if (linkRange == LINK_RANGE.SHORT)
        {
            // All links can link at short range.
            return(true);
        }

        if (linkRange == LINK_RANGE.LONG && longLink)
        {
            // if it is a long range link, it has to be a long link, or it won't work.
            return(true);
        }

        return(false);
    }
Example #2
0
    public void Init(PowerManager iSource, PowerManager iTarget)
    {
        _source = iSource;
        _target = iTarget;

        lastTransfer = 0;

        Vector3 targetPosition = iTarget.gameObject.transform.position;
        Vector3 sourcePosition = iSource.gameObject.transform.position;

        /*float x = iTarget.gameObject.transform.position.x;
         * float y = iTarget.gameObject.transform.position.y;
         *
         * float dx = iSource.gameObject.transform.position.x - x;
         * float dy = iSource.gameObject.transform.position.y - y;
         *
         * float length = Mathf.Sqrt((dx * dx) + (dy * dy));
         * float angle = Mathf.Atan2(dy, dx) * Mathf.Rad2Deg;
         *
         * transform.position = iSource.gameObject.transform.position;
         * transform.rotation = Quaternion.Euler(0.0f, 0.0f, angle);
         * transform.localScale = new Vector3(length, 1.0f, 1.0f);*/

        Vector3 relativePos = targetPosition - sourcePosition;

        transform.position = sourcePosition;

        float angle = Mathf.Atan2(relativePos.y, relativePos.x) * Mathf.Rad2Deg;

        transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);

        transform.localScale = new Vector3(relativePos.magnitude, 1.0f, 1.0f);

        LinkRange = getLinkRange(iSource, iTarget);

        /*Vector3 objectScale = itemBeingPlaced.localScale;
         * float distance = Vector3.Distance(hit.point, itemBeingPlaced.position);
         * Vector3 newScale = new Vector3(objectScale.x, objectScale.y, distance);
         * itemBeingPlaced.localScale = newScale;*/
    }