예제 #1
0
        private async void PlayShakeAnimation(DicePair pair)
        {
            this.Visibility = Windows.UI.Xaml.Visibility.Visible;

            sbyte[] randomArray = new sbyte[20];
            randomArray[0] = (sbyte)((Windows.Security.Cryptography.CryptographicBuffer.GenerateRandomNumber() % 6) + 1);
            for (int i = 1; i < 20; i++)
            {
                randomArray[i] = (sbyte)((Windows.Security.Cryptography.CryptographicBuffer.GenerateRandomNumber() % 6) + 1);
                if (randomArray[i] == randomArray[i - 1])
                    randomArray[i] = (sbyte)((randomArray[i - 1] + 3) % 6 + 1);
            }

            randomArray[9] = pair.dice1;
            randomArray[19] = pair.dice2;

            for (int i = 0; i < 9; i++)
            {
                this.Dice1.Source = diceImages[randomArray[i] - 1];
                this.Dice2.Source = diceImages[randomArray[i + 10] - 1];
                await System.Threading.Tasks.Task.Delay(90);
            }

            this.Dice1.Source = diceImages[randomArray[9] - 1];
            this.Dice2.Source = diceImages[randomArray[19] - 1];
            await System.Threading.Tasks.Task.Delay(500);

            this.AnimationCompleted(pair);
            this.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }
예제 #2
0
        public DicePair Play()
        {
            var result = new DicePair()
            {
                dice1 = (sbyte)((Windows.Security.Cryptography.CryptographicBuffer.GenerateRandomNumber() % 6) + 1),
                dice2 = (sbyte)((Windows.Security.Cryptography.CryptographicBuffer.GenerateRandomNumber() % 6) + 1)
            };

            this.PlayShakeAnimation(result);

            return result;
        }
예제 #3
0
 public DiceAnimationCompletingEvent(DicePair pair)
 {
     this.diceresult = pair;
 }
예제 #4
0
 void ShowDiceResultOnPlayerCardWhenAnimationCompleted(DicePair result)
 {
     if(Common.Game.MovingPlayer.Equals(this.CurrentGame.CurrentPlayer))
     {
         this.PlayerDiceResultImage1.Source = Dice.diceImages[result.dice1 - 1];
         this.PlayerDiceResultImage2.Source = Dice.diceImages[result.dice2 - 1];
     }
     else
     {
         this.CompetitorDiceResultImage1.Source = Dice.diceImages[result.dice1 - 1];
         this.CompetitorDiceResultImage2.Source = Dice.diceImages[result.dice2 - 1];
     }
 }
예제 #5
0
        /// <summary>
        /// Zar atıldıktan sonra yapılacak işlemler
        /// </summary>
        /// <param name="result"></param>
        void AfterDice(DicePair dice)
        {
            System.Diagnostics.Debug.WriteLine(this.playerName + " tarafından zar atıldı : (" + dice.dice1 + ", " + dice.dice2 + ")");

            this.lastDices.Clear();
            if (dice.dice1 != dice.dice2)
            {
                this.lastDices.Add(dice.dice1);
                this.lastDices.Add(dice.dice2);
            }
            else
            {
                this.lastDices.Add(dice.dice1);
                this.lastDices.Add(dice.dice2);
                this.lastDices.Add(dice.dice1);
                this.lastDices.Add(dice.dice2);
            }

            Pages.GamePage.Dice_.AnimationCompleted -= this.AfterDice;
        }