Esempio n. 1
0
//	private Vector3 ControlLayer_sourcePos = Vector3.zero;
//	private bool ControlLayer_bArrival = false;
//	private float ControlLater_changeAmountY = 0f;
    void Update111()
    {
        this.ControlLayer_Falling();

        //if(true == Input_Unity.IsTouch())
        if (TouchPhase.Began == Input_Unity.GetTouchEvent())
        {
            this.gameObject.layer = GlobalConstants.Layer.Num.superCat;

            _destPos   = Input_Unity.GetTouchWorldPos();
            _destPos.z = 0;
            _dir       = _destPos - transform.position;

//			ControlLayer_sourcePos = transform.position;
//			ControlLayer_bArrival = true;
//			ControlLater_changeAmountY = 0f;
            s_ControlLayer_Falling.Init(transform);
            _rb2d.velocity = Vector2.zero;

            //Debug.Log("Force : " + rb2d.velocity.sqrMagnitude); //chamto test
            //if(_rb2d.velocity.sqrMagnitude >= 100.0f)
            //	_rb2d.AddForce (_dir, ForceMode2D.Force);
            //else
            _rb2d.AddForce(_dir * 2, ForceMode2D.Impulse);
        }
        if (TouchPhase.Ended == Input_Unity.GetTouchEvent())
        {
            //_rb2d.velocity = Vector2.zero; //cat stop
        }

        this.AniDirection(_destPos - transform.position);
    }
Esempio n. 2
0
    void Push_TouchEvent()
    {
        //DebugWide.Log(Input.touchCount);

        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            if (Input.touchCount > 0)
            {
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    //DebugWide.LogError("Update : TouchPhase.Began"); //chamto test
                    Init_PrevTouchMovedPos();
                    m_TouchedObject = SendMessage_TouchObject("TouchBegan", Input.GetTouch(0).position);
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Stationary)
                {
                    //DebugWide.LogError("Update : TouchPhase.Moved"); //chamto test

                    if (null != m_TouchedObject)
                    {
                        m_TouchedObject.SendMessage("TouchMoved", 0, SendMessageOptions.DontRequireReceiver);
                    }

                    Update_PrevTouchMovedPos();
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Ended)
                {
                    //DebugWide.LogError("Update : TouchPhase.Ended"); //chamto test
                    //checkInput("TouchEnded",Input.GetTouch(0).position);
                    if (null != m_TouchedObject)
                    {
                        m_TouchedObject.SendMessage("TouchEnded", 0, SendMessageOptions.DontRequireReceiver);
                    }
                    m_TouchedObject = null;
                }
                else
                {
                    DebugWide.LogError("Update : Exception Input Event : " + Input.GetTouch(0).phase);
                }
            }
        }
        else if (Application.platform == RuntimePlatform.OSXEditor)
        {
            //Debug.Log("mousedown:" +Input.GetMouseButtonDown(0)+ "  mouseup:" + Input.GetMouseButtonUp(0) + " state:" +Input.GetMouseButton(0)); //chamto test
            if (Input.GetMouseButtonDown(0))
            {
                //Debug.Log ("______________ MouseBottonDown ______________" + m_TouchedObject); //chamto test

                //if(0 == (m_prevMousePosition - Input.mousePosition).sqrMagnitude)
                {                       //mouse Down
                    if (false == f_isEditorDraging)
                    {
                        //Init_PrevTouchMovedPos();
                        m_TouchedObject = SendMessage_TouchObject("TouchBegan", Input.mousePosition);
                        if (null != m_TouchedObject)
                        {
                            f_isEditorDraging = true;
                        }
                    }
                }

                //DebugWide.Log("--------------"); //chamto test
            }

            if (Input.GetMouseButtonUp(0))
            {                   //mouse Up
                                //Debug.Log ("______________ MouseButtonUp ______________" + m_TouchedObject); //chamto test
                f_isEditorDraging = false;

                if (null != m_TouchedObject)
                {
                    m_TouchedObject.SendMessage("TouchEnded", 0, SendMessageOptions.DontRequireReceiver);
                }
                m_TouchedObject = null;
                //checkInput("TouchEnded",Input.mousePosition);
            }

            //else
            if (Input_Unity.GetMouseButtonMove(0))
            {                   //mouse Move
                if (f_isEditorDraging)
                {               ///mouse Down + Move (Drag)
                    //Debug.Log ("______________ MouseMoved ______________" + m_TouchedObject); //chamto test

                    if (null != m_TouchedObject)
                    {
                        m_TouchedObject.SendMessage("TouchMoved", 0, SendMessageOptions.DontRequireReceiver);
                    }

                    //Update_PrevTouchMovedPos();
                }        //if
            }            //if

            //m_prevMousePosition = Input.mousePosition;
        }
    }
