Example #1
0
    /// <summary>
    /// Try to build cable
    /// </summary>
    private void Build()
    {
        if (startPoint == endPoint || target == null)
        {
            return;
        }

        Vector2         targetVector = (connectionPointRenderers[endPoint].transform.position - transform.position);
        ConnectionApply cableApply   = ConnectionApply.ByLocalPlayer(target, startPoint, endPoint, targetVector);

        //if HandObject is null, then its an empty hand apply so we only need to check the receiving object
        if (cableApply.HandObject != null)
        {
            //get all components that can contains CableApply interaction
            var cableAppliables = cableApply.HandObject.GetComponents <MonoBehaviour>()
                                  .Where(c => c != null && c.enabled && (c is IBaseInteractable <ConnectionApply>));

            foreach (var cableAppliable in cableAppliables.Reverse())
            {
                var hap = cableAppliable as IBaseInteractable <ConnectionApply>;
                if (hap.ClientCheckAndTrigger(cableApply))
                {
                    return;
                }
            }
        }
    }
    /// <summary>
    /// Try to build cable
    /// </summary>
    private void Build()
    {
        if (startPoint == endPoint || Mathf.Abs(startPointVector.x - endPointVector.x) > 2.5 || Mathf.Abs(startPointVector.y - endPointVector.y) > 2.5)
        {
            return;
        }

        GameObject      target     = MouseUtils.GetOrderedObjectsUnderMouse().FirstOrDefault();
        ConnectionApply cableApply = ConnectionApply.ByLocalPlayer(target, startPoint, endPoint, null);

        //if HandObject is null, then its an empty hand apply so we only need to check the receiving object
        if (cableApply.HandObject != null)
        {
            //get all components that can contains CableApply interaction
            var cableAppliables = cableApply.HandObject.GetComponents <MonoBehaviour>()
                                  .Where(c => c != null && c.enabled && (c is IBaseInteractable <ConnectionApply>));

            foreach (var cableAppliable in cableAppliables.Reverse())
            {
                var hap = cableAppliable as IBaseInteractable <ConnectionApply>;
                if (hap.ClientCheckAndTrigger(cableApply))
                {
                    return;
                }
            }
        }
    }
Example #3
0
    /// <summary>
    /// Try to build cable
    /// </summary>
    private void Build()
    {
        if (startPoint == endPoint || target == null)
        {
            return;
        }
        var Register = PlayerManager.LocalPlayer.RegisterTile();

        Vector3 Position = Vector3.zero;

        if (Register.Matrix.MatrixMove == null)
        {
            Position = cablePlacementVisualisation.transform.position + (new Vector3(0.5f, 0.5f, 0));
        }
        else
        {
            var InQuaternion = Register.Matrix.MatrixMove.FacingOffsetFromInitial.Quaternion;
            Position = cablePlacementVisualisation.transform.position + (InQuaternion * new Vector3(0.5f, 0.5f, 0));
        }


        Vector2 targetVector = Position.ToLocal(PlayerManager.LocalPlayer.RegisterTile().Matrix);         // transform.position ( - transform.position); //TODO? what? is this

        ConnectionApply cableApply = ConnectionApply.ByLocalPlayer(target, startPoint, endPoint, targetVector);

        //if HandObject is null, then its an empty hand apply so we only need to check the receiving object
        if (cableApply.HandObject != null)
        {
            //get all components that can contains CableApply interaction
            var cableAppliables = cableApply.HandObject.GetComponents <MonoBehaviour>()
                                  .Where(c => c != null && c.enabled && (c is IBaseInteractable <ConnectionApply>));

            foreach (var cableAppliable in cableAppliables.Reverse())
            {
                var hap = cableAppliable as IBaseInteractable <ConnectionApply>;
                if (hap.ClientCheckAndTrigger(cableApply))
                {
                    return;
                }
            }
        }
    }