Esempio n. 1
0
    protected override void OnPlaced()
    {
        RaycastHit hit = new RaycastHit();
        Ray        ray = new Ray()
        {
            origin    = transform.position + Vector3.up,
            direction = Vector3.down
        };

        if (Physics.Raycast(ray, out hit, 10f, Layers.BUILDING))
        {
            PowerPad pad = hit.collider.gameObject.GetComponent <PowerPad>();
            if (pad == null)
            {
                return;
            }

            pad.ReceiveObject(this);
        }
    }
Esempio n. 2
0
    public override bool CheckForValidDrop(Vector3 position)
    {
        LayerMask  layers = Layers.BUILDING | Layers.TERRAIN;
        GameObject obj    = GridRaycaster.GetObject(position, layers);

        if (obj == null)
        {
            return(false);
        }

        if (obj.GetComponent <Building>() == null)
        {
            return(true);
        }
        else
        {
            PowerPad pad = obj.GetComponent <PowerPad>();
            return(pad != null);
        }
    }