Example #1
0
        public string HintGetsCorrectly(int points, ThrowNumber number)

        {
            var hint = OneHundredAndEightyCore.Windows.Score.CheckOut.Get(points, number);

            return(hint);
        }
        public static string Get(int points, ThrowNumber throwNumber)
        {
            switch (throwNumber)
            {
            case ThrowNumber.FirstThrow:
                if (OneThrow.ContainsKey(points))
                {
                    return(OneThrow[points]);
                }

                if (TwoThrows.ContainsKey(points))
                {
                    return(TwoThrows[points]);
                }

                if (ThreeThrows.ContainsKey(points))
                {
                    return(ThreeThrows[points]);
                }

                break;

            case ThrowNumber.SecondThrow:
                if (OneThrow.ContainsKey(points))
                {
                    return(OneThrow[points]);
                }

                if (TwoThrows.ContainsKey(points))
                {
                    return(TwoThrows[points]);
                }

                break;

            case ThrowNumber.ThirdThrow:
                if (OneThrow.ContainsKey(points))
                {
                    return(OneThrow[points]);
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(null);
        }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        P1ScoreTxt.text = P1Score.ToString();
        //P2ScoreTxt.text = P2Score.ToString();

        if (current != last)
        {
            progressUnsmoothed += Time.deltaTime / transitionTime;
            if (progressUnsmoothed >= 1)
            {
                progressUnsmoothed = 0;
                last = current;
            }
            progress = smooth(progressUnsmoothed);
        }
        else if (current != mode)
        {
            current = mode;
        }
        updatePos();

        if (Input.GetMouseButtonDown(0))
        {
            if (mode == Mode.Main)
            {
                mode = Mode.MainMotion;
            }
            else if (mode == Mode.MainMotion && progress == 0)
            {
                RaycastHit hit;
                if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
                {
                    mode = Mode.Dart;
                    GameObject dart = (GameObject)Instantiate(dartPre, hit.point + new Vector3(0, 0, -25f), Quaternion.Euler(Vector3.zero));
                    dart.GetComponentInChildren <Animation>().Play("Throw");
                    currentDart = dart;
                    darts.Enqueue(dart);
                    Score score = decodeScore(hit.point);
                    if (P1Turn)
                    {
                        P1Score       += score.Points;
                        StatusTxt.text = "Player one";
                    }
                    ///else
                    {
                        //P2Score += score.Points;
                        //StatusTxt.text = "Player two";
                    }
                    StatusTxt.text += " scored <i>" + score.Points + "</i>.";

                    if (throwNumber == ThrowNumber.t5)
                    {
                        P1Turn = !P1Turn;
                        //StatusTxt.text += " Next player";
                        StatusTxt.text += " Play again";
                        P1Score         = 0;
                        P1Turn          = true;
                        throwNumber     = ThrowNumber.t1;
                    }
                    else
                    {
                        throwNumber++;
                    }
                }
            }
            else if (mode == Mode.Dart && progress == 0)
            {
                mode = Mode.Main;
                if (throwNumber == ThrowNumber.t1)
                {
                    while (darts.Count > 0)
                    {
                        GameObject d = darts.Dequeue();
                        d.GetComponentInChildren <Animation>().Play("Drop");;
                        Destroy(d, 1f);
                    }
                }
            }
        }
    }