コード例 #1
0
ファイル: MainLayer.cs プロジェクト: LckDck/TestGame
        bool MoveGem(GemSprite gem)
        {
            if (gem == null)
            {
                return(false);
            }
            var col = gem.Col;
            var row = gem.Row;

            // Check if gem place corresponds its cell place
            // if not - it should move
            if (gem.Cell.Col != gem.Col || gem.Cell.Row != gem.Row)
            {
                var newPlace = places[gem.Cell.Col, gem.Cell.Row];
                var target   = new CCPoint(newPlace.PositionX, newPlace.PositionY);

                gem.Col = gem.Cell.Col;
                gem.Row = gem.Cell.Row;

                var moveAction = new CCMoveTo(CellAnimationDuration, target);
                var ease       = new CCEaseIn(moveAction, 4);

                gem.AddAction(ease);
                return(true);
            }
            return(false);
        }
コード例 #2
0
ファイル: GameLayer.cs プロジェクト: kappajbeta/Bloons
        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));
        }
コード例 #3
0
ファイル: MainLayer.cs プロジェクト: LckDck/TestGame
        void OnActivatedBonus(object sender, Tuple <int, int> cell)
        {
            var gem       = gems.Find(item => item.Col == cell.Item1 && item.Row == cell.Item2);
            var actionIn  = new CCEaseIn(new CCScaleTo(0.3f, 1.1f), 4);
            var actionOut = new CCEaseOut(new CCScaleTo(0.3f, 1f), 4);

            var sequence     = new CCSequence(actionIn, actionOut);
            var repeatAction = new CCRepeat(sequence, 10000);

            gem.AddAction(repeatAction);
        }
コード例 #4
0
ファイル: GameLayer.cs プロジェクト: kappajbeta/Bloons
        void ResetStopwatch()
        {
            if (((CCLabel)stopwatchSprite.GetChildByTag(1)).Text != "00:00:00")
            {
                CCEaseIn   shakeIn;
                CCEaseOut  shakeOut;
                CCEaseIn   shakeBackIn;
                CCEaseOut  shakeBackOut;
                CCCallFunc resetFunction;
                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)stopwatchSprite.GetChildByTag(1)).Text = "00:00:00");
                shakeBackIn    = new CCEaseIn(new CCMoveBy(0.1f, new CCPoint(30, 0)), 1f);
                shakeBackOut   = new CCEaseOut(new CCMoveBy(0.1f, new CCPoint(-15, 0)), 1f);
                motionSequence = new CCSequence(shakeIn, shakeOut, resetFunction, shakeBackIn, shakeBackOut);

                stopwatchSprite.RunAction(motionSequence);
            }
        }
コード例 #5
0
ファイル: EaseActionsTest.cs プロジェクト: zhuruvl/CocosSharp
        public override void OnEnter()
        {
            base.OnEnter();

            var size = Layer.VisibleBoundsWorldspace.Size;

            var move      = new CCMoveBy(3, new CCPoint(size.Width - 130, 0));
            var move_back = (CCFiniteTimeAction)move.Reverse();

            var move_ease_in      = new CCEaseIn(move, 2.5f);
            var move_ease_in_back = move_ease_in.Reverse();

            var move_ease_out      = new CCEaseOut(move, 2.5f);
            var move_ease_out_back = move_ease_out.Reverse();

            var delay = new CCDelayTime(0.25f);

            var seq1 = new CCSequence(move, delay, move_back, delay)
            {
                Tag = 1
            };
            var seq2 = new CCSequence(move_ease_in, delay, move_ease_in_back, delay)
            {
                Tag = 1
            };
            var seq3 = new CCSequence(move_ease_out, delay, move_ease_out_back, delay)
            {
                Tag = 1
            };

            m_grossini.RepeatForever(seq1);

            m_tamara.RepeatForever(seq2);

            m_kathia.RepeatForever(seq3);

            Schedule(testStopAction, 6.25f);
        }
コード例 #6
0
        public override void OnEnter()
        {
            base.OnEnter();

            var size = CCDirector.SharedDirector.WinSize;

            var move      = new CCMoveBy(3, new CCPoint(size.Width - 130, 0));
            var move_back = (CCActionInterval)move.Reverse();

            var move_ease_in      = new CCEaseIn((CCActionInterval)move.Copy(), 2.5f);
            var move_ease_in_back = move_ease_in.Reverse();

            var move_ease_out      = new CCEaseOut((CCActionInterval)move.Copy(), 2.5f);
            var move_ease_out_back = move_ease_out.Reverse();

            var delay = new CCDelayTime(0.25f);

            var seq1 = CCSequence.FromActions(move, delay, move_back, (CCFiniteTimeAction)delay.Copy());
            var seq2 = CCSequence.FromActions(move_ease_in, (CCFiniteTimeAction)delay.Copy(), move_ease_in_back, (CCFiniteTimeAction)delay.Copy());
            var seq3 = CCSequence.FromActions(move_ease_out, (CCFiniteTimeAction)delay.Copy(), move_ease_out_back,
                                              (CCFiniteTimeAction)delay.Copy());

            var a2 = m_grossini.RunAction(new CCRepeatForever((CCActionInterval)seq1));

            a2.Tag = 1;

            var a1 = m_tamara.RunAction(new CCRepeatForever((CCActionInterval)seq2));

            a1.Tag = 1;

            var a = m_kathia.RunAction(new CCRepeatForever((CCActionInterval)seq3));

            a.Tag = 1;

            Schedule(testStopAction, 6.25f);
        }