public override void ApplyLevel(HandScreen screen, Hand hand, GameTime gameTime)
        {
            hand.Movement.HorizontalDirection = Direction.NONE;
            hand.Movement.VerticalDirection = Direction.DOWN;

            if (hand.CurrentAnimation.IsAnimating == true)
                hand.Movement.VerticalSpeed = 0;
            else
                hand.Movement.VerticalSpeed = speed;

            screen.NewHandReleaseInterval = releaseInterval;
        }
 private void AddToDictionaryIfNotAlready(Hand hand, GameTime gameTime)
 {
     var isKnownHand = lastChangedTimes.ContainsKey (hand);
     if (!isKnownHand)
         lastChangedTimes.Add (hand, gameTime.TotalGameTime);
 }
 public override void ApplyLevel(HandScreen screen, Hand hand, GameTime gameTime)
 {
     if (hand.CurrentAnimation.IsAnimating == false && hand.Origin.Y <= heightThreshold)
         UpdateHandType (hand, gameTime);
 }
 private void UpdateHandType(Hand hand, GameTime gameTime)
 {
     if (!hand.IsScheduledToDraw)
         lastChangedTimes.Remove (hand);
     else {
         AddToDictionaryIfNotAlready (hand, gameTime);
         RandomizeHandType (hand, gameTime);
     }
 }
 private void UpdateHandState(Hand hand)
 {
     var isInCollisionArea = IsInCollisionArea (hand.Rectangle);
     switch (hand.State) {
     case HandState.Active:
         if (isInCollisionArea)
             hand.State = HandState.Reactive;
         break;
     case HandState.Reactive:
         if (!isInCollisionArea)
             hand.State = HandState.Expired;
         break;
     default:
         break;
     }
 }
 private void StartHandAnimation(Hand hand, GameTime gameTime)
 {
     hand.StartAnimation (TimeSpan.FromSeconds (0.5), gameTime);
 }
 public abstract void ApplyLevel(HandScreen screen, Hand hand, GameTime gameTime);
		private MatchResult GetMatchResult (Hand tappedUserHand, GameTime gameTime)
		{
			return HandScreen.GetMatchResult (tappedUserHand, gameTime);
		}
 private bool IsInCollisionArea(Hand hand)
 {
     return hand.State == HandState.Reactive;
 }
Exemple #10
0
        private Timing GetTapTiming(Hand hand)
        {
            var handCenterLine = hand.Origin.Y + hand.Size.Y / 2f;
            var collisionAreaCenterLine = CollisionArea.Top + CollisionArea.Height / 2f;
            var delta = Math.Abs (collisionAreaCenterLine - handCenterLine);
            var threshold = CollisionArea.Height / 2f;

            if (delta <= threshold)
                return Timing.Great;
            else if (delta <= threshold * 2)
                return Timing.Good;
            else if (delta <= hand.Size.Y / 2f + CollisionArea.Height / 2f)
                return Timing.SoSo;
            else
                return Timing.None;
        }
Exemple #11
0
        private MatchResult GetMatchResult(Hand userHand, Hand hand)
        {
            if (userHand.Type == hand.Type)
                return new MatchResult (){ Result = ResultType.Draw };

            bool didUserWin = DidUserWin (userHand, hand);
            var matchResult = GetMatchResult (didUserWin);
            matchResult.TapTiming = GetTapTiming (hand);

            return matchResult;
        }
Exemple #12
0
 private bool DidUserWin(Hand userHand, Hand hand)
 {
     switch (userHand.Type) {
     case HandType.Rock:
     case HandType.RockPressed:
         return hand.Type == HandType.Scissors;
     case HandType.Paper:
     case HandType.PaperPressed:
         return  hand.Type == HandType.Rock;
     case HandType.Scissors:
     case HandType.ScissorsPressed:
         return  hand.Type == HandType.Paper;
     default:
         throw new InvalidOperationException ("Not Recognized Hand Type");
     }
 }
Exemple #13
0
 private void ApplyLevel(Hand hand, GameTime gameTime)
 {
     for (int i = 0, CurrentGameLevelCount = Levels.Count; i < CurrentGameLevelCount; i++)
         Levels [i].ApplyLevel (this, hand, gameTime);
 }
Exemple #14
0
        public MatchResult GetMatchResult(Hand tappedUserHandn, GameTime gameTime)
        {
            var bottomHand = Hands.FirstOrDefault (x => x.State == HandState.Reactive);

            if (bottomHand == null)
                return new MatchResult (){ Result = ResultType.WrongTiming };

            if (IsInCollisionArea (bottomHand)) {
                var matchResult = GetMatchResult (tappedUserHandn, bottomHand);
                if (matchResult.Result == ResultType.Victory)
                    StartHandAnimation (bottomHand, gameTime);

                bottomHand.State = HandState.Destroyed;
                bottomHand.Freeze ();
                return matchResult;
            } else {
                return new MatchResult (){ Result = ResultType.WrongTiming };
            }
        }
 private MatchResult GetMatchResult(Hand tappedUserHand)
 {
     return HandScreen.GetMatchResult (tappedUserHand);
 }
 private void RandomizeHandType(Hand hand, GameTime gameTime)
 {
     var hasEnoughTimeElapsed = gameTime.TotalGameTime.Subtract (lastChangedTimes [hand]) >= TimeSpan.FromMilliseconds (changeInterval.TotalMilliseconds / 2 + changeInterval.TotalMilliseconds * random.NextDouble ());
     if (hasEnoughTimeElapsed) {
         HandType = GetRandomHandType ();
         hand.Type = HandType;
         lastChangedTimes [hand] = gameTime.TotalGameTime;
     }
 }
		private bool IsUserHandTapped (Hand userHand)
		{
			return !Hand.IsDummy (userHand);
		}
Exemple #18
0
 private void ReleaseHand(Hand hand)
 {
     Hands.Add (hand);
 }
Exemple #19
0
 private void RemoveIfNotValid(Hand hand)
 {
     if (!hand.IsScheduledToDraw)
         Hands.Remove (hand);
 }
Exemple #20
0
 public static bool IsDummy(Hand hand)
 {
     return hand.Type == HandType.None;
 }