Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Tick()
- {
- var delta = Time.delta;
- #region ACTION MOVE
- foreach (var entity in groupActionMove)
- {
- var cMotion = entity.ComponentMotion();
- var cActionMove = entity.ComponentActionMove();
- var cPlayer = entity.ComponentPlayer();
- float x = cPlayer.source.GetAxisRaw(DataInputActions.Default.Horizontal);
- float y = cPlayer.source.GetAxisRaw(DataInputActions.Default.Vertical);
- cMotion.direction.x = Math.Abs(x) > 0.65f ? x : 0;
- cMotion.direction.y = Math.Abs(y) > 0.65f ? y : 0;
- cMotion.speed = cActionMove.speed;
- }
- foreach (var entity in groupActionTurn)
- {
- var cView = entity.ComponentView();
- var cPlayer = entity.ComponentPlayer();
- float x = cPlayer.source.GetAxisRaw(DataInputActions.Default.Horizontal);
- if (x != 0)
- cView.facing = x > 0 ? 1 : -1;
- }
- #endregion
- #region ACTION JUMP
- foreach (var entity in groupActionJump)
- {
- var cJump = entity.ComponentActionJump();
- var cMotion = entity.ComponentMotion();
- var cAnimation = entity.ComponentAnimation();
- var cPlayer = entity.ComponentPlayer();
- var cObj = entity.ComponentObject();
- if (cPlayer.source.GetButton(DataInputActions.Default.Jump))
- {
- cMotion.velocity.y += cJump.force.y;
- cAnimation.Set(Anim.Jump, 0);
- SetCollider(entity, false);
- var composer = new EntityComposer(entity, 1);
- var ceInAir = composer.Add<ComponentInAir>();
- ceInAir.gravity = cJump.gravity;
- ceInAir.landingSpot = cObj.transform.position.y;
- ceInAir.actionOnFinish = ChangeAnimationToNormal;
- composer.Deploy(Tag.Jump);
- Timer.Add(delta, () => ceInAir.allowLanding = true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement