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; }
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; }
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; }
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"); } }
private void ApplyLevel(Hand hand, GameTime gameTime) { for (int i = 0, CurrentGameLevelCount = Levels.Count; i < CurrentGameLevelCount; i++) Levels [i].ApplyLevel (this, hand, gameTime); }
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); }
private void ReleaseHand(Hand hand) { Hands.Add (hand); }
private void RemoveIfNotValid(Hand hand) { if (!hand.IsScheduledToDraw) Hands.Remove (hand); }
public static bool IsDummy(Hand hand) { return hand.Type == HandType.None; }