Esempio n. 3
0
 /// <summary>
 /// TouchMoved 함수 호출후 갱신이 되어야 한다.
 /// </summary>
 private void Update_PrevTouchMovedPos()
 {
     m_prevTouchMovedPos = Input_Unity.GetTouchPos();         //update touchedMovePos
 }
Esempio n. 4
0
//	//startstartstartstartstartstartstartstartstartstartstartstartstartstartstartstartstart
//	#region Sources obsolete - test source
//
//	void ProcessInput(RaycastHit2D hit2d , RaycastHit hit3d)
//	{
//		if(Input.touchCount <= 0 ) return;
//
//		if(Input.GetTouch(0).phase == TouchPhase.Began)
//		{
//			//Todo
//		}
//		else if(Input.GetTouch(0).phase == TouchPhase.Moved)
//		{
//			//Todo
//			if(hit2d.collider.CompareTag("drop"))
//			{
//				//drop move code
//				DebugWide.Log("2d TouchPhase Move Drop!!");
//			}
//			if(hit3d.collider.CompareTag("drop"))
//			{
//				//drop move code
//				DebugWide.Log("3d TouchPhase Move Drop!!");
//			}
//		}
//		else if(Input.GetTouch(0).phase == TouchPhase.Ended)
//		{
//			//Todo
//		}
//	}
//
//
//
//	RaycastHit2D RayCast2D(Ray ray )
//	{
//
//		return Physics2D.Raycast(ray.origin, ray.direction);
//
////		RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);
////		if(hit)
////		{
////			ProcessInput(hit,null);
////		}
//	}
//
//	RaycastHit RayCast3D(Ray ray )
//	{
//		RaycastHit hit;
//		Physics.Raycast(ray, out hit, Mathf.Infinity);
//		return hit;
//
////		if(Physics.Raycast(ray, out hit, Mathf.Infinity))
////		{
////			ProcessInput(null,hit);
////		}
//	}
//
//
//
//	// Update is called once per frame
//	void doNotUse_Update ()
//	{
//		//if(false)
//		////if(Input.mousePresent)
////		{
////			DebugWide.Log("Update Mouse Input!! -----"); //chamto test
////
////			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
////
////
////			ProcessInput(
////				RayCast2D(ray),RayCast3D(ray));
////		}
//		if(Input.touchCount > 0 )
//		{
//			DebugWide.Log("Update Touch Input!! -----"); //chamto test
//
//			Vector2 pos = Input.GetTouch(0).position;
//			Vector3 theTouch = new Vector3(pos.x , pos.y , 0.0f);
//
//			Ray ray = Camera.main.ScreenPointToRay(theTouch);
//
//
//			ProcessInput(
//				RayCast2D(ray),RayCast3D(ray));
//
//		}
//	}
//
//	#endregion
//	//endendendendendendendendendendendendendendendendendendendendendendendendendendendend
//


    //----------------------------------------------------------------------------------

    private void Init_PrevTouchMovedPos()
    {
        m_prevTouchMovedPos = Input_Unity.GetTouchPos();         //init touchedMovePos
    }
Esempio n. 5
0
    public static Vector3 GetTouchWorldPos()
    {
        Vector3 pos = Input_Unity.GetTouchPos();

        return(Camera.main.ScreenToWorldPoint(pos));
    }
