protected override void OnUpdate() { List <EntryBeeAnim> listAnim = GameManager.entitiesBeeAnim; for (int i = 0; i < childData.Length; i++) { ChildComponent child = childData.Child[i]; BeeAnimatorComponent anim = childData.Animator[i]; int currentDirIndex = anim.currentDirIndex; BeeAnimationState currentState = anim.currentState; int dirIndex = listAnim[child.AnimIndex].DirIndex; BeeAnimationState state = listAnim[child.AnimIndex].State; if (state != currentState) { anim.animator.Play(state.ToString()); anim.currentState = state; } if (dirIndex != currentDirIndex) { float2 facingValues = float2.zero; switch (dirIndex) { case 1: //DOWN facingValues = new float2(0f, -1f); break; case 2: //LEFT facingValues = new float2(-1f, 0f); break; case 3: //UP facingValues = new float2(0f, 1f); break; case 4: //RIGHT facingValues = new float2(1f, 0f); break; } anim.animator.SetFloat(Constants.AnimatorParameter.Float.FACE_X, facingValues.x); anim.animator.SetFloat(Constants.AnimatorParameter.Float.FACE_Y, facingValues.y); anim.currentDirIndex = dirIndex; } } }
protected override void OnUpdate() { deltaTime = Time.deltaTime; List <float3> listPos = GameManager.entitiesPos; List <int> emptyPosIndexes = GameManager.emptyPosIndexes; List <int> emptyProjectileAnimIndexes = GameManager.emptyProjectileAnimIndexes; for (int i = 0; i < data.Length; i++) { PlayerAttackComponent playerAttackComponent = data.PlayerAttackComponent[i]; ChildComponent childComponent = data.ChildComponent[i]; float destroyDuration = playerAttackComponent.duration; float destroyTimer = playerAttackComponent.timer; if (destroyTimer >= destroyDuration) { //Add pos index to List of empty pos index emptyPosIndexes.Add(childComponent.PosIndex); //Add anim index to List of empty anim index emptyProjectileAnimIndexes.Add(childComponent.AnimIndex); // GameDebug.Log("childComponent.PosIndex "+childComponent.PosIndex+"\n listPos "+listPos[childComponent.PosIndex]); GameObjectEntity.Destroy(playerAttackComponent.gameObject); UpdateInjectedComponentGroups(); foreach (int a in emptyPosIndexes) { GameDebug.Log(a); } } else { playerAttackComponent.timer += deltaTime; } } }
protected override void OnUpdate() { List <float3> listPos = GameManager.entitiesPos; for (int i = 0; i < parentData.Length; i++) { Parent parent = parentData.Parent[i]; Position position = parentData.ParentPosition[i]; //SET PARENT POSITION float3 parentPosValue = position.Value; listPos[parent.PosIndex] = parentPosValue; } for (int j = 0; j < childData.Length; j++) { ChildComponent child = childData.Child[j]; Transform ChildTransform = childData.ChildTransform[j]; //GET PARENT POSITION float3 parentPosValue = listPos[child.PosIndex]; ChildTransform.position = parentPosValue; } }
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 } }