Example #1
0
        void AddBalloon()
        {
            string   previousBestTime = GetDefault(PREVIOUS_BEST_TIME_KEY);
            string   currentTime      = ((CCLabel)stopwatchSprite.GetChildByTag(1)).Text;
            TimeSpan currentTimeSpan  = new TimeSpan(int.Parse(currentTime.Split(':')[0]), int.Parse(currentTime.Split(':')[1]), int.Parse(currentTime.Split(':')[2]));

            previousTimeSpan = (String.IsNullOrWhiteSpace(previousBestTime) ? new TimeSpan(0, 0, 0) : new TimeSpan(int.Parse(previousBestTime.Split(':')[0]),
                                                                                                                   int.Parse(previousBestTime.Split(':')[1]),
                                                                                                                   int.Parse(previousBestTime.Split(':')[2])));

            GetRandomBalloonColor();

            balloonSprite           = new CCSprite("Balloon:" + balloonColor);
            balloonSprite.Name      = "Balloon:" + balloonColor;
            balloonSprite.PositionX = layerWidth / 2 + 3;
            balloonSprite.PositionY = 0;
            balloonSprite.Opacity   = 200;

            balloonMoved        = false;
            balloonLaunched     = false;
            balloonXVelocity    = 0;
            balloonYVelocity    = 0;
            newBalloonYVelocity = 0;
            lastPlayTime        = DateTime.Now;

            if ((currentTimeSpan.TotalSeconds - previousTimeSpan.TotalSeconds) > 0)
            {
                CCEaseIn   shakeIn;
                CCEaseOut  shakeOut;
                CCEaseIn   shakeBackIn;
                CCEaseOut  shakeBackOut;
                CCCallFunc resetFunction;
                CCCallFunc bestTimeAlertFunction;
                CCSequence motionSequence;

                shakeIn               = new CCEaseIn(new CCMoveBy(0.05f, new CCPoint(15, 0)), 1f);
                shakeOut              = new CCEaseOut(new CCMoveBy(0.05f, new CCPoint(-30, 0)), 1f);
                resetFunction         = new CCCallFunc(() => ((CCLabel)previousBestTimeSprite.GetChildByTag(1)).Text = currentTime);
                shakeBackIn           = new CCEaseIn(new CCMoveBy(0.1f, new CCPoint(30, 0)), 1f);
                shakeBackOut          = new CCEaseOut(new CCMoveBy(0.1f, new CCPoint(-15, 0)), 1f);
                bestTimeAlertFunction = new CCCallFunc(() => ShowBestTimeAlert());
                motionSequence        = new CCSequence(shakeIn, shakeOut, resetFunction, shakeBackIn, shakeBackOut, bestTimeAlertFunction);
                previousTimeSpan      = currentTimeSpan;

                previousBestTimeSprite.RunAction(motionSequence);
                SetDefault(((CCLabel)stopwatchSprite.GetChildByTag(1)).Text, PREVIOUS_BEST_TIME_KEY);
            }
            else
            {
                ControlMenu("Show");
            }

            AddChild(balloonSprite);
            balloonSprite.RunActions(new CCScaleTo(0.10f, 1.5f), new CCScaleTo(0.10f, 1f));
        }
        public static string SpriteHasLabel(CCSprite sprite)
        {
            var contentTag = sprite.GetChildByTag(SpriteTypes.ContentTag) as CCLabel;

            if (contentTag != null)
            {
                return(contentTag.Text);
            }
            else
            {
                return("");
            }
        }
Example #3
0
        void TouchesBegan(List <CCTouch> touches, CCEvent touchEvent)
        {
            // base.TouchesBegan(touches, touchEvent);

            if (!_running)
            {
                //if intro, hide intro message
                if (_introMessage.Visible)
                {
                    _introMessage.Visible = false;

                    //if game over, hide game over message
                }
                else if (_gameOverMessage.Visible)
                {
                    CCSimpleAudioEngine.SharedEngine.StopAllEffects();
                    _gameOverMessage.Visible = false;
                }

                resetGame();
                return;
            }

            CCTouch touch = touches.FirstOrDefault();

            if (touch != null)
            {
                //if bomb already growing...
                if (_bomb.Visible)
                {
                    //stop all actions on bomb, halo and sparkle
                    _bomb.StopAllActions();
                    CCSprite child;
                    child = (CCSprite)_bomb.GetChildByTag(kSpriteHalo);
                    ProcessSprite(child);
                    //child.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
                    child.StopAllActions();
                    child = (CCSprite)_bomb.GetChildByTag(kSpriteSparkle);
                    ProcessSprite(child);
                    //child.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
                    child.StopAllActions();

                    //if bomb is the right size, then create shockwave
                    if (_bomb.ScaleX > 0.3f)
                    {
                        _shockWave.Scale    = 0.1f;
                        _shockWave.Position = _bomb.Position;
                        _shockWave.Visible  = true;
                        _shockWave.RunAction(new CCScaleTo(0.5f, _bomb.ScaleX * 2.0f));
                        _shockWave.RunAction((CCFiniteTimeAction)_shockwaveSequence);
                        CCSimpleAudioEngine.SharedEngine.PlayEffect("music/bombRelease");
                    }
                    else
                    {
                        CCSimpleAudioEngine.SharedEngine.PlayEffect("music/bombFail");
                    }
                    _bomb.Visible = false;
                    //reset hits with shockwave, so we can count combo hits
                    _shockwaveHits = 0;

                    //if no bomb currently on screen, create one
                }
                else
                {
                    CCPoint tap = touch.LocationOnScreen;;;                       //??¿¿?¿?
                    tap.Y = Window.WindowSizeInPixels.Height - tap.Y;

                    _bomb.StopAllActions();
                    _bomb.Scale    = 0.1f;
                    _bomb.Position = tap;
                    _bomb.Visible  = true;
                    _bomb.Opacity  = 50;
                    _bomb.RunAction(_growBomb);

                    CCSprite child;
                    child = (CCSprite)_bomb.GetChildByTag(kSpriteHalo);
                    ProcessSprite(child);
                    //child.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
                    child.RunAction(_rotateSprite);
                    child = (CCSprite)_bomb.GetChildByTag(kSpriteSparkle);
                    ProcessSprite(child);
                    //child.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
                    child.RunAction(_rotateSprite);
                }
            }
        }