Example #1
0
    void InitAttack()
    {
        InputManger.Instance.RegistClickDelegate(delegate(Vector2 clickPosition)
        {
            MapLaserNode laser = MapNodeManager.Instance.CreateNode <MapLaserNode>("Prefab/Bullet/Laser", transform.parent);

            RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.parent.TransformPoint(clickPosition) - transform.position, 10000f, 1 << LayerMask.NameToLayer("Scene"));
            if (hit.collider != null)
            {
                laser.Init(transform.position, hit.point);
            }
            else
            {
                laser.Init(transform.position, transform.parent.TransformPoint(clickPosition));
            }
        });
    }
Example #2
0
    void OnMouseClick(Vector2 clickPosition)
    {
        m_target_pos = clickPosition;
        //激光指示,最后去掉
        MapLaserNode laser = MapNodeManager.Instance.CreateNode <MapLaserNode>("Prefab/Bullet/Laser", transform.parent);

        laser.Init(transform.position, transform.parent.TransformPoint(clickPosition));
        //RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.parent.TransformPoint(clickPosition) - transform.position, 10000f, 1 << LayerMask.NameToLayer("Scene"));
        //if (hit.collider != null)
        //{
        //    laser.Init(transform.position, hit.point);
        //}
        //else
        //{
        //    laser.Init(transform.position, transform.parent.TransformPoint(clickPosition));
        //}
    }