Esempio n. 6
0
    public static TouchPhase GetTouchEvent()
    {
        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            if (Input.touchCount > 0)
            {
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    DebugWide.LogWhite("Update : TouchPhase.Began");                      //chamto test
                    return(TouchPhase.Began);
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Stationary)
                {
                    DebugWide.LogWhite("Update : TouchPhase.Moved");                      //chamto test
                    return(TouchPhase.Moved);
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Ended)
                {
                    DebugWide.LogWhite("Update : TouchPhase.Ended");                      //chamto test
                    return(TouchPhase.Ended);
                }
                else
                {
                    DebugWide.LogWhite("Update : Exception Input Event : " + Input.GetTouch(0).phase);
                    return(Input.GetTouch(0).phase);
                }
            }
        }
        else if (Application.platform == RuntimePlatform.OSXEditor)
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (false == f_isEditorDraging)
                {
                    //DebugWide.LogWhite ("______________ MouseButtonDown ______________"); //chamto test

                    f_isEditorDraging = true;

                    return(TouchPhase.Began);
                }
            }

            if (Input.GetMouseButtonUp(0))                      //mouse Up

            //DebugWide.LogWhite ("______________ MouseButtonUp ______________"); //chamto test
            {
                f_isEditorDraging = false;

                return(TouchPhase.Ended);
            }

            //else
            if (Input_Unity.GetMouseButtonMove(0))                      //mouse Move

            {
                if (f_isEditorDraging)                          ///mouse Down + Move (Drag)

                //DebugWide.LogWhite ("______________ MouseMoved ______________"); //chamto test

                {
                    return(TouchPhase.Moved);
                }        //if
            }            //if
        }
        return(TouchPhase.Canceled);
    }
Esempio n. 7
0
    //void Update ()
    void FixedUpdate()
    {
        //Utility.Line.UpdateDebugLine(transform, this.name+"_destPos", transform.position, _destPos); //chamto test
        //Utility.Line.UpdateDebugLineScale(this.name+"_destPos", transform.localScale);

        if (true == Input_Unity.IsTouch())
        {
            Vector3 touchPos = Input_Unity.GetTouchWorldPos();

            //DebugWide.LogRed(GlobalConstants.Hierarchy.gameViewArea); //chamto test
            if (true == GlobalConstants.Hierarchy.gameViewArea.Contains(touchPos))
            {
                if (Cat.eMove.Super == _moveMode)
                {
                    _pathPos.Clear();
                    _pathPos.Push(touchPos);
                }
                else
                {
                    //_pathPos = _pathFinder.Search(transform.position, Input_Unity.GetTouchWorldPos ());
                    _pathFinder.SearchNonAlloc(transform.position, touchPos, ref _pathPos);

#if UNITY_EDITOR
                    //chamto test
                    //Utility.Line.UpdateDebugLine(transform, this.name+"_path", _pathPos.ToArray(),Color.green, Color.black);
#endif
                }



                _STATE = 1;
                this.State_MoveNext();
            }
        }

        switch (_STATE)
        {
        case 0:         //idle
        {
            _dir      = _destPos - transform.position;
            sumTime1 += Time.deltaTime;
            sumTime2 += Time.deltaTime;

            if (Cat.eArrive.Normal == _arriveMode)
            {
                //--------------------------------
                //normal
                //_rb2d.AddForce (_dir, ForceMode2D.Force); // == force
            }
            if (Cat.eArrive.Good == _arriveMode)
            {
                //--------------------------------
                //서로 나누어 먹는 느낌
//				if(_rb2d.velocity.sqrMagnitude <= 10.8f)
                _rb2d.AddForceAtPosition(_dir, _destPos, ForceMode2D.Impulse);                         //++ force
//				else
//					_rb2d.velocity = Vector2.zero; //cat stop
            }
            if (Cat.eArrive.Grabber == _arriveMode)
            {
                //--------------------------------
                //혼자 먹으려 싸우는 느낌
                _rb2d.MovePosition(_destPos);
            }
        }
        break;

        case 1:         //move to pos
        {
            //DebugWide.LogRed("moveToPos  state-1 : "); //chamto test
            this.State_UpdateMoveToPos();

            if (true == this.State_ArriveOn())
            {
                _STATE = 2;
            }
        }
        break;

        case 2:         //Landing
        {
            if ((null != _pathPos && 0 == _pathPos.Count) ||
                null == _pathPos)
            {
                _STATE = 0;
            }


            if (true == _isContactBuilding)
            {
                if (null != _pathPos && 0 != _pathPos.Count)
                {
                    _STATE = 1;
                    //_isContactBuilding = false;
                    State_MoveNext();
                }
            }
        }
        break;

        case 3:                                                           //falling
        {
            DebugWide.LogRed("falling  state-3 : " + _isContactBuilding); //chamto test
            if (true == _isContactBuilding)
            {
                _STATE = 1;
                //_isContactBuilding = false;
                this.gameObject.layer = GlobalConstants.Layer.Num.superCat;
            }
        }
        break;
        }        //end switch

        this.AniDirection(_destPos - transform.position);
    }