// 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); }
//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); }