예제 #1
0
    private SnappingUnits EquipSnappingComponent(GameObject attachTarget, float shipWrapRadius)
    {
        //添加布阵格子组件,以供自动排布
        Snapping_ = attachTarget.AddComponent <SnappingUnits>();

        //每个可拖拽单元都受到同一个RectGrid的约束
        Snapping_.Grid           = DeploySceneManager.Instance.PlayerGridDrawer.GridInstance;
        Snapping_.ShipWrapRadius = shipWrapRadius;
        Snapping_.ShipIocnName   = IconName_;
        Snapping_.ArrowGroup     = attachTarget.AddComponent <DeployUnitDisplayHelper>();
        DeployUnitDisplayHelper.SetCurrent(Snapping_.ArrowGroup, attachTarget.transform, shipWrapRadius);
        Snapping_.RebackCursorCallback += delegate { OnDragEnd(); };

        return(Snapping_);
    }
예제 #2
0
    private void CancelLastDeploy()
    {
        Debugger.Log("CancelLastDeploy()...");
        if (Snapping_ != null)  //第1次无效,第2次也无效时的容错
        {
            if (Snapping_.FollowIcon)
            {
                Destroy(Snapping_.FollowIcon.gameObject);
                Snapping_.FollowIcon = null;
            }

            Destroy(Snapping_.gameObject);
            Snapping_ = null;
            //DeployDragHandeler.InDragMode = false;
            IsDragging = false;
        }
    }
예제 #3
0
    /// <summary>
    /// 此次拖拽结束
    /// </summary>
    private void OnDragEnd()
    {
        Debugger.Log("OnDragEnd()");
        IsDragging = false;

        SetElementStateOnDrag(false);
        if (Snapping_ == null)
        {
            StopAllCoroutines();
            return;//未拖拽到格子上的情况
        }
        bool deploySucceed = Snapping_.OnEndDragFromUI();

        Debugger.Log("deploySucceed : " + deploySucceed);
        if (deploySucceed)
        {
            RefreshDeployStatus();
            DeployUnitMenu.Instance.CancelClickCallback += CancelDeploy;
            Snapping_ = null;
        }
    }
예제 #4
0
 public void SetSnappingScript(SnappingUnits script)
 {
     snappingScript = script;
 }
 public void SetSnappingScript(SnappingUnits script)
 {
     snappingScript = script;
 }