internal void ReadRotationPacket() { ushort partId = reader.ReadUInt16(); byte order = reader.ReadUInt8(); RotateData rotX = ReadRotateData(reader); RotateData rotY = ReadRotateData(reader); RotateData rotZ = ReadRotateData(reader); }
private void callback(EventParamete parameteData) { if (parameteData.EvendName == ParmaterCodes.People.ToString()) { string data = parameteData.GetParameter <string>()[0]; RotateData rotateData = new RotateData(); rotateData = Newtonsoft.Json.JsonConvert.DeserializeObject <RotateData>(data); } }
RotateData ReadRotateData(NetReader reader) { RotateData data = default(RotateData); data.Origin = reader.ReadInt16() / 256f; data.Type = reader.ReadUInt8(); data.VarA = reader.ReadInt16() / 512f; data.VarB = reader.ReadInt16() / 512f; return(data); }
/// <summary> /// Start Idle. /// </summary> /// <returns></returns> public virtual IEnumerator Start_Idle(AIBehavior behavior) { if (PrintDebugMessage) { Debug.Log("Start behavior:" + behavior.Name + " .IdleDataName:" + behavior.IdleDataName); } IdleData _IdleData = Unit.IdleDataDict[behavior.IdleDataName]; string IdleAnimationName = _IdleData.AnimationName; float lastScanEndConditionTime = Time.time; while (true) { if (Halt) { animation.Stop(IdleAnimationName); yield return(null); continue; } else { animation.CrossFade(IdleAnimationName); //if this behavior's end condition matches, end this behavior if ((Time.time - lastScanEndConditionTime) >= behavior.AlterBehaviorInterval) { lastScanEndConditionTime = Time.time; if (CheckAlternateBehaviorCondition(behavior)) { if (PrintDebugMessage) { Debug.Log("Idle behavior:" + behavior.Name + " is end."); } break; } } //if the current target is not null and idle data mean to be keep facing at the target, face to the target. if (CurrentTarget != null && _IdleData.KeepFacingTarget) { Vector3 LookAtPosition = new Vector3(CurrentTarget.position.x, transform.position.y, CurrentTarget.position.z); if (_IdleData.SmoothRotate) { RotateData rotateData = Unit.RotateDataDict[_IdleData.RotateDataName]; //Calculate angle distance of forward direction and face to target direction. Vector3 toTargetDir = CurrentTarget.position - transform.position; Vector3 faceDir = transform.forward; if (Vector3.Angle(toTargetDir, faceDir) >= rotateData.AngleDistanceToStartRotate) { Util.RotateToward(transform, LookAtPosition, true, rotateData.RotateAngularSpeed); } } else { transform.LookAt(LookAtPosition); } } yield return(null); } } animation.Stop(this.Unit.IdleDataDict[behavior.IdleDataName].AnimationName); StopBehavior(behavior); }
public void SetRotateData(RotateData rotate) { isClockwise = rotate.isClockwise; speed = rotate.speed; }
public static async UniTask RotateLerp(this Transform From, RotateData rotateData) { await DoTime(() => From.rotation = Quaternion.Slerp(From.rotation, rotateData.To, rotateData.Speed *Time.deltaTime), rotateData.time); }