Beispiel #1
0
		public void RemoveBalloon( Balloon b )
		{
			for( int i=0; i<m_Balloons.Count; ++i )
			{
				if( m_Balloons[i] == b )
				{
					m_Balloons.RemoveAt( i );
					break;
				}
			}

			m_AppController.ReduceBalloons();

			if( m_Balloons.Count == 0 )
			{
				// notifications cleared, save values and return to main
				//PlayerPrefs.SetInt( "Balloons.BalloonsApp.m_BalloonCount", m_BalloonCount + 1 );

				/* // TODO submit this part as a bug report
				// Because RemoveBalloon is done during OnDestroy, when unloading the scene it crashes
				AppManager appManager = AppManager.GetSingleton();
				AppBehaviour activeApp = appManager.GetAppBehaviour( "Balloons" );

				if( activeApp != null )
					activeApp.Kill();
				*/

				m_AppController.GameCleared();
				Invoke( "ToKill", 0.5f );
			}
		}
Beispiel #2
0
        public void Select(Point location)
        {
            // Loop through each balloon in Arrayist to see which was selected
            foreach (Balloon balloon in _balloons)
            {
                if (balloon.Hit(location))
                {
                    // Reset active balloon color
                    if (_activeBalloon != null && _activeBalloon != balloon)
                        _activeBalloon.FillColor = _defaultColor;
                    _activeBalloon = balloon;
                    _activeBalloon.FillColor = _hitColor;

                    // Raise OnInfo event with custom arguments
                    OnInfo(_activeBalloon, new BalloonInfoArgs(_activeBalloon));
                    break;
                }
            }
        }
Beispiel #3
0
        private void RemoveBalloon(Balloon balloon)
        {
            // remove event delegate handler for Popped even for this balloon
            balloon.Popped -= this.PoppedEventHandler;

            _balloonDrawAnimate -= balloon.DrawAndAnimate;

            // Find balloon in ArrayList for removal and reset of active balloon
            int index = _balloons.IndexOf(balloon);
            if (index >= 0)
            {
                if (_balloons[index] == _activeBalloon) _activeBalloon = null;
                    _balloons.RemoveAt(index);

                // raise OnNoInfo event
                OnNoInfo(balloon, EventArgs.Empty);
            }
        }
Beispiel #4
0
        // Private methods
        private Balloon CreateBalloon()
        {
            // Randomly set growth and lift rates, and create a balloon
            int growthRate = _random.Next(10, 41);
            int liftRate = _random.Next(1, 6);
            Balloon balloon = new Balloon(new Point(_random.Next(_boardSize.Width - 20), _boardSize.Height),
                    new Size(20, 20), _defaultColor, growthRate, liftRate);

            // Add event handler to Popped event for each balloon
            balloon.Popped += new EventHandler(PoppedEventHandler);

            // Add balloon drawing and animation method to our delegate
            _balloonDrawAnimate += balloon.DrawAndAnimate;

            return balloon;
        }