Beispiel #1
0
    void CheckState()
    {
        m_fzoomDis = GetZoomDis();
        bool bZoomFlagOld = m_isZooming;
        bool bZoomFlagNew = m_fzoomDis != 0.0f;

        if (bZoomFlagOld && !bZoomFlagNew)
        {
            OnZoomBackAtion();
        }
        m_isZooming = bZoomFlagNew;
        if (!Input.GetMouseButton(0))
        {
            if (m_bOneTouchDown)
            {
                OnDragOut();
                m_fPanningSpeed = 0;
                m_bOneTouchDown = false;
            }
            m_isDrag = false;
        }
        else
        {
            if (!m_bOneTouchDown)
            {
                RaycastHit hit;
                if (!WndManager.IsHitNGUI(out hit))
                {
                    m_vTouchDown       = GetTouchPos(0);
                    m_vlastFirstTouch  = GetTouchPos(0);
                    m_vToPosition      = new Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z);
                    m_fPanningSpeed    = 0f;
                    m_bOneTouchDown    = true;
                    m_vtotalmouseDelta = Vector2.zero;
                }
            }
        }
        if (m_bOneTouchDown && !m_isDrag)
        {
            float click = mouseClickThreshold;
            click *= click;
            m_vtotalmouseDelta += m_vlastFirstTouch - GetTouchPos(0);
            m_mag = m_vtotalmouseDelta.sqrMagnitude;
            if (m_mag > click)
            {
                m_vlastFirstTouch = m_vTouchDown;
                //m_vTouchDownDragOff = GetTouchPos(0)-m_vTouchDown;
                m_isDrag = true;
            }
        }
    }
Beispiel #2
0
    void OnMouseDown()
    {
        RaycastHit hit;

        if (WndManager.IsHitNGUI(out hit))        //当点击到UI时不做处理
        {
            return;
        }
        if (Input.touchCount >= 2)
        {
            return;
        }
        m_bMouseDown     = true;
        m_bLongTouch     = false;
        m_bMoudeUp       = false;
        m_fMouseDownTime = Time.time;
    }
Beispiel #3
0
    private Vector2 m_vtotalmouseDelta; //记录手指按下后的屏幕移动总和,可用于判断移动和捏合操作
    public override void OnMouseDown(SceneObj objScene)
    {
        RaycastHit hit;

        if (!WndManager.IsHitNGUI(out hit))
        {
            m_vtotalmouseDelta = Vector3.zero;
            m_objTouchDown     = objScene;
            if (SystemInfo.deviceType == DeviceType.Desktop)
            {
                m_vposLastTouchMove = Input.mousePosition;
            }
            else
            {
                m_vposLastTouchMove = Input.GetTouch(0).position;
            }
        }
    }
Beispiel #4
0
    void Update()
    {
        if (MyHead.SprTipsInfo.gameObject.activeInHierarchy == true)
        {
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit hit;
                if (WndManager.IsHitNGUI(out hit) == true)
                {
                    if (hit.collider.gameObject == MyHead.BtnTips.gameObject)
                    {
                        return;
                    }

                    if (hit.collider.gameObject != MyHead.SprTipsInfo.gameObject)
                    {
                        MyHead.SprTipsInfo.gameObject.SetActive(false);
                    }
                }
            }
        }
    }
