Beispiel #1
0
 public void EndTrick()
 {
     if (State == TrickState.Started)
     {
         enabled       = false;
         _endRequested = true;
         State         = TrickState.Ending;
         TrickEnding?.Invoke(TrickAction);
         OnTrickEndRequested();
     }
 }
Beispiel #2
0
 private void PrintCurrentTrick(TrickState currentTrick)
 {
     if (!currentTrick.AnyPlayed)
     {
         Console.WriteLine("You're first to play a card.");
     }
     else
     {
         Console.WriteLine(string.Join("  ", currentTrick.Moves.Select(m => $"{m.Card} (P{m.Player + 1})")));
     }
 }
Beispiel #3
0
        public bool CanPlay(Card card, TrickState currentTrickState)
        {
            var currentSuit  = currentTrickState.Suit;
            var switchesSuit = currentSuit.HasValue && card.Suit != currentSuit;

            if (switchesSuit && MustFollow(currentSuit.Value))
            {
                return(false);
            }
            return(Has(card));
        }
Beispiel #4
0
        public bool StartTrick()
        {
            if (State != TrickState.Inactive)
            {
                return(false);
            }

            enabled = true;
            State   = TrickState.Started;
            OnTrickStart();
            TrickStarted?.Invoke(TrickAction);
            return(true);
        }
Beispiel #5
0
        public void Wenz()
        {
            players    = new PlayerState[4];
            players[0] = new PlayerState("P1", "");
            players[1] = new PlayerState("P2", "");
            players[2] = new PlayerState("P3", "");
            players[3] = new PlayerState("P4", "");

            trick = new TrickState(GameType.Wenz, Color.None, 0);
            trick.AddCard(new Card(Color.Herz, 8), players[0]);
            trick.AddCard(new Card(Color.Herz, 3), players[1]);
            trick.AddCard(new Card(Color.Gras, 3), players[2]);
            trick.AddCard(new Card(Color.Herz, 11), players[3]);

            Assert.Equal("P4", trick.Winner.Name);
        }
Beispiel #6
0
 void GetTrickInput()
 {
     if (Input.GetKeyDown(FTrickKey))
     {
         moveDirection = 0.0f;
         trickState    = TrickState.ForwardTrick;
         animator.SetTrigger("ForwardTrick");
         bDoingTrick = true;
         Invoke("ResetTrickState", TrickDuration);
     }
     else if (Input.GetKeyDown(BTrickKey))
     {
         moveDirection = 0.0f;
         trickState    = TrickState.BackTrick;
         animator.SetTrigger("BackTrick");
         bDoingTrick = true;
         Invoke("ResetTrickState", TrickDuration);
     }
     else if (Input.GetKeyDown(RTrickKey))
     {
         moveDirection = 0.0f;
         sr.flipX      = false;
         trickState    = TrickState.RightTrick;
         animator.SetTrigger("RightTrick");
         bDoingTrick = true;
         Invoke("ResetTrickState", TrickDuration);
     }
     else if (Input.GetKeyDown(LTrickKey))
     {
         moveDirection = 0.0f;
         sr.flipX      = true;
         trickState    = TrickState.LeftTrick;
         animator.SetTrigger("LeftTrick");
         bDoingTrick = true;
         Invoke("ResetTrickState", TrickDuration);
     }
 }
Beispiel #7
0
 void ResetTrickState()
 {
     trickState  = TrickState.Neutral;
     bDoingTrick = false;
 }
 public bool IsTrickInState(TrickAction trickAction, TrickState state)
 {
     return(Tricks[trickAction].State == state);
 }
Beispiel #9
0
 protected void Reset()
 {
     State         = TrickState.Inactive;
     _endRequested = false;
     TrickEnded?.Invoke(TrickAction);
 }
Beispiel #10
0
 public bool IsTrickInState(TrickAction trickAction, TrickState state)
 {
     return(LeftSaberTrickManager.IsTrickInState(trickAction, state) ||
            RightSaberTrickManager.IsTrickInState(trickAction, state));
 }