protected override void OnUpdate() { Entities .WithoutBurst() .WithStructuralChanges() .ForEach((Entity entity, SpriteRenderer renderer, ref HitComponent hitComp, ref AnimationFrameComponent animComp) => { if (false == AnimUtility.HasState(animComp, AnimUtility.hit)) { animComp.state |= AnimUtility.hit; renderer.color = hitComp.hitEffectColor; GamePause.Pause(0.15f); } hitComp.elapsedTime += Time.DeltaTime; if ((hitComp.elapsedTime >= hitComp.hitEffectTime) && (renderer.color == hitComp.hitEffectColor)) { renderer.color = Color.white; } else if (hitComp.elapsedTime >= hitComp.godTime) { animComp.state ^= AnimUtility.hit; EntityManager.RemoveComponent <HitComponent>(entity); EntityManager.RemoveComponent <MoveComponent>(entity); } }).Run(); }
protected override void OnUpdate() { if (IsLocked()) { return; } Entities.ForEach((Entity entity, ref ControlComponent controlComp, ref AnimationFrameComponent animComp) => { if (EntityManager.HasComponent <AttackComponent>(entity)) { if (1.0f <= animComp.frameRate) { EntityManager.RemoveComponent <AttackComponent>(entity); } if (false == AnimUtility.HasState(animComp, AnimUtility.attack)) { animComp.state |= AnimUtility.attack; } } else { if (AnimUtility.HasState(animComp, AnimUtility.attack)) { animComp.state ^= AnimUtility.attack; } } }); }
protected override void OnUpdate() { if (GameOver.bIsOvered == hasBeenOvered) { return; } hasBeenOvered = GameOver.bIsOvered; if (GameOver.bIsOvered) { Entities.WithName("GameOverSystem") .WithoutBurst() .WithStructuralChanges() .ForEach((Entity entity, ref TargetIdComponent idComp, ref AnimationFrameComponent animComp) => { if (IdUtility.Id.Player != idComp.value) { return; } if (false == AnimUtility.HasState(animComp, AnimUtility.hit)) { animComp.state |= AnimUtility.hit; } if (false == EntityManager.HasComponent <GUIComponent>(Utility.SystemEntity)) { EntityManager.AddComponentData(Utility.SystemEntity, new GUIComponent() { id = IdUtility.GUIId.Over }); } }) .Run(); } }
protected override void OnUpdate() { Entities.ForEach((Entity entity, ref Translation transComp, ref MoveComponent moveComp, ref AnimationFrameComponent animComp) => { var calcPos = transComp.Value; calcPos.y = GetPositionY(entity, calcPos); calcPos.x = GetPositionX(entity, calcPos); var dir = calcPos - transComp.Value; if (false == EntityManager.HasComponent <TargetIdFollowComponent>(entity)) { #region Run var bMovingX = math.FLT_MIN_NORMAL < math.abs(moveComp.value.x); var bRunning = ((0.0f < dir.x) && (Utility.stepOffset < dir.x)) || (0.0f > dir.x) && (-Utility.stepOffset > dir.x); if (bMovingX || bRunning) { animComp.bFlipX = bMovingX ? moveComp.value.x < 0.0f : animComp.bFlipX; if (false == AnimUtility.HasState(animComp, AnimUtility.run)) { animComp.state |= AnimUtility.run; } } else { if (AnimUtility.HasState(animComp, AnimUtility.run)) { animComp.state ^= AnimUtility.run; } } #endregion #region Jump var bMovingY = math.FLT_MIN_NORMAL < math.abs(Utility.terminalVelocity - moveComp.value.y); var bFalling = (0.0f > dir.y) && (-Utility.stepOffset > dir.y); var bJumping = (0.0f < dir.y) && (Utility.stepOffset < dir.y); if (bMovingY || bJumping || bFalling) { if (false == AnimUtility.HasState(animComp, AnimUtility.jump)) { animComp.state |= AnimUtility.jump; } } else { if (AnimUtility.HasState(animComp, AnimUtility.jump)) { animComp.state ^= AnimUtility.jump; EntityManager.AddComponentData(entity, new InstantAudioComponent() { id = SoundUtility.ClipKey.Landing, pos = calcPos, }); var effectSpawnEntity = EntityManager.CreateEntity(); EntityManager.AddComponentData(effectSpawnEntity, new EffectSpawnComponent { id = EffectUtility.Key.Landing, pos = calcPos, rot = quaternion.identity, scale = new float3(0.5f) }); } } #endregion #region Crouch if (EntityManager.HasComponent <CrouchComponent>(entity)) { animComp.state |= AnimUtility.crouch; } else if (AnimUtility.HasState(animComp, AnimUtility.crouch)) { animComp.state ^= AnimUtility.crouch; } #endregion #region FrameLock // jump anim lock if (EntityManager.HasComponent <CrouchComponent>(entity)) { EntityManager.AddComponentData(entity, new AnimationLockComponent(1)); } else if (bJumping) { if (false == EntityManager.HasComponent <AnimationLockComponent>(entity)) { EntityManager.AddComponentData(entity, new AnimationLockComponent(2)); } } else { if (EntityManager.HasComponent <AnimationLockComponent>(entity)) { EntityManager.RemoveComponent <AnimationLockComponent>(entity); } } #endregion } transComp.Value = calcPos; }); }