protected override void OnUpdate() { EntityCommandBuffer commandBuffer = PostUpdateCommands; List <EntryPlayerAnim> listAnim = GameManager.entitiesPlayerAnim; for (int i = 0; i < parentData.Length; i++) { Entity animEntity = parentData.AnimationIdleEntities[i]; Parent parent = parentData.Parent[i]; Player player = parentData.Player[i]; FaceDirection faceDir = parentData.FaceDirection[i]; commandBuffer.RemoveComponent <AnimationPlayerAttack1>(animEntity); //SET LIST // int dirIndex = faceDir.dirIndex; // float3 faceDirValue = faceDir.Value; PlayerAnimationState state = PlayerAnimationState.ATTACK_1; // int endAnimToggle = listAnim[parent.AnimIndex].EndAnimationToggle; EntryPlayerAnim entryPlayerAnim = listAnim[parent.AnimIndex]; entryPlayerAnim.State = state; entryPlayerAnim.StartAnimationToggle = 21; // listAnim[parent.AnimIndex] = new EntryPlayerAnim(dirIndex, faceDirValue, state, 21, endAnimToggle); listAnim[parent.AnimIndex] = entryPlayerAnim; //SET TO PLAYER (PARENT) player.State = state; parentData.Player[i] = player; } }
protected override void OnUpdate() { EntityCommandBuffer commandBuffer = PostUpdateCommands; List <EntryPlayerAnim> listAnim = GameManager.entitiesPlayerAnim; int maxPlayerAttackIndex = GameManager.settings.maxPlayerAttackIndex; for (int i = 0; i < data.Length; i++) { Entity animEntity = data.AnimationEntities[i]; Player player = data.Player[i]; MoveDirection moveDir = data.MoveDirection[i]; FaceDirection faceDir = data.FaceDirection[i]; Parent parent = data.Parent[i]; // PlayerAnimationState state = player.State; // Vector3 direction = moveDir.Value; int playerStartAnimToggle = player.StartAnimationToggle; int playerEndAnimToggle = player.EndAnimationToggle; int animIndex = parent.AnimIndex; EntryPlayerAnim entryPlayerAnim = listAnim[animIndex]; PlayerAnimationState state = player.State; int dirIndex = faceDir.dirIndex; float3 faceDirValue = faceDir.Value; #region START ANIMATION if (playerStartAnimToggle != 0) { switch (playerStartAnimToggle) { case 1: commandBuffer.AddComponent(animEntity, new AnimationPlayerIdleStand { }); break; case 2: commandBuffer.AddComponent(animEntity, new AnimationPlayerMoveRun { }); break; case 21: commandBuffer.AddComponent(animEntity, new AnimationPlayerAttack1 { }); commandBuffer.RemoveComponent <PlayerInputDirection>(animEntity); commandBuffer.RemoveComponent <PlayerInputAttack>(animEntity); moveDir.Value = float3Zero; data.MoveDirection[i] = moveDir; break; case 22: commandBuffer.AddComponent(animEntity, new AnimationPlayerAttack2 { }); commandBuffer.RemoveComponent <PlayerInputDirection>(animEntity); commandBuffer.RemoveComponent <PlayerInputAttack>(animEntity); moveDir.Value = float3Zero; data.MoveDirection[i] = moveDir; break; case 23: commandBuffer.AddComponent(animEntity, new AnimationPlayerAttack3 { }); commandBuffer.RemoveComponent <PlayerInputDirection>(animEntity); commandBuffer.RemoveComponent <PlayerInputAttack>(animEntity); moveDir.Value = float3Zero; data.MoveDirection[i] = moveDir; break; } //SET LIST // int endAnimToggle = listAnim[animIndex].EndAnimationToggle; entryPlayerAnim.DirIndex = dirIndex; entryPlayerAnim.FaceDirValue = faceDirValue; // entryPlayerAnim.State = state; // entryPlayerAnim.StartAnimationToggle = 0; // listAnim[animIndex] = new EntryPlayerAnim(dirIndex, faceDirValue, state, 0, endAnimToggle); listAnim[animIndex] = entryPlayerAnim; //SET TO PLAYER (PARENT) player.StartAnimationToggle = 0; data.Player[i] = player; } #endregion #region END ANIMATION if (playerEndAnimToggle != 0) { switch (playerEndAnimToggle) { case 1: commandBuffer.AddComponent(animEntity, new AnimationPlayerIdleStand { }); player.AttackIndex = 0; data.Player[i] = player; break; case 2: commandBuffer.AddComponent(animEntity, new PlayerInputDirection { }); commandBuffer.AddComponent(animEntity, new PlayerInputAttack { }); int attackIndex = player.AttackIndex >= maxPlayerAttackIndex ? 0 : player.AttackIndex + 1; player.AttackIndex = attackIndex; data.Player[i] = player; break; } //SET LIST // int startAnimToggle = listAnim[animIndex].StartAnimationToggle; entryPlayerAnim.State = state; entryPlayerAnim.EndAnimationToggle = 0; // listAnim[animIndex] = new EntryPlayerAnim(dirIndex, faceDirValue, state, startAnimToggle, 0); listAnim[animIndex] = entryPlayerAnim; //SET TO PLAYER (PARENT) player.EndAnimationToggle = 0; data.Player[i] = player; } #endregion } }
protected override void OnUpdate() { List <EntryPlayerAnim> listAnim = GameManager.entitiesPlayerAnim; for (int i = 0; i < parentData.Length; i++) { Parent parent = parentData.Parent[i]; Player player = parentData.Player[i]; int parentIndex = parent.AnimIndex; EntryPlayerAnim entryPlayerAnim = listAnim[parentIndex]; int endAnimToggle = entryPlayerAnim.EndAnimationToggle; int currentEndAnimToggle = player.EndAnimationToggle; if (endAnimToggle != currentEndAnimToggle) { player.EndAnimationToggle = endAnimToggle; parentData.Player[i] = player; } } for (int j = 0; j < childData.Length; j++) { ChildComponent child = childData.Child[j]; PlayerAnimatorComponent anim = childData.Animator[j]; int childIndex = child.AnimIndex; EntryPlayerAnim entryPlayerAnim = listAnim[childIndex]; float3 faceDirValue = entryPlayerAnim.FaceDirValue; PlayerAnimationState state = entryPlayerAnim.State; #region DIRECTION int dirIndex = entryPlayerAnim.DirIndex; int currentDirIndex = anim.currentDirIndex; if (dirIndex != currentDirIndex) { anim.animator.SetFloat(Constants.AnimatorParameter.Float.FACE_X, faceDirValue.x); anim.animator.SetFloat(Constants.AnimatorParameter.Float.FACE_Y, faceDirValue.z); anim.currentDirIndex = dirIndex; anim.currentFaceDirValue = faceDirValue; } #endregion #region PLAY & STOP ANIMATION // PlayerAnimationState currentState = anim.currentState; int playerStartAnimToggle = entryPlayerAnim.StartAnimationToggle; // int currentPlayerStartAnimToggle = anim.currentPlayerStartAnimToggle; if (playerStartAnimToggle != 0) { anim.animator.Play(state.ToString()); anim.currentState = state; // anim.currentPlayerStartAnimToggle = playerStartAnimToggle; entryPlayerAnim.StartAnimationToggle = 0; listAnim[childIndex] = entryPlayerAnim; } else { // int startAnimToggle = listAnim[childIndex].StartAnimationToggle; if (anim.isCheckOnEndAnimation) { entryPlayerAnim.EndAnimationToggle = 1; // listAnim[childIndex] = new EntryPlayerAnim(dirIndex, faceDirValue, state, startAnimToggle, 1); listAnim[childIndex] = entryPlayerAnim; anim.isCheckOnEndAnimation = false; } if (anim.isCheckOnEndSpecificAnimation) { entryPlayerAnim.EndAnimationToggle = 2; // listAnim[childIndex] = new EntryPlayerAnim(dirIndex, faceDirValue, state, startAnimToggle, 2); listAnim[childIndex] = entryPlayerAnim; anim.isCheckOnEndSpecificAnimation = false; } } #endregion } }