Exemplo n.º 1
0
 internal void HandleInput(TouchCollection touchCollection)
 {
     bool touchReleased = false;
     foreach (TouchLocation touch in touchCollection)
     {
         if (touch.State == TouchLocationState.Released)
         {
             touchReleased = true;
         }
     }
     if (touchReleased && playerState == PlayerState.Climbing)
     {
         playerState = PlayerState.Jumping;
         collider = jumpCollider;
         collider.MoveToPoint(position);
         if(CurrentAnimation != jumpAnimation)
             CurrentAnimation = jumpAnimation;
         headingDirection = (Direction)((int)headingDirection * -1);
         FitAnimationDirection();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Add an new collider to the multi collider important the new collider has to be placed relativ to 0,0 the multi collider will do the positionning
 /// himself
 /// </summary>
 /// <param name="col">Collider to add</param>
 public void AddCollider(Collider col)
 {
     col.MoveToPoint(CalculateCurrentColPos(col));
     Colliders.Add(col);
 }
Exemplo n.º 3
0
        public override void Update(GameTime gameTime)
        {
            if (playerState != PlayerState.Dying && playerState != PlayerState.Dead)
            {
                playerScore += 1;
                if (isImmortal)
                {
                    immortalTime += gameTime.ElapsedGameTime.Milliseconds;
                    if (immortalTime > 2000)
                        isImmortal = false;
                }
            }
            if (playerState == PlayerState.Jumping)
            {
                position.X += (int)headingDirection * (10 + GameManager.Instance.GameSpeed);
                position.Y = position.X > gameYCenter ? position.Y + (1 * ((position.X - gameYCenter) / monkeyJumpGravity) * (int)headingDirection) : position.Y - (1 * ((gameYCenter - position.X) / monkeyJumpGravity) * (int)headingDirection);
                collider.MoveToPoint(position);

                if (position.X < gameBounds.X || position.X > gameBounds.Right)
                {
                    position.X = position.X < gameBounds.X ? gameBounds.X : gameBounds.Right;
                    position.Y = monkeyYLevel;
                    collider = climbCollider;
                    collider.MoveToPoint(position);
                    playerState = PlayerState.Climbing;
                    CurrentAnimation = climbAnimation;
                }
            }
            else if (playerState == PlayerState.Dying)
            {
                position.Y += gameTime.ElapsedGameTime.Milliseconds / 10 * GameManager.Instance.GameSpeed * 2f;
                collider.MoveToPoint(position);
                CurrentAnimation.Rotation += 0.9f;

                if (position.Y > gameBounds.Bottom)
                {
                    playerState = PlayerState.Dead;
                }
            }

            base.Update(gameTime);
        }