// 检查一个等级是否通过 public bool CheckLevel() { if (GetComponent <LevelController> ().NextLevelConfig == null) // 已经到了最高级 { return(false); } var conditions = GetComponent <LevelController> ().NextLevelConfig.conditions; // check this level condition bool allPassed = true; foreach (var condition in conditions) { if (!this.GetAchievement(condition.id)) { allPassed = false; break; } } if (allPassed) // all passed, level up { GetComponent <LevelController> ().LevelUp(); this.ResetAchievement(); // 播放升级动画 AniInfo aniInfo = new AniInfo(AniLevelUp); Level curLevel = GetComponent <LevelController> ().CurLevelConfig; this.PlayAni(aniInfo.AddParam("level", curLevel.name).AddParam("quality", curLevel.quality.ToString())); this.NewHighestScore(GetComponent <ScoreController>().CurScore); // 再判断一次最高分 } return(allPassed); }
IEnumerator AniMoves(AniInfo aniInfo, GameObject target, float speed) { gameAni.transform.Rotate(new Vector3(0, 0, 180)); if (speed == 0) { yield return(null); } //StartCoroutine(PlayerAni(aniInfo, gameAni,1)); Vector3 targetPos = target.transform.position; Image image = gameAni.GetComponent <Image>(); //Debug.Log(Vector3.Distance(gameAni.transform.position, targetPos)); int i = 1; while (Vector3.Distance(gameAni.transform.position, targetPos) > 10) { image.sprite = Resources.Load <Sprite>(aniInfo.AniPath + "/" + i); //Debug.Log(aniInfo.AniPath + "/" + i); //Debug.Log(Vector3.Distance(gameAni.transform.position, targetPos)); gameAni.transform.position = Vector3.MoveTowards(gameAni.transform.position, targetPos, speed * Time.deltaTime); yield return(new WaitForSeconds(0.05f)); i++; if (i >= aniInfo.AniCount) { i = 0; } } //StopCoroutine(PlayerAni(aniInfo, gameAni,1)); StopCoroutine(AniMoves(aniInfo, target, speed)); Destroy(gameAni); }
void Play(AniInfo info) { m_curInfo = info; if (m_animator != null) { m_animator.Rebind(); m_animator.Play(m_curInfo.m_aniName); } else if (m_animation != null) { m_animation.wrapMode = m_curInfo.wrapMode; m_animation.PlayQueued(m_curInfo.m_aniName, QueueMode.PlayNow); } m_curInfo.m_lastPlayIntervalTime = Time.time; if (m_curInfo.intervalMin < m_curInfo.intervalMax) { m_curInfo.curInterval = Random.Range(m_curInfo.intervalMin, m_curInfo.intervalMax); } else { m_curInfo.curInterval = m_curInfo.intervalMin; } m_curLastPlayTime = Time.time; }
// check and save achievement,返回是否升级 private void CheckNum(int id, int num, int oldNum, bool checkLevel) { int needNum = this.GetAchievementNeedNum(id); if (needNum == -1) { return; } if (num >= needNum) // passed { SetAchievement(id, true); // 播放通过条件动画 AniInfo aniInfo = new AniInfo(AniConditionPass); string txt = LevelConfig.GetAchievement(id).GetNumText(this.GetAchievementNeedNum(id, true)); this.PlayAni(aniInfo.AddParam("condition", txt)); if (checkLevel) { this.CheckLevel(); // 检查等级 } } else if (id != 3003) { // 播放进度动画 string txt = LevelConfig.GetAchievement(id).GetNumText(this.GetAchievementNeedNum(id, true)); AniInfo aniInfo = new AniInfo(AniConditionProgress); this.PlayAni(aniInfo.AddParam("condition", txt).AddParam("oldNum", oldNum.ToString()).AddParam("newNum", num.ToString())); } }
public void Init(Actor actor) { ani = actor.gameObject.GetComponentInChildren <Animator>(); Debug.Assert(ani != null, "CHECK: ActorAnimation init ani is null > " + actor.gameObject.name); ActorBehaviour[] abs = ani.GetBehaviours <ActorBehaviour>(); for (int i = 0; i < abs.Length; ++i) { abs[i].actorAni = this; } aniInfos[(int)ActorAniState.None] = null; var aniInfo = new AniInfo(); aniInfo.name = "Actor_Idle"; aniInfo.shortNameHash = Animator.StringToHash("Actor_Idle"); aniInfo.condition = string.Empty; aniInfo.ctype = AniConditionType.None; aniInfos[(int)ActorAniState.Idle] = aniInfo; aniInfo = new AniInfo(); aniInfo.name = "Actor_Attack_L"; aniInfo.shortNameHash = Animator.StringToHash("Actor_Attack_L"); aniInfo.condition = "Attack"; aniInfo.ctype = AniConditionType.Trigger; aniInfos[(int)ActorAniState.Attack] = aniInfo; aniInfo = new AniInfo(); aniInfo.name = "Actor_Attack_R"; aniInfo.shortNameHash = Animator.StringToHash("Actor_Attack_R"); aniInfo.condition = "Attack"; aniInfo.ctype = AniConditionType.Trigger; aniInfos[(int)ActorAniState.Attack] = aniInfo; aniInfo = new AniInfo(); aniInfo.name = "Actor_Hurt_L"; aniInfo.shortNameHash = Animator.StringToHash("Actor_Hurt_L"); aniInfo.condition = "Hurt"; aniInfo.ctype = AniConditionType.Trigger; aniInfos[(int)ActorAniState.Hurt] = aniInfo; aniInfo = new AniInfo(); aniInfo.name = "Actor_Hurt_R"; aniInfo.shortNameHash = Animator.StringToHash("Actor_Hurt_R"); aniInfo.condition = "Hurt"; aniInfo.ctype = AniConditionType.Trigger; aniInfos[(int)ActorAniState.Hurt] = aniInfo; aniInfo = new AniInfo(); aniInfo.name = "Actor_Dead"; aniInfo.shortNameHash = Animator.StringToHash("Actor_Dead"); aniInfo.condition = "Dead"; aniInfo.ctype = AniConditionType.Bool; aniInfos[(int)ActorAniState.Dead] = aniInfo; // make sure SetFaceDir(actor.faceDir); }
public void Inits(LandlordsEventAniType aniType, float start_Time, float end_delyTime, string triggerPlayerHeadIcon = "")//特效触发者头像 { //加入队列 AniInfo info = new AniInfo(aniType, start_Time, end_delyTime, triggerPlayerHeadIcon); aniList.Add(info); if (!isPlaying) { StartCoroutine(Play()); } }
IEnumerator PlayerAni(AniInfo aniInfo, GameObject gameAni) { Image image = gameAni.GetComponent <Image>(); for (int i = 1; i <= aniInfo.AniCount; i++) { image.sprite = Resources.Load <Sprite>(aniInfo.AniPath + "/" + i); //Debug.Log(aniInfo.AniPath + "/" + i); yield return(new WaitForSeconds(0.05f)); } StopCoroutine(PlayerAni(aniInfo, gameAni)); //Debug.Log("Destroy"); Destroy(gameAni); }
// 播放某个动画 public void PlayAni(AniInfo aniInfo) { if (!_isPlaying) { _isPlaying = true; var animator = aniInfo.Ani.GetComponent <Animator> (); aniInfo.Ani.SetActive(true); // 变为显示 switch (aniInfo.Ani.name) { case "ConditionPass": // 通过一个条目 { var text = aniInfo.Ani.transform.Find("Canvas/Text"); text.GetComponent <Text>().text = aniInfo.Params["condition"]; break; } case "LevelUp": // 升级 { var text = aniInfo.Ani.transform.Find("Canvas/Text"); text.GetComponent <Text>().text = aniInfo.Params["level"]; TextController.ReplaceSprite("UI/level_" + aniInfo.Params["quality"], aniInfo.Ani.transform.Find("level_5").gameObject); break; } case "ConditionProgress": // 条目进度 { var text1 = aniInfo.Ani.transform.Find("Canvas/Text"); text1.GetComponent <Text>().text = aniInfo.Params["condition"]; var text2 = aniInfo.Ani.transform.Find("Canvas/Text (1)"); text2.GetComponent <Text>().text = aniInfo.Params["oldNum"]; var text3 = aniInfo.Ani.transform.Find("Canvas (2)/Text"); text3.GetComponent <Text>().text = aniInfo.Params["newNum"]; break; } } animator.Play("Playing"); // 开始播放 } else { lock (_nextAni) { _nextAni.Enqueue(aniInfo); } } }
public void PlayerAniObj(string casterPath, string targetPath, string aniName, int speed) { string path = null; AniInfo aniObj = this.aniFactory.CreateAni(aniName); //Debug.Log(gameObjects[2]); gameAni = Instantiate(gameObjects[aniObj.AniID]); if (aniObj.AniType == 1) { //特效加载自己身上 path = this.sencePos + casterPath; //父节点路径 } else { //特效加载目标身上 path = this.sencePos + targetPath; //父节点路径 } oTarget = GameObject.Find(targetPath); //挂在动画到目标节点上 gameAni.transform.parent = GameObject.Find(path).gameObject.transform; gameAni.transform.localPosition = new Vector3(0, 0, 0); //自行调整位置 //Debug.Log("aniObj.MoveType" + aniObj.MoveType); if (aniObj.MoveType == 1) { float speeds = 4f * (Vector3.Distance(gameAni.transform.position, oTarget.transform.position) / (1 / (aniObj.AniCount * 0.05f))); Debug.Log("speeds" + speeds); if (speeds > 0.1) { StartCoroutine(AniMoves(aniObj, oTarget, speeds)); } } else { StartCoroutine(PlayerAni(aniObj, gameAni)); } StartCoroutine(Hit(GameObject.Find(path).gameObject)); }
public MDLFile(Stream FileInput, Boolean parseAnims = false, Boolean parseHitboxes = false) { using (uReader FileStream = new uReader(FileInput)) { FileStream.ReadTypeFixed(ref MDL_Header, 392); if (MDL_Header.id != 0x54534449) { throw new FileLoadException("File signature does not match 'IDST'"); } //Bones #region Bones //Bones MDL_StudioBones = new mstudiobone_t[MDL_Header.bone_count]; MDL_BoneNames = new String[MDL_Header.bone_count]; for (Int32 BoneID = 0; BoneID < MDL_Header.bone_count; BoneID++) { Int32 boneOffset = MDL_Header.bone_offset + (216 * BoneID); FileStream.ReadTypeFixed(ref MDL_StudioBones[BoneID], 216, boneOffset); MDL_BoneNames[BoneID] = FileStream.ReadNullTerminatedString(boneOffset + MDL_StudioBones[BoneID].sznameindex); } //Bones #endregion #region Hitboxes if (parseHitboxes) { MDL_Hitboxsets = new mstudiohitboxset_t[MDL_Header.hitbox_count]; Hitboxes = new Hitbox[MDL_Header.hitbox_count][]; for (Int32 HitboxsetID = 0; HitboxsetID < MDL_Header.hitbox_count; HitboxsetID++) { Int32 HitboxsetOffset = MDL_Header.hitbox_offset + (12 * HitboxsetID); FileStream.ReadTypeFixed(ref MDL_Hitboxsets[HitboxsetID], 12, HitboxsetOffset); Hitboxes[HitboxsetID] = new Hitbox[MDL_Hitboxsets[HitboxsetID].numhitboxes]; for (Int32 HitboxID = 0; HitboxID < MDL_Hitboxsets[HitboxsetID].numhitboxes; HitboxID++) { Int32 HitboxOffset = HitboxsetOffset + (68 * HitboxID) + MDL_Hitboxsets[HitboxsetID].hitboxindex; Hitboxes[HitboxsetID][HitboxID].BBox = new mstudiobbox_t(); FileStream.ReadTypeFixed(ref Hitboxes[HitboxsetID][HitboxID].BBox, 68, HitboxOffset); } } } #endregion #region Animations if (parseAnims) { try { //Animations MDL_AniDescriptions = new mstudioanimdesc_t[MDL_Header.localanim_count]; Animations = new AniInfo[MDL_Header.localanim_count]; for (Int32 AnimID = 0; AnimID < MDL_Header.localanim_count; AnimID++) { Int32 AnimOffset = MDL_Header.localanim_offset + (100 * AnimID); FileStream.ReadTypeFixed(ref MDL_AniDescriptions[AnimID], 100, AnimOffset); mstudioanimdesc_t StudioAnim = MDL_AniDescriptions[AnimID]; String StudioAnimName = FileStream.ReadNullTerminatedString(AnimOffset + StudioAnim.sznameindex); Animations[AnimID] = new AniInfo { name = StudioAnimName, studioAnim = StudioAnim }; Animations[AnimID].AnimationBones = new List <AnimationBone>(); //mstudioanim_t FileStream.BaseStream.Position = AnimOffset; Int64 StartOffset = FileStream.BaseStream.Position; Int32 CurrentOffset = MDL_AniDescriptions[AnimID].animindex; Int16 NextOffset; do { FileStream.BaseStream.Position = StartOffset + CurrentOffset; Byte BoneIndex = FileStream.ReadByte(); Byte BoneFlag = FileStream.ReadByte(); NextOffset = FileStream.ReadInt16(); CurrentOffset += NextOffset; AnimationBone AnimatedBone = new AnimationBone(BoneIndex, BoneFlag, MDL_AniDescriptions[AnimID].numframes); AnimatedBone.ReadData(FileStream); Animations[AnimID].AnimationBones.Add(AnimatedBone); } while (NextOffset != 0); //mstudioanim_t List <AnimationBone> AnimationBones = Animations[AnimID].AnimationBones; Int32 NumBones = MDL_Header.bone_count; Int32 NumFrames = StudioAnim.numframes; //Used to avoid "Assertion failed" key count in Unity (if frames less than 2) Boolean FramesLess = NumFrames < 2; if (FramesLess) { NumFrames += 1; } Animations[AnimID].PosX = new Keyframe[NumFrames][]; Animations[AnimID].PosY = new Keyframe[NumFrames][]; Animations[AnimID].PosZ = new Keyframe[NumFrames][]; Animations[AnimID].RotX = new Keyframe[NumFrames][]; Animations[AnimID].RotY = new Keyframe[NumFrames][]; Animations[AnimID].RotZ = new Keyframe[NumFrames][]; Animations[AnimID].RotW = new Keyframe[NumFrames][]; for (Int32 FrameID = 0; FrameID < NumFrames; FrameID++) { Animations[AnimID].PosX[FrameID] = new Keyframe[NumBones]; Animations[AnimID].PosY[FrameID] = new Keyframe[NumBones]; Animations[AnimID].PosZ[FrameID] = new Keyframe[NumBones]; Animations[AnimID].RotX[FrameID] = new Keyframe[NumBones]; Animations[AnimID].RotY[FrameID] = new Keyframe[NumBones]; Animations[AnimID].RotZ[FrameID] = new Keyframe[NumBones]; Animations[AnimID].RotW[FrameID] = new Keyframe[NumBones]; } for (Int32 boneID = 0; boneID < NumBones; boneID++) { AnimationBone AnimBone = AnimationBones.FirstOrDefault(x => x.Bone == boneID); //frameIndex < 30 && studioAnimName == "@ak47_reload" for (Int32 frameID = 0; frameID < NumFrames; frameID++) { //get current animation time (length) by divide frame index on "fps" Single time = frameID / StudioAnim.fps; mstudiobone_t StudioBone = MDL_StudioBones[boneID]; //Transform bone = Bones[boneIndex]; Vector3 Position = StudioBone.pos; Vector3 Rotation = StudioBone.rot; //BINGO! All animations are corrected :p if (AnimBone != null) { if ((AnimBone.Flags & STUDIO_ANIM_RAWROT) > 0) { Rotation = MathLibrary.ToEulerAngles(AnimBone.pQuat48); } if ((AnimBone.Flags & STUDIO_ANIM_RAWROT2) > 0) { Rotation = MathLibrary.ToEulerAngles(AnimBone.pQuat64); } if ((AnimBone.Flags & STUDIO_ANIM_RAWPOS) > 0) { Position = AnimBone.pVec48; } if ((AnimBone.Flags & STUDIO_ANIM_ANIMROT) > 0) { Rotation += AnimBone.FrameAngles[(FramesLess && frameID != 0) ? frameID - 1 : frameID].Multiply(StudioBone.rotscale); } if ((AnimBone.Flags & STUDIO_ANIM_ANIMPOS) > 0) { Position += AnimBone.FramePositions[(FramesLess && frameID != 0) ? frameID - 1 : frameID].Multiply(StudioBone.posscale); } if ((AnimBone.Flags & STUDIO_ANIM_DELTA) > 0) { Position = Vector3.zero; Rotation = Vector3.zero; } } //Invert right-handed position to left-handed if (StudioBone.parent == -1) { Position = MathLibrary.SwapY(Position); } else { Position.x = -Position.x; } //Corrects global scale and convert radians to degrees Position *= uLoader.UnitScale; Rotation *= Mathf.Rad2Deg; Quaternion quat; //Fix up bone rotations from right-handed to left-handed if (StudioBone.parent == -1) { quat = Quaternion.Euler(-90, 180, -90) * MathLibrary.AngleQuaternion(Rotation); } else { quat = MathLibrary.AngleQuaternion(Rotation); } Animations[AnimID].PosX[frameID][boneID] = new Keyframe(time, Position.x); Animations[AnimID].PosY[frameID][boneID] = new Keyframe(time, Position.y); Animations[AnimID].PosZ[frameID][boneID] = new Keyframe(time, Position.z); Animations[AnimID].RotX[frameID][boneID] = new Keyframe(time, quat.x); Animations[AnimID].RotY[frameID][boneID] = new Keyframe(time, quat.y); Animations[AnimID].RotZ[frameID][boneID] = new Keyframe(time, quat.z); Animations[AnimID].RotW[frameID][boneID] = new Keyframe(time, quat.w); } } } //Animations //Sequences MDL_SeqDescriptions = new mstudioseqdesc_t[MDL_Header.localseq_count]; Sequences = new SeqInfo[MDL_Header.localseq_count]; for (Int32 seqID = 0; seqID < MDL_Header.localseq_count; seqID++) { Int32 sequenceOffset = MDL_Header.localseq_offset + (212 * seqID); FileStream.ReadTypeFixed(ref MDL_SeqDescriptions[seqID], 212, sequenceOffset); mstudioseqdesc_t Sequence = MDL_SeqDescriptions[seqID]; Sequences[seqID] = new SeqInfo { name = FileStream.ReadNullTerminatedString(sequenceOffset + Sequence.szlabelindex), seq = Sequence }; FileStream.BaseStream.Position = sequenceOffset + Sequence.animindexindex; var animID = FileStream.ReadShortArray(Sequence.groupsize[0] * Sequence.groupsize[1]); //Debug.LogWarning(animIndices[0]); // Just use the first animation for now Sequences[seqID].ani = Animations[animID[0]]; } //Sequences } catch (Exception ex) { Debug.LogError(String.Format("\"{0}\" Parse animation failed: {1}", MDL_Header.Name, ex)); } } #endregion #region Materials //Materials MDL_TexturesInfo = new mstudiotexture_t[MDL_Header.texture_count]; MDL_Textures = new String[MDL_Header.texture_count]; for (Int32 TexID = 0; TexID < MDL_Header.texture_count; TexID++) { Int32 TextureOffset = MDL_Header.texture_offset + (64 * TexID); FileStream.ReadTypeFixed(ref MDL_TexturesInfo[TexID], 64, TextureOffset); MDL_Textures[TexID] = FileStream.ReadNullTerminatedString(TextureOffset + MDL_TexturesInfo[TexID].sznameindex); } Int32[] TDirOffsets = new Int32[MDL_Header.texturedir_count]; MDL_TDirectories = new String[MDL_Header.texturedir_count]; for (Int32 DirID = 0; DirID < MDL_Header.texturedir_count; DirID++) { FileStream.ReadTypeFixed(ref TDirOffsets[DirID], 4, MDL_Header.texturedir_offset + (4 * DirID)); MDL_TDirectories[DirID] = FileStream.ReadNullTerminatedString(TDirOffsets[DirID]); } //Materials #endregion #region BodyParts //Bodyparts MDL_Bodyparts = new StudioBodyPart[MDL_Header.bodypart_count]; for (Int32 BodypartID = 0; BodypartID < MDL_Header.bodypart_count; BodypartID++) { mstudiobodyparts_t BodyPart = new mstudiobodyparts_t(); Int32 BodyPartOffset = MDL_Header.bodypart_offset + (16 * BodypartID); FileStream.ReadTypeFixed(ref BodyPart, 16, BodyPartOffset); if (BodyPart.sznameindex != 0) { MDL_Bodyparts[BodypartID].Name = FileStream.ReadNullTerminatedString(BodyPartOffset + BodyPart.sznameindex); } else { MDL_Bodyparts[BodypartID].Name = String.Empty; } MDL_Bodyparts[BodypartID].Models = new StudioModel[BodyPart.nummodels]; for (Int32 ModelID = 0; ModelID < BodyPart.nummodels; ModelID++) { mstudiomodel_t Model = new mstudiomodel_t(); Int64 ModelOffset = BodyPartOffset + (148 * ModelID) + BodyPart.modelindex; FileStream.ReadTypeFixed(ref Model, 148, ModelOffset); MDL_Bodyparts[BodypartID].Models[ModelID].isBlank = (Model.numvertices <= 0 || Model.nummeshes <= 0); MDL_Bodyparts[BodypartID].Models[ModelID].Model = Model; MDL_Bodyparts[BodypartID].Models[ModelID].Meshes = new mstudiomesh_t[Model.nummeshes]; for (Int32 MeshID = 0; MeshID < Model.nummeshes; MeshID++) { mstudiomesh_t Mesh = new mstudiomesh_t(); Int64 MeshOffset = ModelOffset + (116 * MeshID) + Model.meshindex; FileStream.ReadTypeFixed(ref Mesh, 116, MeshOffset); MDL_Bodyparts[BodypartID].Models[ModelID].Meshes[MeshID] = Mesh; } MDL_Bodyparts[BodypartID].Models[ModelID].IndicesPerLod = new Dictionary <Int32, List <Int32> > [8]; for (Int32 i = 0; i < 8; i++) { MDL_Bodyparts[BodypartID].Models[ModelID].IndicesPerLod[i] = new Dictionary <Int32, List <Int32> >(); } MDL_Bodyparts[BodypartID].Models[ModelID].VerticesPerLod = new mstudiovertex_t[8][]; } } //BodyParts #endregion } }
public Transform BuildModel(Boolean GenerateUV2 = false) { GameObject ModelObject = new GameObject(MDL_Header.Name); #region Bones Transform[] Bones = new Transform[MDL_Header.bone_count]; Dictionary <Int32, String> bonePathDict = new Dictionary <Int32, String>(); for (Int32 boneID = 0; boneID < MDL_Header.bone_count; boneID++) { GameObject BoneObject = new GameObject(MDL_BoneNames[boneID]); Bones[boneID] = BoneObject.transform;//MDL_Bones.Add(BoneObject.transform); Vector3 pos = MDL_StudioBones[boneID].pos * uLoader.UnitScale; Vector3 rot = MDL_StudioBones[boneID].rot * Mathf.Rad2Deg; //Invert x for convert right-handed to left-handed pos.x = -pos.x; if (MDL_StudioBones[boneID].parent >= 0) { Bones[boneID].parent = Bones[MDL_StudioBones[boneID].parent]; } else { //Swap Z & Y and invert Y (ex: X Z -Y) //only for parents, cuz parents used different order vectors float temp = pos.y; pos.y = pos.z; pos.z = -temp; Bones[boneID].parent = ModelObject.transform; } bonePathDict.Add(boneID, Bones[boneID].GetTransformPath(ModelObject.transform)); Bones[boneID].localPosition = pos; //Bones[i].localRotation = MDL_StudioBones[i].quat; if (MDL_StudioBones[boneID].parent == -1) { //Fix up parents Bones[boneID].localRotation = Quaternion.Euler(-90, 90, -90) * MathLibrary.AngleQuaternion(rot); } else { Bones[boneID].localRotation = MathLibrary.AngleQuaternion(rot); } } if (uLoader.DrawArmature) { MDLArmatureInfo DebugArmature = ModelObject.AddComponent <MDLArmatureInfo>(); DebugArmature.boneNodes = Bones; } #endregion #region Hitboxes if (MDL_Hitboxsets != null) { for (Int32 HitboxsetID = 0; HitboxsetID < MDL_Header.hitbox_count; HitboxsetID++) { for (Int32 HitboxID = 0; HitboxID < MDL_Hitboxsets[HitboxsetID].numhitboxes; HitboxID++) { mstudiobbox_t Hitbox = Hitboxes[HitboxsetID][HitboxID].BBox; BoxCollider BBox = new GameObject(String.Format("Hitbox_{0}", Bones[Hitbox.bone].name)).AddComponent <BoxCollider>(); BBox.size = MathLibrary.NegateX(Hitbox.bbmax - Hitbox.bbmin) * uLoader.UnitScale; BBox.center = (MathLibrary.NegateX(Hitbox.bbmax + Hitbox.bbmin) / 2) * uLoader.UnitScale; BBox.transform.parent = Bones[Hitbox.bone]; BBox.transform.localPosition = Vector3.zero; BBox.transform.localRotation = Quaternion.identity; //bbox.transform.tag = HitTagType(MDL_BBoxes[i].group); } } } #endregion #region BodyParts if (BuildMesh) { for (Int32 BodypartID = 0; BodypartID < MDL_Header.bodypart_count; BodypartID++) { StudioBodyPart BodyPart = MDL_Bodyparts[BodypartID]; for (Int32 ModelID = 0; ModelID < BodyPart.Models.Length; ModelID++) { StudioModel Model = BodyPart.Models[ModelID]; //Skip if model is blank if (Model.isBlank) { continue; } #region TODO: Remove this code after find way to strip unused vertexes for lod's (VTXStripGroup / VTXStrip) mstudiovertex_t[] Vertexes = Model.VerticesPerLod[0]; BoneWeight[] BoneWeight = new BoneWeight[Vertexes.Length]; Vector3[] Vertices = new Vector3[Vertexes.Length]; Vector3[] Normals = new Vector3[Vertexes.Length]; Vector2[] UvBuffer = new Vector2[Vertexes.Length]; for (Int32 i = 0; i < Vertexes.Length; i++) { Vertices[i] = MathLibrary.SwapZY(Vertexes[i].m_vecPosition * uLoader.UnitScale); Normals[i] = MathLibrary.SwapZY(Vertexes[i].m_vecNormal); Vector2 UV = Vertexes[i].m_vecTexCoord; if (uLoader.SaveAssetsToUnity && uLoader.ExportTextureAsPNG) { UV.y = -UV.y; } UvBuffer[i] = UV; BoneWeight[i] = GetBoneWeight(Vertexes[i].m_BoneWeights); } #endregion #region LOD Support Boolean DetailModeEnabled = uLoader.DetailMode == DetailMode.Lowest || uLoader.DetailMode == DetailMode.Low || uLoader.DetailMode == DetailMode.Medium || uLoader.DetailMode == DetailMode.High; Boolean LODExist = uLoader.EnableLODParsing && !DetailModeEnabled && Model.NumLODs > 1; Transform FirstLODObject = null; LODGroup LODGroup = null; LOD[] LODs = null; Single MaxSwitchPoint = 100; Int32 StartLODIndex = 0; if (LODExist) { LODs = new LOD[Model.NumLODs]; for (Int32 LODID = 1; LODID < 3; LODID++) { Int32 LastID = Model.NumLODs - LODID; ModelLODHeader_t LOD = Model.LODData[LastID]; //ignore $shadowlod if (LOD.switchPoint != -1) { if (LOD.switchPoint > 0) { MaxSwitchPoint = LOD.switchPoint; } //Set switchPoint from MaxSwitchPoint (if switchPoint is zero or negative) if (LODID == 2 || LOD.switchPoint == 0) { MaxSwitchPoint += MaxSwitchPoint * uLoader.NegativeAddLODPrecent; Model.LODData[LOD.switchPoint == 0 ? LastID : LastID + 1].switchPoint = MaxSwitchPoint; } // + Threshold used to avoid errors with LODGroup MaxSwitchPoint += uLoader.ThresholdMaxSwitch; break; } } } else { if (!uLoader.EnableLODParsing) { Model.NumLODs = 1; } } if (uLoader.EnableLODParsing && DetailModeEnabled) { StartLODIndex = uLoader.DetailMode == DetailMode.Lowest ? (Model.NumLODs - 1) : uLoader.DetailMode == DetailMode.Low ? (Int32)(Model.NumLODs / 1.5f) : uLoader.DetailMode == DetailMode.Medium ? (Model.NumLODs / 2) : (Int32)(Model.NumLODs / 2.5f); } #endregion #region Build Meshes for (Int32 LODID = StartLODIndex; LODID < Model.NumLODs; LODID++) { #region TODO: Uncomment after find way to strip unused vertexes for lod's (VTXStripGroup / VTXStrip) /*mstudiovertex_t[] Vertexes = Model.VerticesPerLod[LODID]; * * BoneWeight[] BoneWeight = new BoneWeight[Vertexes.Length]; * Vector3[] Vertices = new Vector3[Vertexes.Length]; * Vector3[] Normals = new Vector3[Vertexes.Length]; * Vector2[] UvBuffer = new Vector2[Vertexes.Length]; * * for (Int32 i = 0; i < Vertexes.Length; i++) * { * Vertices[i] = MathLibrary.SwapZY(Vertexes[i].m_vecPosition * uLoader.UnitScale); * Normals[i] = MathLibrary.SwapZY(Vertexes[i].m_vecNormal); * * Vector2 UV = Vertexes[i].m_vecTexCoord; * if (uLoader.SaveAssetsToUnity && uLoader.ExportTextureAsPNG) * UV.y = -UV.y; * * UvBuffer[i] = UV; * BoneWeight[i] = GetBoneWeight(Vertexes[i].m_BoneWeights); * }*/ #endregion #region LOD ModelLODHeader_t ModelLOD = Model.LODData[LODID]; if (LODExist) { if (ModelLOD.switchPoint == 0) { ModelLOD.switchPoint = MaxSwitchPoint; } else { ModelLOD.switchPoint = MaxSwitchPoint - ModelLOD.switchPoint; } ModelLOD.switchPoint -= ModelLOD.switchPoint * uLoader.SubstractLODPrecent; } #endregion #region Mesh //Create empty object for mesh GameObject MeshObject = new GameObject(Model.Model.Name); MeshObject.name += "_vLOD" + LODID; MeshObject.transform.parent = ModelObject.transform; //Create empty mesh and fill parsed data Mesh Mesh = new Mesh(); Mesh.name = MeshObject.name; Mesh.subMeshCount = Model.Model.nummeshes; Mesh.vertices = Vertices; //Make sure if mesh exist any vertexes if (Mesh.vertexCount <= 0) { Debug.LogWarning(String.Format("Mesh: \"{0}\" has no vertexes, skip building... (MDL Version: {1})", Mesh.name, MDL_Header.version)); continue; } Mesh.normals = Normals; Mesh.uv = UvBuffer; #endregion #region Renderers Renderer Renderer; //SkinnedMeshRenderer (Models with "animated" bones & skin data) if (!MDL_Header.flags.HasFlag(StudioHDRFlags.STUDIOHDR_FLAGS_STATIC_PROP)) { //Bind poses & bone weights SkinnedMeshRenderer SkinnedRenderer = MeshObject.AddComponent <SkinnedMeshRenderer>(); Renderer = SkinnedRenderer; Matrix4x4[] BindPoses = new Matrix4x4[Bones.Length]; for (Int32 i = 0; i < BindPoses.Length; i++) { BindPoses[i] = Bones[i].worldToLocalMatrix * MeshObject.transform.localToWorldMatrix; } Mesh.boneWeights = BoneWeight; Mesh.bindposes = BindPoses; SkinnedRenderer.sharedMesh = Mesh; SkinnedRenderer.bones = Bones; SkinnedRenderer.updateWhenOffscreen = true; } //MeshRenderer (models with "STUDIOHDR_FLAGS_STATIC_PROP" flag or with generic "static_prop" bone) else { MeshFilter MeshFilter = MeshObject.AddComponent <MeshFilter>(); Renderer = MeshObject.AddComponent <MeshRenderer>(); MeshFilter.sharedMesh = Mesh; } Renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.TwoSided; #endregion #region Debug Stuff #if UNITY_EDITOR DebugMaterial DebugMat = null; if (uLoader.DebugMaterials) { DebugMat = MeshObject.AddComponent <DebugMaterial>(); } #endif #endregion #region Triangles and Materials Material[] Materials = new Material[Mesh.subMeshCount]; for (Int32 MeshID = 0; MeshID < Model.Model.nummeshes; MeshID++) { //Set triangles per lod & submeshes Mesh.SetTriangles(Model.IndicesPerLod[LODID][MeshID], MeshID); //Find & parse materials String MaterialPath; Int32 LastDirID = MDL_TDirectories.Length - 1; for (Int32 DirID = 0; DirID < MDL_TDirectories.Length; DirID++) { MaterialPath = MDL_TDirectories[DirID] + MDL_Textures[Model.Meshes[MeshID].material]; //If material exist if (uResourceManager.ContainsFile(MaterialPath, uResourceManager.MaterialsSubFolder, uResourceManager.MaterialsExtension[0])) { VMTFile VMT = uResourceManager.LoadMaterial(MaterialPath); #region Debug Stuff #if UNITY_EDITOR if (uLoader.DebugMaterials) { DebugMat.Init(VMT); } #endif #endregion //Set material Materials[MeshID] = VMT.Material; break; } else if (DirID == LastDirID) { Materials[MeshID] = uResourceManager.LoadMaterial(String.Empty).Material; } } } Renderer.sharedMaterials = Materials; #endregion #region UV2 #if UNITY_EDITOR if (GenerateUV2) { UnityEditor.SerializedObject so = new UnityEditor.SerializedObject(Renderer); so.FindProperty("m_ScaleInLightmap").floatValue = uLoader.ModelsLightmapSize; so.ApplyModifiedProperties(); MeshObject.isStatic = GenerateUV2; uResourceManager.UV2GenerateCache.Add(Mesh); } #endif #endregion #region Set LOD's if (LODExist) { if (LODID == 0) { LODGroup = MeshObject.AddComponent <LODGroup>(); FirstLODObject = MeshObject.transform; } else if (FirstLODObject != null) { MeshObject.transform.parent = FirstLODObject; } LODs[LODID] = new LOD(ModelLOD.switchPoint / MaxSwitchPoint, new Renderer[] { Renderer }); } if (uLoader.EnableLODParsing && DetailModeEnabled) { break; } #endregion }//lod's per model //Init all parsed lod's into LODGroup if (LODGroup != null) { LODGroup.SetLODs(LODs); } #endregion } //models in bodypart } //Bodypart } #endregion #region Animations if (MDL_SeqDescriptions != null) { var AnimationComponent = ModelObject.AddComponent <Animation>(); for (Int32 seqID = 0; seqID < MDL_SeqDescriptions.Length; seqID++) { SeqInfo Sequence = Sequences[seqID]; AniInfo Animation = Sequence.ani; //Creating "AnimationCurve" for animation "paths" (aka frames where stored position (XYZ) & rotation (XYZW)) AnimationCurve[] posX = new AnimationCurve[MDL_Header.bone_count]; //X AnimationCurve[] posY = new AnimationCurve[MDL_Header.bone_count]; //Y AnimationCurve[] posZ = new AnimationCurve[MDL_Header.bone_count]; //Z AnimationCurve[] rotX = new AnimationCurve[MDL_Header.bone_count]; //X AnimationCurve[] rotY = new AnimationCurve[MDL_Header.bone_count]; //Y AnimationCurve[] rotZ = new AnimationCurve[MDL_Header.bone_count]; //Z AnimationCurve[] rotW = new AnimationCurve[MDL_Header.bone_count]; //W //Fill "AnimationCurve" arrays for (Int32 boneIndex = 0; boneIndex < MDL_Header.bone_count; boneIndex++) { posX[boneIndex] = new AnimationCurve(); posY[boneIndex] = new AnimationCurve(); posZ[boneIndex] = new AnimationCurve(); rotX[boneIndex] = new AnimationCurve(); rotY[boneIndex] = new AnimationCurve(); rotZ[boneIndex] = new AnimationCurve(); rotW[boneIndex] = new AnimationCurve(); } Int32 numFrames = Animation.studioAnim.numframes; //Used to avoid "Assertion failed" key count in Unity (if frames less than 2) if (numFrames < 2) { numFrames += 1; } //Create animation clip AnimationClip clip = new AnimationClip(); //Make it for legacy animation system (for now, but it possible to rework for Mecanim) clip.legacy = true; //Set animation clip name clip.name = Animation.name; //To avoid problems with "obfuscators" / "protectors" for models, make sure if model have name in sequence if (String.IsNullOrEmpty(clip.name)) { clip.name = "(empty)" + seqID; } for (Int32 frameIndex = 0; frameIndex < numFrames; frameIndex++) { //Get current frame from blend (meaning from "Animation") by index //AnimationFrame frame = Animation.Frames[frameIndex]; //Set keys (position / rotation) from current frame for (Int32 boneIndex = 0; boneIndex < Bones.Length; boneIndex++) { posX[boneIndex].AddKey(Animation.PosX[frameIndex][boneIndex]); posY[boneIndex].AddKey(Animation.PosY[frameIndex][boneIndex]); posZ[boneIndex].AddKey(Animation.PosZ[frameIndex][boneIndex]); rotX[boneIndex].AddKey(Animation.RotX[frameIndex][boneIndex]); rotY[boneIndex].AddKey(Animation.RotY[frameIndex][boneIndex]); rotZ[boneIndex].AddKey(Animation.RotZ[frameIndex][boneIndex]); rotW[boneIndex].AddKey(Animation.RotW[frameIndex][boneIndex]); //Set default pose from the first animation if (seqID == 0 && frameIndex == 0) { Bones[boneIndex].localPosition = new Vector3 ( Animation.PosX[0][boneIndex].value, Animation.PosY[0][boneIndex].value, Animation.PosZ[0][boneIndex].value ); Bones[boneIndex].localRotation = new Quaternion ( Animation.RotX[0][boneIndex].value, Animation.RotY[0][boneIndex].value, Animation.RotZ[0][boneIndex].value, Animation.RotW[0][boneIndex].value ); } } } //Apply animation paths (Position / Rotation) to clip for (Int32 boneIndex = 0; boneIndex < MDL_Header.bone_count; boneIndex++) { clip.SetCurve(bonePathDict[boneIndex], typeof(Transform), "localPosition.x", posX[boneIndex]); clip.SetCurve(bonePathDict[boneIndex], typeof(Transform), "localPosition.y", posY[boneIndex]); clip.SetCurve(bonePathDict[boneIndex], typeof(Transform), "localPosition.z", posZ[boneIndex]); clip.SetCurve(bonePathDict[boneIndex], typeof(Transform), "localRotation.x", rotX[boneIndex]); clip.SetCurve(bonePathDict[boneIndex], typeof(Transform), "localRotation.y", rotY[boneIndex]); clip.SetCurve(bonePathDict[boneIndex], typeof(Transform), "localRotation.z", rotZ[boneIndex]); clip.SetCurve(bonePathDict[boneIndex], typeof(Transform), "localRotation.w", rotW[boneIndex]); } if (Animation.studioAnim.fps > 0.0f) { clip.frameRate = Animation.studioAnim.fps; } //This ensures a smooth interpolation (corrects the problem of "jitter" after 180~270 degrees rotation path) //can be "comment" if have idea how to replace this clip.EnsureQuaternionContinuity(); AnimationComponent.AddClip(clip, clip.name); } } #endregion //If model has compiled flag "$staticprop" //then rotate this model by 90 degrees (Y) //https://github.com/ValveSoftware/source-sdk-2013/blob/master/sp/src/public/studio.h#L1965 //Big thanks for this tip: //ShadelessFox //REDxEYE if (MDL_Header.flags.HasFlag(StudioHDRFlags.STUDIOHDR_FLAGS_STATIC_PROP)) { ModelObject.transform.eulerAngles = new Vector3(0, 90, 0); } return(ModelObject.transform); }
// Update is called once per frame void Update() { if (!m_IsPlay) { //输入命令阶段 if (m_NowInputNum == 4) //结算阶段 { m_IsOver = SendToControl(); //发送信息,结算数据 //Debug.Log("SendToControl " + m_IsOver); if (m_IsOver == -2) //三个人命令未输完 { Init(m_NowPlayerID + 1); } else //数完后开始准备播放,更新数据 { m_FlyBloodPlay.Clear(); m_AniPlay.Clear(); m_IsPlay = true; float now = 0f; m_AniStartTime = Time.time; foreach (GameInfo info in gameControl.gameInfo) //计算时间 { //info.PrintInfo(); int ObjID = info.ObjID; //技能帧数获得,还没有写 int PlayID = ObjID; if (PlayID < 50) { PlayID = 0; } // 道具部分全部转为负数 // 默认技能伤害是正数 if (info.InjuryInfo.Count == 0) { continue; } //for(int i=0;i<info.InjuryInfo.Count;i++){ // for(int j=0;j<info.InjuryInfo[i].Count;j++){ // if(ObjID==0){ // //info.InjuryInfo[i][j].Injuty=-info.InjuryInfo[i][j].Injuty; // } // } //} AniFactory af = new AniFactory(); //Debug.Log(af.ToString() + " " + ObjID); //Debug.Log(af.aniDicts.ToString()); Dictionary <string, List <string> > nowSkillPlay = null; nowSkillPlay = af.aniDicts[PlayID]; //Debug.Log(nowSkillPlay); if (nowSkillPlay == null) { continue; } bool flag1 = false; for (int i = 0; i < info.InjuryInfo.Count; i++) { for (int j = 0; j < info.InjuryInfo[i].Count; j++) { flag1 = true; } } if (!flag1) { continue; } foreach (string skillpath in nowSkillPlay["我方"]) { AniInfo aniInfo = af.aniDict[skillpath]; m_AniPlay.Add(now, new AniInformation(info.CasterPos, 0, skillpath)); //技能播放名字获得,还没有写 float iMusicTime = GetMusicTime(skillpath); if (GetMusicTime(skillpath) != 0) { m_MusicPlay.Add(now, skillpath); } now += 0.05f * aniInfo.AniCount; now += 1; } for (int i = 0; i < info.InjuryInfo.Count; i++) { bool flag = true; for (int j = 0; j < info.InjuryInfo[i].Count; j++) { foreach (string skillpath in af.aniDicts[PlayID]["敌方"]) { float iMusicTime = GetMusicTime(skillpath); if (GetMusicTime(skillpath) != 0 && flag) { m_MusicPlay.Add(now, skillpath); flag = false; } m_AniPlay.Add(now, new AniInformation(info.CasterPos, info.InjuryInfo[i][j].TargetPos, skillpath)); //技能播放名字获得,还没有写 now += 0.05f; } m_FlyBloodPlay.Add(now, info.InjuryInfo[i][j]); } if (af.aniDicts[PlayID]["敌方"].Count > 0) { AniInfo aniInfo = af.aniDict[af.aniDicts[PlayID]["敌方"][0]]; now += 0.05f * aniInfo.AniCount; } now += 1.5f; //飙血时间延迟1.5s } now += 0.5f; //for (int i = 0; i < info.InjuryInfo.Count; i++) //{ // for (int j = 0; j < info.InjuryInfo[i].Count; j++) // { // m_FlyBloodPlay.Add(now, info.InjuryInfo[i][j]); // now += 0.05f; // } // now += 1f; //} } } } } else { //动画播放阶段,每一帧去扫所有播放字典,时间到的既能播放,后从字典删除 if (m_NowInputNum == 4) { List <float> tamplist = new List <float>(); foreach (float key in m_FlyBloodPlay.Keys) { if (key < Time.time - m_AniStartTime) { //Debug.Log(m_FlyBloodPlay[key].TargetPos.ToString() + " " + m_FlyBloodPlay[key].Injuty.ToString()); FlyBloodPlay(m_FlyBloodPlay[key].TargetPos, m_FlyBloodPlay[key].Injuty); m_DataShowUI.GetComponent <CBattleShow>().Refresh(); m_self.GetComponent <CWarriorObj>().AtkBloodByLocal(m_FlyBloodPlay[key].TargetPos, m_FlyBloodPlay[key].Injuty); //Debug.Log(" "+ m_self.GetComponent<CWarriorObj>().GetScrollbar(m_FlyBloodPlay[key].TargetPos).IsDie() + " Refresh(m_FlyBloodPlay[key].TargetPos)" + m_FlyBloodPlay[key].TargetPos); if (m_self.GetComponent <CWarriorObj>().GetScrollbar(m_FlyBloodPlay[key].TargetPos).IsDie()) { m_self.GetComponent <CWarriorObj>().Refresh(m_FlyBloodPlay[key].TargetPos); } tamplist.Add(key); } } foreach (float key in m_MusicPlay.Keys) { if (key < Time.time - m_AniStartTime) { //Debug.Log(m_MusicPlay[key].ToString()); PlayMusic(m_MusicPlay[key]); tamplist.Add(key); } } foreach (float key in m_AniPlay.Keys) { if (key < Time.time - m_AniStartTime) { //Debug.Log(m_AniPlay[key].Casterlocal.ToString() + " " + m_AniPlay[key].Targetlocal.ToString() + " " + m_AniPlay[key].AniName1.ToString()); PlayAni(m_AniPlay[key].Casterlocal, m_AniPlay[key].Targetlocal, m_AniPlay[key].AniName1); tamplist.Add(key); } } foreach (float key in tamplist) { if (m_FlyBloodPlay.ContainsKey(key)) { m_FlyBloodPlay.Remove(key); } if (m_AniPlay.ContainsKey(key)) { m_AniPlay.Remove(key); } if (m_MusicPlay.ContainsKey(key)) { m_MusicPlay.Remove(key); } } //int IsOver = gameControl.GameStart(ref startTime); if (m_FlyBloodPlay.Count == 0 && m_AniPlay.Count == 0) //技能播放完毕,更新数据,这里血条才会更新,没能随着播放动画更新 { m_IsPlay = false; m_NowInputNum = 0; m_DataShowUI.GetComponent <CBattleShow>().Refresh(); playDieAni(); //m_self.GetComponent<CWarriorObj>().Refresh(); m_self.GetComponent <CWarriorObj>().RefreshBuff(); if (m_IsOver == 0) //若未结束战斗开始新的回合 { Init(0); } else if (m_IsOver == -1) //结束战斗结算,还没有写 { StartCoroutine(BattleEndL()); // 播放结束音乐 //。。。 BgMusic.dd.StopBgMusic(); BgMusic.dd.LoadMusicSource("fail"); BgMusic.dd.PlayBgMusic(); } else if (m_IsOver == 1) { BgMusic.dd.StopBgMusic(); BgMusic.dd.LoadMusicSource(); BgMusic.dd.PlayBgMusic(); Debug.Log("Win!"); int exp = 0; int gold = 0; foreach (Person p in gameControl.GameSence.enemyList) { exp += p.Experience; gold += p.Money; } CPlayerData.pd.bag.Money += gold; foreach (Person p in gameControl.GameSence.playerList) { p.buffs.Clear(); p.CurrentExperience += exp; if (p.CurrentExperience > p.CalculateExperienceMax()) { p.LvUp(); } } StartCoroutine(BattleEndV()); int i = UnityEngine.Random.Range(0, 1); if (i == 0) { int nowtask = CPlayerData.pd.GetTaskNum(); TaskList tl = CPlayerData.pd.tl; Task nowTask = tl.GetTaskStatus(nowtask); if (nowTask != null) { if (m_NowBattle == nowTask.FightID) { //完成5此任务,用来测试 tl.AddTaskCurrentNumber(nowtask, m_MonsterTask[m_NowBattle]); Debug.Log("get! " + nowtask + " " + m_MonsterTask[m_NowBattle]); } if (tl.CheckTask(nowtask)) { CPlayerData.pd.SetTaskNum(nowtask + 1); Debug.Log("complite"); } } } } } } } }
public AniInfo CreateAni(string aniName) { AniInfo aniInfo = this.aniDict[aniName]; return(aniInfo); }
public void LoadLowData() { { TextAsset data = Resources.Load("TestJson/Resource_Ani", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject Ani = new JSONObject(strSrc); { //Null데이터용 0번 애니메이션을 넣어줘야한다. AniInfo tmpInfo = new AniInfo(); tmpInfo.id = 0; tmpInfo.aniName = "none"; tmpInfo.effect = "none"; tmpInfo.cameraShakeSet = 0; tmpInfo.rootMotion = false; tmpInfo.killPushOffset = 0; tmpInfo.childEffect = 0; tmpInfo.seSkill = 0; tmpInfo.voiceTime = 0; AniInfoDic.Add(tmpInfo.id, tmpInfo); } for (int i = 0; i < Ani.list.Count; i++) { AniInfo tmpInfo = new AniInfo(); tmpInfo.id = (uint)Ani[i]["id_ui"].n; tmpInfo.aniName = Ani[i]["aniName_c"].str; tmpInfo.effect = Ani[i]["effect_c"].str; tmpInfo.cameraShakeSet = (byte)Ani[i]["cameraShakeSet_b"].n; if (Ani[i]["rootMotion_is"].n == 0) { tmpInfo.rootMotion = false; } else { tmpInfo.rootMotion = true; } tmpInfo.killPushOffset = (float)Ani[i]["killPushOffset_f"].n; tmpInfo.childEffect = (byte)Ani[i]["childEffect_b"].n; tmpInfo.seSkill = (uint)Ani[i]["seSkill_ui"].n; tmpInfo.voice = new JsonCustomData(Ani[i]["voice_j"].ToString()); tmpInfo.voiceTime = (ushort)Ani[i]["voiceTime_us"].n; AniInfoDic.Add(tmpInfo.id, tmpInfo); } } { TextAsset data = Resources.Load("TestJson/Resource_Sound", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject Sound = new JSONObject(strSrc); for (int i = 0; i < Sound.list.Count; i++) { SoundInfo tmpInfo = new SoundInfo(); tmpInfo.id = (uint)Sound[i]["id_ui"].n; tmpInfo.soundFile = Sound[i]["soundFile_c"].str; SoundInfoDic.Add(tmpInfo.id, tmpInfo); } } { TextAsset data = Resources.Load("TestJson/Resource_Unit", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject Unit = new JSONObject(strSrc); for (int i = 0; i < Unit.list.Count; i++) { UnitInfo tmpInfo = new UnitInfo(); tmpInfo.id = (uint)Unit[i]["id_ui"].n; tmpInfo.unitType = (byte)Unit[i]["unitType_b"].n; tmpInfo.aniIdle01 = (uint)Unit[i]["aniIdle01_ui"].n; tmpInfo.battleAniIdle01 = (uint)Unit[i]["battleAniIdle01_ui"].n; tmpInfo.aniRun = (uint)Unit[i]["aniRun_ui"].n; tmpInfo.aniHit01 = (uint)Unit[i]["aniHit01_ui"].n; tmpInfo.aniDie01 = (uint)Unit[i]["aniDie01_ui"].n; tmpInfo.aniIntro = (uint)Unit[i]["aniIntro_ui"].n; tmpInfo.aniStand = (uint)Unit[i]["aniStand_ui"].n; tmpInfo.aniDown = (uint)Unit[i]["aniDown_ui"].n; tmpInfo.aniSpecial = (uint)Unit[i]["aniSpecial_ui"].n; tmpInfo.aniRevival = (uint)Unit[i]["aniRevival_ui"].n; tmpInfo.aniStun = (uint)Unit[i]["aniStun_ui"].n; tmpInfo.aniVictory = (uint)Unit[i]["aniVictory_ui"].n; tmpInfo.aniFail = (uint)Unit[i]["aniFail_ui"].n; tmpInfo.aniFailIdle = (uint)Unit[i]["aniFailIdle_ui"].n; tmpInfo.awakenEffect = (uint)Unit[i]["awakenEffect_ui"].n; tmpInfo.AniAttack01 = (uint)Unit[i]["AniAttack01_ui"].n; tmpInfo.AniAttack02 = (uint)Unit[i]["AniAttack02_ui"].n; tmpInfo.AniAttack03 = (uint)Unit[i]["AniAttack03_ui"].n; tmpInfo.AniAttack04 = (uint)Unit[i]["AniAttack04_ui"].n; tmpInfo.AniSkill01 = (uint)Unit[i]["AniSkill01_ui"].n; tmpInfo.AniSkill02 = (uint)Unit[i]["AniSkill02_ui"].n; tmpInfo.AniSkill03 = (uint)Unit[i]["AniSkill03_ui"].n; tmpInfo.AniSkill04 = (uint)Unit[i]["AniSkill04_ui"].n; tmpInfo.AniSkill05 = (uint)Unit[i]["AniSkill05_ui"].n; tmpInfo.AniSkill06 = (uint)Unit[i]["AniSkill06_ui"].n; tmpInfo.AniSkill07 = (uint)Unit[i]["AniSkill07_ui"].n; tmpInfo.AniSkill08 = (uint)Unit[i]["AniSkill08_ui"].n; tmpInfo.AniChain = (uint)Unit[i]["AniChain_ui"].n; tmpInfo.aniWalk = (uint)Unit[i]["aniWalk_ui"].n; tmpInfo.ExtraAni = (uint)Unit[i]["ExtraAni_ui"].n; tmpInfo.aniIntroStart = (uint)Unit[i]["aniIntroStart01_ui"].n; tmpInfo.aniIntroEnd = (uint)Unit[i]["aniIntroEnd01_ui"].n; UnitInfoDic.Add(tmpInfo.id, tmpInfo); } } }