public static Tuple <bool, bool> GetResult(this HandShapeTypes current, HandShapeTypes previous) { var won = false; var lose = false; switch (current) { case HandShapeTypes.Paper: won = previous == HandShapeTypes.Rock; lose = previous == HandShapeTypes.Scissors; break; case HandShapeTypes.Rock: won = previous == HandShapeTypes.Scissors; lose = previous == HandShapeTypes.Paper; break; case HandShapeTypes.Scissors: won = previous == HandShapeTypes.Paper; lose = previous == HandShapeTypes.Rock; break; default: break; } return(Tuple.Create(won, lose)); }
public void SetHandShape(HandTypes hand, HandShapeTypes shape) { if ((hand == HandTypes.Left && _leftShape == shape) || (hand == HandTypes.Right && _rightShape == shape)) { return; } if (hand == HandTypes.Left) { _leftShape = shape; _leftReleaseCount = 0; _leftReleaseRunning = (shape == HandShapeTypes.Default); } else { _rightShape = shape; _rightReleaseCount = 0; _rightReleaseRunning = (shape == HandShapeTypes.Default); } int offset = hand == HandTypes.Right ? 5 : 0; float[] angles = (shape == HandShapeTypes.Default) ? _defaultBendAngles : (shape == HandShapeTypes.Rock) ? _rockBendAngles : (shape == HandShapeTypes.Scissors) ? _scissorsBendAngles : _paperBendAngles; for (int i = 0; i < 5; i++) { _controller.Hold(i + offset, angles[i]); } }