Ejemplo n.º 1
0
        void BalloonClick(Balloon balloon)
        {
            try
            {
                _dinosaur.Hit();

                if (balloon.txtChar.Text != FontHandle.TranslateUnicodeCharToBKHCM2(_arrText[_indexArrText - 1][_currCharIndex].ToString())) // Wrong
                {
                    this._effectSound.Source = new Uri("/Sound/wrong.mp3", UriKind.Relative);
                    _timeBar.Decrease(_deltaTime * 3);
                }
                else
                {
                    balloon.Boom();

                    // Number
                    Number _number = new Number(false);
                    this.LayoutRoot.Children.Add(_number);
                    _number.SetValue(Canvas.LeftProperty, (double)balloon.GetValue(Canvas.LeftProperty));
                    _number.SetValue(Canvas.TopProperty, (double)balloon.GetValue(Canvas.TopProperty) + 50);
                    _number.SetValue(Canvas.ZIndexProperty, 10);
                    _number.Data = "50";

                    int score = int.Parse(_score.Data) + 50;
                    _score.Data = String.Format("{0:00000}", score);

                    _currCharIndex++;
                }
            }
            catch { }
        }
Ejemplo n.º 2
0
        void BalloonClickCompleted(Balloon balloon)
        {
            if (this.canvasBalloons.Children.Count == 0)
            {
                this._effectSound.Source = new Uri("/Sound/win1.mp3", UriKind.Relative);
                
                // Stop game
                this.LayoutRoot.MouseMove -= GamePage_MouseMove;
                _timer.Stop();

                _timeBar.Increase(_deltaTime * 3);

                // Timer stop   
                _timerStop = new DispatcherTimer();
                _timerStop.Interval = TimeSpan.FromMilliseconds(1000);
                _timerStop.Tick += new EventHandler(_timerStop_Tick);
                _timerStop.Start();
            }
        }
Ejemplo n.º 3
0
        void GenerateBalloon()
        {
            if (_indexArrText >= _arrText.Length)
                _indexArrText = 0;

            string text = _arrText[_indexArrText++];
            List<Point> suspendedRegion = new List<Point>();
            suspendedRegion.Add(new Point(0, 0));

            this.txtText.Text = FontHandle.TranslateUnicodeTextToBKHCM2(text);

            for (int i = 0; i < text.Length; i++)
            {
                string character = text[i].ToString();
                character = FontHandle.TranslateUnicodeCharToBKHCM2(character);

                Balloon balloon = new Balloon(character);
                balloon.dlgClick = new Balloon.DelegateClick(BalloonClick);
                balloon.dlgClickCompleted = new Balloon.DelegateClickCompleted(BalloonClickCompleted);

                // Get position
                Point position = GetPositionNotInSuspendedRegion(suspendedRegion, this.canvasBalloons, balloon.LayoutRoot.Width, balloon.LayoutRoot.Height);
                balloon.SetValue(Canvas.LeftProperty, position.X);
                balloon.SetValue(Canvas.TopProperty, position.Y);
                this.canvasBalloons.Children.Add(balloon);
                suspendedRegion.Add(position);
            }

            _currCharIndex = 0;
        }