Beispiel #5
0
    void OnMouseDown()
    {
        if (PutCanvasM.CanOperate == false)
        {
            return;
        }

        RaycastHit hit;

        if (WndManager.IsHitNGUI(out hit))//当点击到UI时不做处理
        {
            return;
        }
        if (Input.touchCount >= 2)
        {
            return;
        }
        m_bMouseDown       = true;
        m_bLongTouch       = false;
        m_bTouchMoveChange = true;
        m_fMouseDownTime   = Time.time;
        m_vtotalmouseDelta = Vector2.zero;
        m_vlastFirstTouch  = GetTouchPos(0);
        m_isDrag           = false;
        if (SystemInfo.deviceType == DeviceType.Desktop)
        {
            m_v3MouseTouchDown = Input.mousePosition;
        }
        else
        {
            m_v3MouseTouchDown = Input.GetTouch(0).position;
        }

        //获取按下时画布格子
        Vector3 m_v3TouchScreenPos = new Vector3(m_v3MouseTouchDown.x, m_v3MouseTouchDown.y, -Camera.main.transform.position.z);
        Vector3 m_v3TouchWorldPos  = Camera.main.ScreenToWorldPoint(m_v3TouchScreenPos);
        Vector3 v3dLocalPos        = BattleEnvironmentM.World2LocalPos(m_v3TouchWorldPos);

        m_roomGridTouchDown = RoomMap.FindRoomGrid(v3dLocalPos);
        if (m_roomGridTouchDown == null)
        {
            return;
        }
        m_curClickType = RoomMap.PickupShipBuildType(m_roomGridTouchDown, v3dLocalPos, m_roomGridTouchDown.mPosRoomGrid.Layer);

        CanvasCore buildRoomCoreTouchDown = m_roomGridTouchDown.GetBuildRoom();

        if (TouchMove.g_bSetParaing == true)
        {
            return;
        }

        TouchMove curTouchMove = TouchMoveManager.GetCurTouchMove();

        if (null != curTouchMove)
        {
            //如果当前选中的是房间,新选中的不管是什么都不做变更
            //如果当前选中的不是房间,但是新选中的对象和当前选中的一样则也不变量。
            if (curTouchMove.IsContainsRoomGrid(m_roomGridTouchDown))
            {
                TouchMove selNewTouchMov = PutCanvasM.GetTouchMoveByRoomGrid(m_roomGridTouchDown, m_curClickType);
                if (curTouchMove.MyCore().m_type == ShipBuildType.BuildRoom ||
                    selNewTouchMov != null && selNewTouchMov == curTouchMove)
                {
                    curTouchMove.PlayEditSelectAnimationEnd();                                     //恢复上个房间内陷阱/角色 动画
                    curTouchMove.OnMouseDown();
                    m_bTouchMoveChange = false;
                }
            }
            PutCanvasM.ClearNoLinkList();
        }
        else
        {
            //判断选中物件是否在上次保存失败的物件上,如果是则直接选择
            bool bInNoLinkList = false;
            if (buildRoomCoreTouchDown != null)
            {
                TouchMove selNewTouchMov = PutCanvasM.GetTouchMoveByCore(buildRoomCoreTouchDown);
                if (null == selNewTouchMov)
                {
                    List <CanvasCore> childCores = m_roomGridTouchDown.GetOtherBuild();
                    for (int i = 0; i < childCores.Count; i++)
                    {
                        selNewTouchMov = PutCanvasM.GetTouchMoveByCore(childCores[i]);
                        break;
                    }
                }
                if (null != selNewTouchMov && PutCanvasM.NoLinkListContain(selNewTouchMov.MyCore()))
                {
                    PutCanvasM.ClearNoLinkList();
                    TouchMoveManager.SetCurTouchMove(selNewTouchMov);
                    selNewTouchMov.PlayEditSelectAnimationEnd();                     //恢复上个房间内陷阱/角色 动画
                    selNewTouchMov.OnMouseDown();
                    m_bTouchMoveChange = false;
                    bInNoLinkList      = true;
                }
            }
            if (bInNoLinkList == false)
            {
                PutCanvasM.ClearNoLinkList();
            }
        }
    }
Beispiel #6
0
    void Update()
    {
        if (CombatScheduler.State == CSState.End)
        {
            //MyHead.m_fulleffect.SetActive(false);
            //MyHead.m_notfulleffect.SetActive(true);
            MyHead.Fire.SetActive(false);
            return;
        }

        if ((m_currentstate == GodSkillState.Click) && (Input.GetMouseButton(0) || Input.touchCount == 1))
        {
            RaycastHit hit;
            if ((!WndManager.IsHitNGUI(out hit) || m_taskguide) && !m_MouseDown)
            {
                Vector3 ScreenPos = Vector3.zero;
                if (SystemInfo.deviceType == DeviceType.Desktop && Input.GetMouseButton(0))
                {
                    ScreenPos = Input.mousePosition;
                }
                else if (Input.touchCount == 1)
                {
                    ScreenPos = Input.GetTouch(0).position;
                }
                Vector3   vGestyrScreenPlane = Camera.main.WorldToScreenPoint(Vector3.zero);
                Vector3   posWorld           = Camera.main.ScreenToWorldPoint(new Vector3(ScreenPos.x, ScreenPos.y, vGestyrScreenPlane.z));
                Transform start   = BattleEnvironmentM.GetLifeMBornNode(true);
                Vector3   locapos = start.InverseTransformPoint(posWorld);
                int       layer   = (int)(locapos.y / MapGrid.m_heigth);
                int       unit    = (int)(locapos.x / MapGrid.m_width);
                //Debug.Log("calc  layer:"+ layer + "  unit:" + unit);
                MapGrid g = MapGrid.GetMG(layer, unit);
                if (g != null)
                {
                    //ReleaseSkill(g,posWorld);
                    m_MouseDownGrid     = g;
                    m_MouseDownWorldPos = posWorld;
                    m_MouseDown         = true;
                    m_MouseDownTime     = Time.time;
                    m_ReleaseSkill      = false;
                    m_ReadyReleaseSkill = true;
                    m_taskguide         = false;
                }
                else
                {
                    NGUIUtil.ShowTipWndByKey("88800015", 1.0f);
                    if (m_taskguide == false)
                    {
                        CancelSelect();
                    }
                }
            }
        }
        else if (m_MouseDown)
        {
            m_MouseDown = false;
            if ((Time.time - m_MouseDownTime) < 0.5f)
            {
                ReleaseSkill(m_MouseDownGrid, m_MouseDownWorldPos);
            }
        }
    }