Ejemplo n.º 1
0
 public override void mUpdate()
 {
     base.mUpdate();
     if (Input.GetMouseButtonDown(0) && uguiHitUI.uiHited == false)
     {
         Vector2 v2 = GetScreenToWorldPos(Input.mousePosition);
         colli = Physics2D.OverlapPoint(v2);
     }
     if (colli != null && Input.GetMouseButtonUp(0))
     {
         Vector2    v2     = GetScreenToWorldPos(Input.mousePosition);
         Collider2D colli2 = Physics2D.OverlapPoint(v2);
         if (colli2 != colli)
         {
             colli = null;
             return;
         }
         ObjView view = colli.GetComponent <ObjView>();
         if (view == null)
         {
             return;
         }
         string      stateName = view.GetState();
         SelectState state     = getSelectState(stateName);
         if (state == null)
         {
             Debug.LogError("stateName = {0}未注册!" + stateName);
             return;
         }
         state.viewTarget = view;
         setState(stateName);
     }
 }
Ejemplo n.º 2
0
    public override void mPhoneUpdate()
    {
        base.mPhoneUpdate();
        if (Input.touchCount != 1 || uguiHitUI.uiHited == true)
        {
            return;
        }
        Touch touch = Input.GetTouch(0);

        switch (touch.phase)
        {
        case TouchPhase.Began:
            Vector2 v2 = GetScreenToWorldPos(touch.position);
            colli = Physics2D.OverlapPoint(v2);
            return;

        case TouchPhase.Moved:
            if (colli != null)
            {
                colli = null;
            }
            return;

        case TouchPhase.Ended:
            break;

        case TouchPhase.Stationary:
        case TouchPhase.Canceled:
        default:
            return;
        }

        if (colli != null)
        {
            Vector2    v2     = GetScreenToWorldPos(Input.mousePosition);
            Collider2D colli2 = Physics2D.OverlapPoint(v2);
            if (colli2 != colli)
            {
                colli = null;
                return;
            }
            ObjView view = colli.GetComponent <ObjView>();
            if (view == null)
            {
                return;
            }
            string      stateName = view.GetState();
            SelectState state     = getSelectState(stateName);
            if (state == null)
            {
                return;
            }
            state.viewTarget = view;
            setState(stateName);
        }
    }
Ejemplo n.º 3
0
    public override void mUpdate()
    {
        base.mUpdate();

        if (Input.GetMouseButtonDown(0) && uguiHitUI.uiHited == false)
        {
            canMove = false;
            Vector2 v2 = GetScreenToWorldPos(Input.mousePosition);
            colli = Physics2D.OverlapPoint(v2);
            if (colli == null)
            {
                setState(FreeState2D.NAME);
                return;
            }
            HandleView handle = colli.GetComponent <HandleView>();
            if (handle != null)
            {
                handle.SetState(selectMachine);
                return;
            }

            ObjView view = colli.GetComponent <ObjView>();
            if (view == null)
            {
                setState(FreeState2D.NAME);
                return;
            }
            else if (view == viewTarget)
            {
                canMove = true;
                return;
            }
            else
            {
                changed = true;
                string      stateName = view.GetState();
                SelectState state     = getSelectState(stateName);
                if (state == null)
                {
                    return;
                }
                state.viewTarget = view;
                setState(stateName);
            }
        }
        if (Input.GetMouseButtonUp(0))
        {
            canMove = false;
        }
    }
Ejemplo n.º 4
0
    public override void mPhoneUpdate()
    {
        base.mPhoneUpdate();
        if (uguiHitUI.uiHited == true || Input.touchCount != 1)
        {
            return;
        }
        Touch touch = Input.GetTouch(0);

        if (touch.phase == TouchPhase.Began)
        {
            canMove = false;
            Vector2 v2 = GetScreenToWorldPos(touch.position);
            colli = Physics2D.OverlapPoint(v2);
            if (colli == null)
            {
                setState(FreeState2D.NAME);
                return;
            }
            HandleView handle = colli.GetComponent <HandleView>();
            if (handle != null)
            {
                handle.SetState(selectMachine);
                return;
            }
            ObjView view = colli.GetComponent <ObjView>();
            if (view == null)
            {
                setState(FreeState2D.NAME);
                return;
            }
            else if (view == viewTarget)
            {
                canMove = true;
                return;
            }
            else
            {
                changed       = true;
                tempColiiView = view;
            }
        }
        else if (touch.phase == TouchPhase.Moved)
        {
            tempColiiView = null;
        }
        else if (touch.phase == TouchPhase.Ended)
        {
            if (canMove == true)
            {
                canMove = false;
                return;
            }

            if (tempColiiView == null)
            {
                setState(FreeState2D.NAME);
                return;
            }

            string      stateName = tempColiiView.GetState();
            SelectState state     = getSelectState(stateName);
            if (state == null)
            {
                return;
            }
            state.viewTarget = tempColiiView;
            setState(stateName);
        }
    }