Exemple #1
0
        public void Turn()
        {
            Console.WriteLine("It's {0} player's turn", Index);
            PlayerDice.ForEach(x => x.Roll());
            string input;

            for (int counter = 0; counter < TIMES_TO_REROLL && !EndOfThrowing; counter++)
            {
                Console.Write("Your roll: ");
                PlayerDice.ForEach(x => Console.Write(x.Num + " "));
                Console.WriteLine("\nPlease write the index(es) of dice to reroll. If your do not wish to reroll, type 0.");
                input = Console.ReadLine();
                while (!ParseInputReroll(input))
                {
                    input = Console.ReadLine();
                }
                Reroll();
            }
            Console.Write("Your last roll was: ");
            PlayerDice.ForEach(x => Console.Write(x.Num + " "));
            Console.WriteLine("\nPlease choose in which category you wish to score. Write FIVES, CHANCE or ONE_PAIR");
            input = Console.ReadLine();
            while (!ParseInputScoring(input))
            {
                input = Console.ReadLine();
            }
            Console.Write("\n");

            PrintPlayerTable();

            EndOfThrowing = false;
            Console.Write("\n");
        }
Exemple #2
0
 public void ThrowDiceAndMovePlayer()
 {
     CurrentPlayer.DiceEyes   = PlayerDice.ThrowDice();
     PlayerDice.HasBeenThrown = true;
     GameInfo.Enqueue(String.Format(Properties.Language.throwdice, CurrentPlayer.Name, PlayerDice.FirstDice, PlayerDice.SecondDice));
     CurrentPlayer.MoveTo(CurrentPlayer.DiceEyes);
 }
Exemple #3
0
        public bool ParseInputReroll(string line)
        {
            if (line == null)
            {
                throw new NullReferenceException();
            }
            if (line.Trim().Equals("0"))
            {
                DiceToReroll.Clear();
                EndOfThrowing = true;
                return(true);
            }

            List <int> InputNumbers;

            try
            {
                InputNumbers = line.Split().Select(int.Parse).ToList();
            }
            catch (Exception)
            {
                Console.WriteLine("Invalid Input: Could not recognise numbers. Try again.");
                return(false);
            }

            if ((InputNumbers.Count() > NUM_OF_DICE || InputNumbers.Count() < 1) || InputNumbers.Any(x => x > NUM_OF_DICE || x < 1))
            {
                Console.WriteLine("Invalid input: Too many entered numbers or they are out of range. Try again.");
                return(false);
            }

            DiceToReroll = PlayerDice.Where(x => InputNumbers.Contains(x.IndexOfDice)).ToList();
            return(true);
        }
Exemple #4
0
        void FixedUpdate()
        {
            if (isRotateDice)
            {
                try
                {
                    int month = Random.Range(1, ImageController.getInstance.DiceRotation.Length);

                    // PlayerDice.GetComponent<Image>().sprite = Resources.Load<Sprite>("Dices/d-" + month);
                    PlayerDice.GetComponent <Image>().sprite = ImageController.getInstance.DiceRotation[month - 1];
                    PlayerDice.transform.localScale          = new Vector3(1.5f, 1.5f, 1.5f);
                }
                catch (System.Exception ex)
                {
                    // Debug.Log ("FixedUpdate Exception "+ex.Message);
                }

                /*
                 * int index = (Time.deltaTime) % frame.Length;
                 * GameObject g  = frame[index];
                 * GameObject newCell = Instantiate (g);
                 * newCell.transform.SetParent (Container.transform);
                 * newCell.transform.localScale = new Vector3 (1, 1, 1);
                 *
                 * newCell.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("images/dice_" + month);
                 */
            }
        }
Exemple #5
0
        //	public void showPlayerProfile(){
        //		// Debug.Log ("showPlayerProfile working");
        //		ProfilePanel.SetActive (true);
        //
        //	}

        IEnumerator stopRotation(int value, JSONNode TurnValue)
        {
            yield return(new WaitForSeconds(0.5f));

            isRotateDice = false;
            try
            {
                PlayerDice.GetComponent <Image>().sprite = ImageController.getInstance.Dice[value - 1];
                //PlayerDice.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Dices/dice_" + value);
                PlayerDice.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                PlayerDice.transform.rotation   = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f);
            }
            catch (System.Exception ex)
            {
                // Debug.Log ("stopRotation Exception "+ex.Message);
            }
            base.resetDices();
            // Debug.Log("Opponent "+TurnValue.ToString());
            for (int i = 0; i < TurnValue.Count; i++)
            {
                try
                {
                    diceSample[i].SetActive(true);
                    diceSample[i].GetComponent <DiceSample>().index = int.Parse(TurnValue[i]);
                    diceSample[i].GetComponent <Image>().sprite     = ImageController.getInstance.Dice[int.Parse(TurnValue[i]) - 1];
                }
                catch (System.Exception ex)
                {
                    // Debug.Log(ex.Message);
                }
            }

            //print (" " + base.dicNumber + " Occured");
        }
Exemple #6
0
 public void EndTurn()
 {
     if (!PlayerDice.IsDouble())
     {
         NextTurn();
     }
     PlayerDice.HasBeenThrown = false;
 }
        void FixedUpdate()
        {
            if (isRotateDice)
            {
                int month = Random.Range(1, ImageController.getInstance.DiceRotation.Length);

                // PlayerDice.GetComponent<Image>().sprite = Resources.Load<Sprite>("Dices/d-" + month);
                PlayerDice.GetComponent <Image>().sprite = ImageController.getInstance.DiceRotation[month - 1];
                PlayerDice.transform.localScale          = new Vector3(1.5f, 1.5f, 1.5f);
            }
        }
        IEnumerator stopRotation()
        {
            yield return(new WaitForSeconds(0.5f));

            isRotateDice = false;
            try
            {
                PlayerDice.GetComponent <Image>().sprite = ImageController.getInstance.Dice[base.dicNumber - 1];
                //PlayerDice.GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Dices/dice_" + base.dicNumber);
                PlayerDice.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                PlayerDice.transform.rotation   = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f);
            }
            catch (System.Exception ex)
            {
                // Debug.Log (ex.Message);
            }

            //print (" " + base.dicNumber + " Occured");
            appwarp.sendTapDone(base.dicNumber);
        }