Advertisement
dimmpixeye

Processing Player

Dec 8th, 2018
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1. public void Tick()
  2.         {
  3.             var delta = Time.delta;
  4.  
  5.             #region ACTION MOVE
  6.  
  7.             foreach (var entity in groupActionMove)
  8.             {
  9.                 var cMotion     = entity.ComponentMotion();
  10.                 var cActionMove = entity.ComponentActionMove();
  11.                 var cPlayer     = entity.ComponentPlayer();
  12.  
  13.                 float x = cPlayer.source.GetAxisRaw(DataInputActions.Default.Horizontal);
  14.                 float y = cPlayer.source.GetAxisRaw(DataInputActions.Default.Vertical);
  15.  
  16.  
  17.                 cMotion.direction.x = Math.Abs(x) > 0.65f ? x : 0;
  18.                 cMotion.direction.y = Math.Abs(y) > 0.65f ? y : 0;
  19.  
  20.  
  21.                 cMotion.speed = cActionMove.speed;
  22.             }
  23.  
  24.             foreach (var entity in groupActionTurn)
  25.             {
  26.                 var   cView   = entity.ComponentView();
  27.                 var   cPlayer = entity.ComponentPlayer();
  28.                 float x       = cPlayer.source.GetAxisRaw(DataInputActions.Default.Horizontal);
  29.  
  30.                 if (x != 0)
  31.                     cView.facing = x > 0 ? 1 : -1;
  32.             }
  33.  
  34.             #endregion
  35.  
  36.             #region ACTION JUMP
  37.  
  38.             foreach (var entity in groupActionJump)
  39.             {
  40.                 var cJump      = entity.ComponentActionJump();
  41.                 var cMotion    = entity.ComponentMotion();
  42.                 var cAnimation = entity.ComponentAnimation();
  43.                 var cPlayer    = entity.ComponentPlayer();
  44.                 var cObj       = entity.ComponentObject();
  45.  
  46.                 if (cPlayer.source.GetButton(DataInputActions.Default.Jump))
  47.                 {
  48.                     cMotion.velocity.y += cJump.force.y;
  49.                     cAnimation.Set(Anim.Jump, 0);
  50.                     SetCollider(entity, false);
  51.  
  52.                     var composer = new EntityComposer(entity, 1);
  53.  
  54.                     var ceInAir = composer.Add<ComponentInAir>();
  55.                     ceInAir.gravity = cJump.gravity;
  56.                     ceInAir.landingSpot = cObj.transform.position.y;
  57.                     ceInAir.actionOnFinish = ChangeAnimationToNormal;
  58.  
  59.                     composer.Deploy(Tag.Jump);
  60.  
  61.                     Timer.Add(delta, () => ceInAir.allowLanding = true);
  62.                 }
  63.             }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement