internal void SetFreeMove(Transform preted) { protectedTransform = preted; mMoveType = Hi5ObjectMoveType.EFree; IsProtectFly = true; //if (Hi5_Interaction_Const.TestModifyConstraints) { //mItem.SetUseGravity(true); //mItem.SetIsKinematic(false); //mItem.CleanLock(); if (mItem.GetComponent <Hi5_Object_Property>() != null && mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.AirMoveProperty != null) { mItem.SetIsKinematic(false); mItem.SetUseGravity(true); mItem.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; mItem.GetComponent <Hi5_Object_Property>().SetRotation(mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.AirMoveProperty.ConstraintsFreezeRotation, mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.AirMoveProperty.ConstraintsFreezeRotation, mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.AirMoveProperty.ConstraintsFreezeRotation); } else { mItem.SetIsKinematic(false); mItem.SetUseGravity(true); mItem.CleanLock(); } } }
internal void Update() { if (Hi5_Layer_Set.IsResetLayer && !isSetLayer) { } if (IsPokeInLoop) { IsPokeProtectionCd -= Time.deltaTime; if (IsPokeProtectionCd < 0.0f) { IsPokeInLoop = false; } } else { IsPokeProtectionCd = Hi5_Interaction_Const.PokeProtectionCd; } //transform.localScale = scale; if (mstatemanager != null) { state = mstatemanager.State; } if (mstatemanager != null && mstatemanager.GetMoveState() != null) { moveType = mstatemanager.GetMoveState().mMoveType; } bool isTemp = false; foreach (Hi5_Interaction_Item_Collider item in itemColliders) { //Debug.Log("object touch plane----------"); if (item.trigger != null) { //Debug.Log("object touch plane---------- A"); isTemp = item.trigger.IsTrigger; if (isTemp) { // Debug.Log("object touch plane"); break; } } } isTouchPlane = isTemp; if (mstatemanager != null) { mstatemanager.Update(Time.deltaTime); } }
internal void SetPlaneMove(Collision collision) { if (mMoveType == Hi5ObjectMoveType.EThrowMove || mMoveType == Hi5ObjectMoveType.EFree) { return; } //if (Hi5_Interaction_Const.TestPlaneMoveUsePhysic) { mMoveType = Hi5ObjectMoveType.EPlaneMove; return; } Queue <Hi5_Position_Record> records = null; if (collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger>() != null) { records = collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger>().mQueuePositionRecord; } if (collision.gameObject.GetComponent <Hi5_Hand_Palm_Move>() != null) { records = collision.gameObject.GetComponent <Hi5_Hand_Palm_Move>().GetRecord(); } if (records != null && records.Count > 0) { Vector3 distanceVector = Vector3.zero; int index = 0; int weightPointCount = 0; float timeCount = 0.0f; foreach (Hi5_Position_Record item in records) { if (Hi5_Interaction_Const.RecordPositionWeight.Length > index) { int weight = Hi5_Interaction_Const.RecordPositionWeight[index]; weightPointCount += weight; timeCount += item.mIntervalTime * weight; distanceVector += item.mMoveVector * weight; } index++; } mMoveData = new ObjectMoveData(); mMoveData.mDirection = distanceVector / timeCount; mMoveData.y = mMoveData.mDirection.y; mMoveData.ySpeed = mMoveData.mDirection.y; mMoveType = Hi5ObjectMoveType.EPlaneMove; contactPointNormal = collision.contacts[0].normal; contactPointNormal.y = 0.0f; mItem.SetIsLockYPosition(true); //mFlyMoveStartProtectionCd = Hi5_Interaction_Const.FingerPinchPauseProtectionTime; } }
internal void Update() { if (IsPokeInLoop) { IsPokeProtectionCd -= Time.deltaTime; if (IsPokeProtectionCd < 0.0f) { IsPokeInLoop = false; } } else { IsPokeProtectionCd = Hi5_Interaction_Const.PokeProtectionCd; } //transform.localScale = scale; if (mstatemanager != null) { state = mstatemanager.State; } if (mstatemanager != null && mstatemanager.GetMoveState() != null) { moveType = mstatemanager.GetMoveState().mMoveType; } trigger = GetComponentInChildren <Hi5_Glove_Interaction_Item_Trigger>(); if (trigger != null) { trigger.itemObject = this; isTouchPlane = trigger.IsTrigger; //trigger.UpdateOther (Time.deltaTime); } if (mstatemanager != null) { mstatemanager.Update(Time.deltaTime); } }
internal void StopMove() { //isMove = false; mMoveData = null; mMoveType = Hi5ObjectMoveType.ENone; //if (Hi5_Interaction_Const.TestPlaneMoveUsePhysic) { // mItem.SetIsKinematic(false); // mItem.SetIsLockYPosition(true); } //else //{ // mItem.SetIsKinematic(true); // mItem.SetIsLockYPosition(false); //} // mItem.SetUseGravity(true); //mItem.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezePositionY; }
//GameObject Clone = null; internal void CalculateThrowMove(Queue <Hi5_Position_Record> records, Transform handPalm, Hi5_Glove_Interaction_Hand hand) { mIsFlyMovePause = false; int index = 0; int weightPointCount = 0; float timeCount = 0.0f; Vector3 distanceVector = Vector3.zero; foreach (Hi5_Position_Record item in records) { if (Hi5_Interaction_Const.RecordPositionWeight.Length > index) { int weight = Hi5_Interaction_Const.RecordPositionWeight[index]; weightPointCount += weight; timeCount += item.mIntervalTime * weight; distanceVector += item.mMoveVector * weight; } index++; } if (index <= 1) { // mMoveData = new ObjectMoveData(); // mMoveData.mDirection = new Vector3 (0.0f, 0.08598139f, 0.0f); // mMoveData.y = mMoveData.mDirection.y; // mMoveData.ySpeed = mMoveData.mDirection.y; //Debug.Log("index <= 1"); Vector3 temp = hand.MoveAnchor.position - hand.mPalm.transform.position; temp.Normalize(); mMoveData = new ObjectMoveData(); mMoveData.mDirection = temp * 0.3998139f; mMoveData.y = mMoveData.mDirection.y; mMoveData.ySpeed = mMoveData.mDirection.y; // mMoveData = new ObjectMoveData(); // mMoveData.mDirection = distanceVector / timeCount* Hi5_Interaction_Const.ThrowSpeed; // mMoveData.y = mMoveData.mDirection.y; // mMoveData.ySpeed = mMoveData.mDirection.y; Hi5_Interaction_Const.WriteItemMoveXml(records, mMoveData); } else { //Debug.Log("index > 1"); mMoveData = new ObjectMoveData(); mMoveData.mDirection = distanceVector / timeCount * Hi5_Interaction_Const.ThrowSpeed; mMoveData.y = mMoveData.mDirection.y; mMoveData.ySpeed = mMoveData.mDirection.y; Hi5_Interaction_Const.WriteItemMoveXml(records, mMoveData); } //if (Hi5_Interaction_Const.TestPhycis) //if (Hi5_Interaction_Const.TestModifyConstraints) { //mItem.SetIsKinematic (false); //mItem.SetUseGravity (true); //mItem.CleanLock (); if (mItem.GetComponent <Hi5_Object_Property>() != null && mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.AirMoveProperty != null) { mItem.SetIsKinematic(false); mItem.SetUseGravity(true); mItem.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; mItem.GetComponent <Hi5_Object_Property>().SetRotation(mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.AirMoveProperty.ConstraintsFreezeRotation, mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.AirMoveProperty.ConstraintsFreezeRotation, mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.AirMoveProperty.ConstraintsFreezeRotation); } else { mItem.SetIsKinematic(false); mItem.SetUseGravity(true); mItem.CleanLock(); } } mMoveType = Hi5ObjectMoveType.EThrowMove; protectedTransform = handPalm; IsProtectFly = true; }
//internal void SetPlaneMove() //{ // if (mMoveType == Hi5ObjectMoveType.EThrowMove || mMoveType == Hi5ObjectMoveType.EFree) // return; // mMoveType = Hi5ObjectMoveType.EPlaneMove; //} internal void SetPlaneMove(Collision collision) { if (mMoveType == Hi5ObjectMoveType.EThrowMove || mMoveType == Hi5ObjectMoveType.EFree) { return; } //if (Hi5_Interaction_Const.TestPlaneMoveUsePhysic) { mMoveType = Hi5ObjectMoveType.EPlaneMove; if (mItem.GetComponent <Hi5_Object_Property>() != null && mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.PlaneMoveProperty != null) { mItem.SetIsKinematic(false); mItem.SetUseGravity(true); mItem.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; mItem.GetComponent <Hi5_Object_Property>().SetRotation(mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.PlaneMoveProperty.ConstraintsFreezeRotation, mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.PlaneMoveProperty.ConstraintsFreezeRotation, mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.PlaneMoveProperty.ConstraintsFreezeRotation); } else { mItem.SetIsKinematic(false); mItem.SetUseGravity(true); mItem.CleanLock(); } return; } Queue <Hi5_Position_Record> records = null; if (collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger>() != null) { records = collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger>().mQueuePositionRecord; } if (collision.gameObject.GetComponent <Hi5_Hand_Palm_Move>() != null) { records = collision.gameObject.GetComponent <Hi5_Hand_Palm_Move>().GetRecord(); } if (records != null && records.Count > 0) { Vector3 distanceVector = Vector3.zero; int index = 0; int weightPointCount = 0; float timeCount = 0.0f; foreach (Hi5_Position_Record item in records) { if (Hi5_Interaction_Const.RecordPositionWeight.Length > index) { int weight = Hi5_Interaction_Const.RecordPositionWeight[index]; weightPointCount += weight; timeCount += item.mIntervalTime * weight; distanceVector += item.mMoveVector * weight; } index++; } mMoveData = new ObjectMoveData(); mMoveData.mDirection = distanceVector / timeCount; mMoveData.y = mMoveData.mDirection.y; mMoveData.ySpeed = mMoveData.mDirection.y; mMoveType = Hi5ObjectMoveType.EPlaneMove; contactPointNormal = collision.contacts[0].normal; contactPointNormal.y = 0.0f; { //mItem.SetUseGravity(true); //mItem.SetIsKinematic(false); //mItem.CleanLock(); if (mItem.GetComponent <Hi5_Object_Property>() != null && mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.PlaneMoveProperty != null) { mItem.SetIsKinematic(false); mItem.SetUseGravity(true); mItem.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; mItem.GetComponent <Hi5_Object_Property>().SetRotation(mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.PlaneMoveProperty.ConstraintsFreezeRotation, mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.PlaneMoveProperty.ConstraintsFreezeRotation, mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.PlaneMoveProperty.ConstraintsFreezeRotation); } else { mItem.SetIsKinematic(false); mItem.SetUseGravity(true); mItem.CleanLock(); } } } }
internal void CacullateThrowMove(Queue <Hi5_Position_Record> records, Transform handPalm, Hi5_Glove_Interaction_Hand hand) { mIsFlyMovePause = false; int index = 0; int weightPointCount = 0; float timeCount = 0.0f; Vector3 distanceVector = Vector3.zero; foreach (Hi5_Position_Record item in records) { if (Hi5_Interaction_Const.RecordPositionWeight.Length > index) { int weight = Hi5_Interaction_Const.RecordPositionWeight[index]; weightPointCount += weight; timeCount += item.mIntervalTime * weight; distanceVector += item.mMoveVector * weight; } index++; } if (index <= 1) { // mMoveData = new ObjectMoveData(); // mMoveData.mDirection = new Vector3 (0.0f, 0.08598139f, 0.0f); // mMoveData.y = mMoveData.mDirection.y; // mMoveData.ySpeed = mMoveData.mDirection.y; Vector3 temp = hand.MoveAnchor.position - hand.mPalm.transform.position; temp.Normalize(); mMoveData = new ObjectMoveData(); mMoveData.mDirection = temp * 0.3998139f; mMoveData.y = mMoveData.mDirection.y; mMoveData.ySpeed = mMoveData.mDirection.y; // mMoveData = new ObjectMoveData(); // mMoveData.mDirection = distanceVector / timeCount* Hi5_Interaction_Const.ThrowSpeed; // mMoveData.y = mMoveData.mDirection.y; // mMoveData.ySpeed = mMoveData.mDirection.y; Hi5_Interaction_Const.WriteItemMoveXml(records, mMoveData); } else { mMoveData = new ObjectMoveData(); mMoveData.mDirection = distanceVector / timeCount * Hi5_Interaction_Const.ThrowSpeed; mMoveData.y = mMoveData.mDirection.y; mMoveData.ySpeed = mMoveData.mDirection.y; Hi5_Interaction_Const.WriteItemMoveXml(records, mMoveData); } //if (Hi5_Interaction_Const.TestFlyMoveNoUsedGravity) { mItem.SetIsKinematic(true); mItem.SetUseGravity(false); } //else //{ // mItem.SetIsKinematic(false); // mItem.SetUseGravity(true); //} mMoveType = Hi5ObjectMoveType.EThrowMove; protecedTransform = handPalm; IsProtectFly = true; }
internal void SetFreeMove(Transform preted) { protecedTransform = preted; mMoveType = Hi5ObjectMoveType.EFree; IsProtectFly = true; }