private BallStat CalcBallScore(int ballNbr, int position, List <Drawing> drawingsByPosition, int totalDrawings, DateTime nextPickDate, bool dailyDrawing)
        {
            var ballStat = new BallStat
            {
                Id       = ballNbr,
                Position = position
            };

            // date last hit
            var positionLastHit = drawingsByPosition.Select(d => d.DrawDate).Max();

            if (positionLastHit > ballStat.LastHit)
            {
                ballStat.LastHit = positionLastHit;
            }

            // how often does number come up
            var dueInDrawingsCount = totalDrawings / drawingsByPosition.Count;

            // set beginning score.  More often number comes up the better the score
            ballStat.Score = Convert.ToInt32(drawingsByPosition.Count / Convert.ToDouble(totalDrawings) * 100);

            // determine next due date
            var dueDraw = ballStat.LastHit;

            if (dailyDrawing)
            {
                for (int ii = 1; ii < dueInDrawingsCount; ii++)
                {
                    if (dueDraw.Hour == 19)
                    {
                        dueDraw = dueDraw.AddHours(17);
                    }
                    else
                    {
                        dueDraw = dueDraw.AddHours(7);
                    }
                }
                ballStat.Score += Convert.ToInt32((nextPickDate - dueDraw).TotalHours);
            }
            else
            {
                for (int ii = 1; ii < dueInDrawingsCount; ii++)
                {
                    if (dueDraw.DayOfWeek == DayOfWeek.Friday)
                    {
                        dueDraw = dueDraw.AddDays(4);
                    }
                    else
                    {
                        dueDraw = dueDraw.AddDays(3);
                    }
                }
                ballStat.Score += Convert.ToInt32((nextPickDate - dueDraw).TotalDays);
            }

            return(ballStat);
        }
예제 #2
0
    private void OnTriggerEnter(Collider other)
    {
        AudioManager.Instance.PlaySound(AudioManager.AudioName.Splash, 1);

        BallStat ballState = other.GetComponent <BallStat>();

        if (ballState == null)
        {
            return;
        }
        Color color = ballState.color;

        if (R > 0)
        {
            R -= color.r;
        }
        else
        {
            R += color.r;
        }

        if (G > 0)
        {
            G -= color.g;
        }
        else
        {
            G += color.g;
        }

        if (B > 0)
        {
            B -= color.b;
        }
        else
        {
            B += color.b;
        }
        GameObject.Destroy(other.gameObject);
    }