Пример #1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="friends">周边相同的猫的集合</param>
    internal void RemoveCat(List <GameObject> friends)
    {
        // int score=Control.Instance.ScoreWithStartNumber(friends.Count);
        //GameLayer.Instance.AddScore(score);

        TouchLayer.isTouch = false;
        List <int> columnList = new List <int>();//存储被消掉的列

        foreach (GameObject item in friends)
        {
            catsList.Remove(item);
            Point key = item.GetComponent <Cat>().point;
            catsDic[key] = null;
            CatManager.Instance.RemoveCat(item);
            columnList.Add(key.X);
        }
        float maxTime = 0;

        foreach (int column in columnList)
        {
            float t = RepairRaw(column);//找到每一空余的列,调整行;
            if (maxTime < t)
            {
                maxTime = t;
            }
        }
        //要等到行的操作完成后,才进行列的操作
        this.transform.RunAction(CCSequence.Create(CCDelay.Create(maxTime), CCCallFunc.Create(RepairColumn)));
    }
Пример #2
0
        public void ChangeSquaresPosition(float timeForChanging, PositionInGame firstPosition, PositionInGame secondPosition, Action callback = null)
        {
            //var firstPosition = (PositionInGame)_random.Next(firstPositionInGame, lastPositionInGame);
            //var secondPosition = (PositionInGame)_random.Next(firstPositionInGame, lastPositionInGame);
            //while (firstPosition == secondPosition)
            //    secondPosition = (PositionInGame)_random.Next(firstPositionInGame, lastPositionInGame);


            var firstSquarePosition  = _cordinatesGenerator.PositionAndSquare[firstPosition];
            var secondSquarePosition = _cordinatesGenerator.PositionAndSquare[secondPosition];

            var firstSquare  = firstSquarePosition;
            var secondSquare = secondSquarePosition;

            _cordinatesGenerator.PositionAndSquare[firstPosition]  = secondSquare;
            _cordinatesGenerator.PositionAndSquare[secondPosition] = firstSquare;


            var moveToFirstPosition  = new CCMoveTo(timeForChanging, new CCPoint(firstSquare.Position.X, firstSquare.Position.Y));
            var moveToSecondPosition = new CCMoveTo(timeForChanging, new CCPoint(secondSquare.Position.X, secondSquare.Position.Y));

            secondSquare.RunAction(moveToFirstPosition);

            if (callback != null)
            {
                var        moveCompletedAction = new CCCallFunc(callback);
                CCSequence mySequence          = new CCSequence(moveToSecondPosition, moveCompletedAction);

                firstSquare.RunAction(mySequence);
            }
            else
            {
                firstSquare.RunAction(moveToSecondPosition);
            }
        }
Пример #3
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(0);

            var spr = new CCSprite("Images/grossini");

            spr.Position = new CCPoint(200, 200);
            AddChild(spr);

            var act1 = new CCMoveBy(2, new CCPoint(0, 100));

            var act2 = new CCCallFunc(log1);
            var act3 = new CCMoveBy(2, new CCPoint(0, -100));
            var act4 = new CCCallFunc(log2);
            var act5 = new CCMoveBy(2, new CCPoint(100, -100));
            var act6 = new CCCallFunc(log3);
            var act7 = new CCMoveBy(2, new CCPoint(-100, 0));
            var act8 = new CCCallFunc(log4);

            var actF = CCSequence.FromActions(act1, act2, act3, act4, act5, act6, act7, act8);

            CCDirector.SharedDirector.ActionManager.AddAction(actF, spr, false);
        }
Пример #4
0
        public void Hide()
        {
            //指定移动到最左边并超出屏幕
            CCMoveTo move = CCMoveTo.actionWithDuration(0.5f, new CCPoint(-CCDirector.sharedDirector().getWinSize().width, 0));

            //执行一个队列行为,当移动完成后就会调用HideAniCompled
            this.runAction(CCSequence.actionOneTwo(move, CCCallFunc.actionWithTarget(this, HideAniCompled)));
        }
        public void disableMenuCallback(object pSender)
        {
            m_pMenu1.Enabled = false;
            CCDelayTime wait   = new CCDelayTime(5);
            CCCallFunc  enable = new CCCallFunc(enableMenuCallback);

            CCFiniteTimeAction seq = new CCSequence(wait, enable);

            m_pMenu1.RunAction(seq);
        }
Пример #6
0
        void StartPipes()
        {
            var create = new CCCallFunc(CreatePipesAndCoins);

            var wait           = new CCDelayTime(3);
            var sequence       = new CCSequence(create, wait);
            var repeartForever = new CCRepeatForever(sequence);

            this.RunAction(repeartForever);
        }
        public void disableMenuCallback(object pSender)
        {
            menu1.Enabled = false;
            var wait   = new CCDelayTime(5);
            var enable = new CCCallFunc(enableMenuCallback);

            var seq = new CCSequence(wait, enable);

            menu1.RunAction(seq);
        }
Пример #8
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));
        }
 private protected void StopSwiping(List <CCTouch> touches, CCEvent touchEvent)
 {
     if (TouchCount == 0)
     {
         if (SwipingUpDown)
         {
             touchEvent.StopPropogation();
             // since the event is stopped here the WreckCarousel has to be informed manually
             WreckageLayer.WreckCarousel.Pressed = false;
             const float actionRate = 2f;
             const float actionTime = 0.25f;
             CCAction    action;
             var         reenableCarousel = new CCCallFunc(() => { if (WreckageLayer.State == WreckageLayer.WreckageState.CAROUSEL)
                                                                   {
                                                                       WreckageLayer.WreckCarousel.Pressable = true;
                                                                   }
                                                           });
             var bounds = WreckageLayer.VisibleBoundsWorldspace;
             // release the wreck
             var wreck = WreckageLayer.MiddleAircraft;
             if (wreck.PositionWorldspace.Y > bounds.Center.Y + bounds.Size.Height * 0.25f)
             {
                 // salvage
                 WreckageLayer.WreckCarousel.Pressable = false;
                 action = new CCSequence(new CCEaseOut(new CCMoveTo(actionTime, WreckPositionOriginal + new CCPoint(0, VisibleBoundsWorldspace.Size.Height)), actionRate),
                                         new CCCallFunc(WreckageLayer.Salvage) /*,
                                                                                * reenableCarousel*/);
             }
             else if (wreck.PositionWorldspace.Y < bounds.Center.Y - bounds.Size.Height * 0.25f &&
                      WreckageLayer.GetWreckPercentile(WreckageLayer.MiddleAircraft) < WreckageLayer.GetWreckMaxPercentile(WreckageLayer.MiddleAircraft))
             {
                 // repair
                 WreckageLayer.WreckCarousel.Pressable = false;
                 action = new CCSequence(new CCEaseOut(new CCMoveTo(actionTime, WreckPositionOriginal), actionRate),
                                         new CCCallFunc(WreckageLayer.StartRepair) /*,
                                                                                    * reenableCarousel*/);
             }
             else
             {
                 // reset
                 action = new CCSequence(new CCEaseOut(new CCMoveTo(actionTime, WreckPositionOriginal), actionRate),
                                         reenableCarousel);
             }
             action.Tag = ActionTag;
             wreck.AddAction(action);
         }
         // reset flags
         SwipeIsUndecided = true;
         SwipingUpDown    = false;
     }
 }
Пример #10
0
    public void RepairColumn()
    {
        int   num  = 0;
        float time = 0;

        for (int x = 0; x < 10; x++)
        {
            bool isNull = true;//当为true的时候说明整列都是空的
            for (int y = 0; y < 10; y++)
            {
                Point key = new Point(x, y);
                if (catsDic[key] != null)
                {
                    isNull = false;
                }
            }
            if (isNull)
            {
                num++;
            }
            if (!isNull)
            {
                if (num > 0)
                {
                    for (int y = 0; y < 10; y++)
                    {
                        Point      key = new Point(x, y);
                        int        dx  = key.X - num;
                        GameObject cat = catsDic[key];
                        catsDic[key] = null;
                        if (cat != null)
                        {
                            time = cat.GetComponent <Cat>().RunToX(new Point(dx, y));
                        }
                    }
                }
            }
        }
        var action = CCSequence.Create(CCDelay.Create(time), CCCallFunc.Create(() =>
        {
            if (IsGameOver())
            {
                //分数奖励
                JiangLiScore();
                StartCoroutine(IsPassGameLv());
            }
            TouchLayer.isTouch = true;
        }));

        this.transform.RunAction(action);
    }
Пример #11
0
        void MoveBoat(bool ignoreWindspeedChange)
        {
            if ((windSpeedChanged == true) ||
                (ignoreWindspeedChange == true))
            {
                CCRepeatForever boatMovingAnimation;
                CCSequence      boatMovingSequence;

                if (windSpeed > 0)
                {
                    float      targetPositionX = (windBlowingRight == true ? layerWidth + boatSprite.ContentSize.Width : -boatSprite.ContentSize.Width);
                    CCMoveTo   moveAcrossTo    = new CCMoveTo(windSpeed * 1.4f, new CCPoint(targetPositionX, boatSprite.PositionY));
                    CCCallFunc resetPositionX  = new CCCallFunc(() => boatSprite.PositionX = (windBlowingRight == true ? -boatSprite.ContentSize.Width :
                                                                                              layerWidth + boatSprite.ContentSize.Width));
                    CCEaseSineIn easeInAcrossTo = new CCEaseSineIn(moveAcrossTo);

                    previousWindSpeed   = windSpeed * 1.4f;
                    boatMovingSequence  = new CCSequence(resetPositionX, moveAcrossTo);
                    boatMovingAnimation = new CCRepeatForever(boatMovingSequence);

                    boatSprite.StopAllActions();
                    boatSprite.RunActions(easeInAcrossTo, boatMovingAnimation);
                }
                else if (previousWindSpeed > 0)
                {
                    float         targetPositionX = (windBlowingRight == true ? previousWindSpeed * 7 : previousWindSpeed * -7);
                    CCEaseSineOut easeOutBy       = new CCEaseSineOut(new CCMoveBy(previousWindSpeed * 1.2f, new CCPoint(targetPositionX, 0)));
                    CCEaseSineOut easeOutSlowerBy = new CCEaseSineOut(new CCMoveBy(previousWindSpeed * 1.4f, new CCPoint(targetPositionX, 0)));
                    CCEaseSineIn  easeInTo        = new CCEaseSineIn(new CCMoveTo(0.5f, new CCPoint(boatSprite.PositionX, oceanSprite.PositionY +
                                                                                                    boatSprite.ContentSize.Height / 2 - 3)));
                    CCCallFunc resetBoatPositionX = new CCCallFunc(() =>
                    {
                        if ((windBlowingRight == true) &&
                            (boatSprite.PositionX >= layerWidth + boatSprite.ContentSize.Width))
                        {
                            boatSprite.PositionX = -boatSprite.ContentSize.Width;
                        }
                        else if ((windBlowingRight == false) &&
                                 (boatSprite.PositionX <= -boatSprite.ContentSize.Width))
                        {
                            boatSprite.PositionX = layerWidth + boatSprite.ContentSize.Width;
                        }
                    });

                    boatMovingSequence = new CCSequence(easeOutBy, resetBoatPositionX, easeOutSlowerBy, easeInTo, boatAnimation);

                    boatSprite.StopAllActions();
                    boatSprite.RunAction(boatMovingSequence);
                }
            }
        }
Пример #12
0
        public override void onEnter()
        {
            base.onEnter();

            alignSpritesLeft(1);

            m_grossini.visible = false;

            CCFiniteTimeAction action = CCSequence.actions(
                CCPlace.actionWithPosition(new CCPoint(200, 200)),
                CCShow.action(),
                CCMoveBy.actionWithDuration(1, new CCPoint(100, 0)),
                CCCallFunc.actionWithTarget(this, new SEL_CallFunc(callback1)),
                CCCallFuncN.actionWithTarget(this, new SEL_CallFuncN(callback2)),
                CCCallFuncND.actionWithTarget(this, new SEL_CallFuncND(callback3), (object)0xbebabeba));

            m_grossini.runAction(action);
        }
Пример #13
0
        protected override void StartProgressLine()
        {
            if (_isTimerStarted)
            {
                return;
            }
            _isTimerStarted = true;

            StopProgressLine();

            var progressTo = new CCProgressTo(_gameTime, 100);

            var        moveCompletedAction = new CCCallFunc(GameFinished);
            CCSequence mySequence          = new CCSequence(progressTo, moveCompletedAction);

            _progressTimer.Percentage = .0f;
            _progressTimer.Repeat(1, mySequence);
        }
Пример #14
0
        void StartDestroyTimer()
        {
            if (DestroyTimerStarted)
            {
                return;
            }
            DestroyTimerStarted = true;

            var delayAction          = new CCDelayTime(CellAnimationDuration + 0.1f);
            var delayCompletedAction = new CCCallFunc(() =>
            {
                DestroyTimerStarted = false;
                ClearBackgroundColor();
                GameCore.DestroyMatches();
            });
            CCSequence sequence = new CCSequence(delayAction, delayCompletedAction);

            RunAction(sequence);
        }
Пример #15
0
        void StartDetonationTimer()
        {
            if (DetonationTimerStarted)
            {
                StopAction(0);
            }
            DetonationTimerStarted = true;

            var delayAction          = new CCDelayTime(DetonationDelay);
            var delayCompletedAction = new CCCallFunc(() =>
            {
                DetonationTimerStarted = false;
                GameCore.Detonate();
            });
            CCSequence sequence = new CCSequence(delayAction, delayCompletedAction);

            sequence.Tag = 0;
            RunAction(sequence);
        }
Пример #16
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCMoveBy           pMove     = new CCMoveBy(2, new CCPoint(200, 0));
            CCCallFunc         pCallback = new CCCallFunc(stopAction);
            CCFiniteTimeAction pSequence = (CCFiniteTimeAction) new CCSequence(pMove, pCallback);

            pSequence.Tag = (int)KTag.kTagSequence;

            CCSprite pChild = new CCSprite(s_pPathGrossini);

            pChild.Position = (new CCPoint(200, 200));

            AddChild(pChild, 1, kTagGrossini);
            pChild.RunAction(pSequence);
        }
Пример #17
0
        void StartCreationTimer()
        {
            if (FillTimerStarted)
            {
                return;
            }
            FillTimerStarted = true;

            var delayAction          = new CCDelayTime(CellAnimationDuration + 0.1f);
            var delayCompletedAction = new CCCallFunc(() =>
            {
                GameCore.FillEmpltyPlaces();
                FillTimerStarted = false;
                StartDestroyTimer();
            });
            CCSequence sequence = new CCSequence(delayAction, delayCompletedAction);

            RunAction(sequence);
        }
Пример #18
0
        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);
            }
        }
Пример #19
0
        public void BeginLevelChangeAnimation(uint level, Action callback)
        {
            //foreach (PositionInGame positionType in Enum.GetValues(typeof(PositionInGame)))
            //{
            //    var square = _cordinatesGenerator.PositionAndSquare[positionType];


            //    square.RunAction(blink);
            //}

            int levelIndex = 1;

            while (levelIndex < level)
            {
                var smallSquare = _cordinatesGenerator.Levels[(LevelLivePosition)levelIndex];
                smallSquare.RunAction(blinkOnce);

                levelIndex++;
            }

            var completedAction = new CCCallFunc(callback);

            CCBlink    blinkLevel         = new CCBlink(1.0f, 3);
            CCSequence mySequence         = new CCSequence(blinkLevel, completedAction);
            var        currentLevelSquare = _cordinatesGenerator.Levels[(LevelLivePosition)level];

            currentLevelSquare.Visible = true;
            currentLevelSquare.RunAction(mySequence);
            //RunAction(mySequence);

            //if (level >= 10)
            //{
            //    if (rotating == false)
            //    {
            //        rotating = true;
            //        //DiagonalSquares(() => StarRotating(true));
            //        StarRotating(true);
            //    }
            //}
        }
Пример #20
0
        public override void onEnter()
        {
            base.onEnter();

            CCSprite child = CCSprite.spriteWithFile(s_pPathGrossini);

            child.position = (new CCPoint(200, 200));
            addChild(child, 1);

            //Sum of all action's duration is 1.5 second.
            child.runAction(CCRotateBy.actionWithDuration(1.5f, 90));
            child.runAction(CCSequence.actions(
                                CCDelayTime.actionWithDuration(1.4f),
                                CCFadeOut.actionWithDuration(1.1f))
                            );

            //After 1.5 second, self will be removed.
            runAction(CCSequence.actions(
                          CCDelayTime.actionWithDuration(1.4f),
                          CCCallFunc.actionWithTarget(this, (removeThis)))
                      );
        }
Пример #21
0
        void AddOceanscape()
        {
            float           oceanScaleFactor = 0;
            float           beachScaleFactor = 0;
            CCSprite        beachSprite      = new CCSprite("Beach");
            CCMoveBy        moveUpBy         = new CCMoveBy(3, new CCPoint(0, 10));
            CCMoveBy        moveDownBy       = new CCMoveBy(3, new CCPoint(0, -10));
            CCSequence      oceanSequence    = new CCSequence(moveUpBy, moveDownBy);
            CCRepeatForever oceanAnimation   = new CCRepeatForever(oceanSequence);
            CCCallFunc      boatAnimationFunction;

            oceanSprite      = new CCSprite("Ocean");
            oceanScaleFactor = layerWidth / oceanSprite.ContentSize.Width;
            beachScaleFactor = layerWidth / beachSprite.ContentSize.Width;

            oceanSprite.ScaleX    = oceanScaleFactor + 0.02f;
            oceanSprite.ScaleY    = oceanScaleFactor;
            oceanSprite.PositionX = oceanSprite.ContentSize.Center.X * oceanScaleFactor;
            oceanSprite.PositionY = oceanSprite.ContentSize.Center.Y * oceanScaleFactor + beachSprite.ContentSize.Center.Y * oceanScaleFactor - 40;
            oceanSprite.UserData  = oceanSprite.PositionY;

            beachSprite.ScaleX    = beachScaleFactor + 0.02f;
            beachSprite.ScaleY    = beachScaleFactor;
            beachSprite.PositionX = beachSprite.ContentSize.Center.X * beachScaleFactor;
            beachSprite.PositionY = beachSprite.ContentSize.Center.Y * beachScaleFactor;

            boatSprite          = new CCSprite("Boat");
            boatSprite.Position = new CCPoint(100, oceanSprite.PositionY + boatSprite.ContentSize.Height / 2);

            oceanAnimation        = new CCRepeatForever(oceanSequence);
            boatAnimationFunction = new CCCallFunc(() => boatSprite.PositionY = oceanSprite.PositionY + boatSprite.ContentSize.Height / 2 - 3);
            boatAnimation         = new CCRepeatForever(boatAnimationFunction);

            AddChild(boatSprite);
            AddChild(oceanSprite);
            AddChild(beachSprite);
            boatSprite.RunAction(boatAnimation);
            oceanSprite.RunAction(oceanAnimation);
        }
Пример #22
0
        private void ChangeSquaresPosition(int firstPositionInGame, int lastPositionInGame, Action callback = null)
        {
            var firstPosition  = (PositionInGame)_random.Next(firstPositionInGame, lastPositionInGame);
            var secondPosition = (PositionInGame)_random.Next(firstPositionInGame, lastPositionInGame);

            while (firstPosition == secondPosition)
            {
                secondPosition = (PositionInGame)_random.Next(firstPositionInGame, lastPositionInGame);
            }


            var firstSquarePosition  = _cordinatesGenerator.PositionAndCordinates[firstPosition];
            var secondSquarePosition = _cordinatesGenerator.PositionAndCordinates[secondPosition];

            var firstPoint  = firstSquarePosition.Point;
            var secondPoint = secondSquarePosition.Point;

            _cordinatesGenerator.PositionAndCordinates[firstPosition].Point  = secondPoint;
            _cordinatesGenerator.PositionAndCordinates[secondPosition].Point = firstPoint;


            var moveToFirstPosition  = new CCMoveTo(_timeForChangingPositions, firstPoint);
            var moveToSecondPosition = new CCMoveTo(_timeForChangingPositions, secondPoint);

            secondSquarePosition.Square.RunAction(moveToFirstPosition);

            if (callback != null)
            {
                var        moveCompletedAction = new CCCallFunc(callback);
                CCSequence mySequence          = new CCSequence(moveToSecondPosition, moveCompletedAction);

                firstSquarePosition.Square.RunAction(mySequence);
            }
            else
            {
                firstSquarePosition.Square.RunAction(moveToSecondPosition);
            }
        }
Пример #23
0
        internal void BeginLiveTakenAnimation(uint lives, Action callback)
        {
            if (lives == 0)
            {
                callback.Invoke();
                return;
            }
            var completedAction = new CCCallFunc(callback);

            //CCBlink blinkLives = new CCBlink(0.5f, 2);
            CCSequence mySequence = new CCSequence(blinkLives, completedAction);
            uint       liveToTake = lives + 1;

            if (liveToTake > 14)
            {
                _cordinatesGenerator.Lives[LevelLivePosition.Plus].RunAction(mySequence);
            }
            else
            {
                var currentLevelSquare = _cordinatesGenerator.Lives[(LevelLivePosition)liveToTake];
                currentLevelSquare.RunAction(mySequence);
            }
        }
Пример #24
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLabelTTF l = new CCLabelTTF("Should not crash", "arial", 16);

            AddChild(l);
            l.Position = (new CCPoint(s.Width / 2, 245));

            CCMoveBy         pMove     = new CCMoveBy(2, new CCPoint(200, 0));
            CCCallFunc       pCallback = new CCCallFunc(stopAction);
            CCActionInterval pSequence = (CCActionInterval) new CCSequence(pMove, pCallback);

            pSequence.Tag = (int)KTag.kTagSequence;

            CCSprite pChild = new CCSprite(s_pPathGrossini);

            pChild.Position = (new CCPoint(200, 200));

            AddChild(pChild, 1, kTagGrossini);
            pChild.RunAction(pSequence);
        }
Пример #25
0
        private async Task DiagonalSquares(CCFiniteTimeAction rotate, Action callback = null)
        {
            if (_isDiagonal)
            {
                return;
            }

            _isDiagonal = true;
            playUpLeft.RunAction(rotate);


            playDownRight.RunAction(rotate);
            playDownLeft.RunAction(rotate);
            if (callback != null)
            {
                var        movecompletedaction = new CCCallFunc(callback);
                CCSequence mysequence          = new CCSequence(rotate, movecompletedaction);
                playUpRight.RunAction(mysequence);
            }
            else
            {
                await playUpRight.RunActionAsync(rotate);
            }
        }
Пример #26
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(3);

            CCFiniteTimeAction action = CCSequence.actions(
                CCMoveBy.actionWithDuration(2, new CCPoint(200, 0)),
                CCCallFunc.actionWithTarget(this, new SEL_CallFunc(callback1)));

            CCFiniteTimeAction action2 = CCSequence.actions(
                CCScaleBy.actionWithDuration(2, 2),
                CCFadeOut.actionWithDuration(2),
                CCCallFuncN.actionWithTarget(this, new SEL_CallFuncN(callback2)));

            CCFiniteTimeAction action3 = CCSequence.actions(
                CCRotateBy.actionWithDuration(3, 360),
                CCFadeOut.actionWithDuration(2),
                CCCallFuncND.actionWithTarget(this, new SEL_CallFuncND(callback3), (object)0xbebabeba));

            m_grossini.runAction(action);
            m_tamara.runAction(action2);
            m_kathia.runAction(action3);
        }
Пример #27
0
        public override void onEnter()
        {
            base.onEnter();

            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCLabelTTF l = CCLabelTTF.labelWithString("Should not crash", "Arial", 16);

            addChild(l);
            l.position = (new CCPoint(s.width / 2, 245));

            CCMoveBy         pMove     = CCMoveBy.actionWithDuration(2, new CCPoint(200, 0));
            CCCallFunc       pCallback = CCCallFunc.actionWithTarget(this, stopAction);
            CCActionInterval pSequence = (CCActionInterval)CCSequence.actions(pMove, pCallback);

            pSequence.tag = (int)KTag.kTagSequence;

            CCSprite pChild = CCSprite.spriteWithFile(s_pPathGrossini);

            pChild.position = (new CCPoint(200, 200));

            addChild(pChild, 1, kTagGrossini);
            pChild.runAction(pSequence);
        }
Пример #28
0
 protected CCCallFunc(CCCallFunc callFunc) : base(callFunc)
 {
     m_pCallFunc      = callFunc.m_pCallFunc;
     m_scriptFuncName = callFunc.m_scriptFuncName;
 }
Пример #29
0
 protected CCCallFunc(CCCallFunc callFunc)
     : base(callFunc)
 {
     m_pCallFunc = callFunc.m_pCallFunc;
     m_scriptFuncName = callFunc.m_scriptFuncName;
 }
Пример #30
0
        private async Task RotatePlayButtons(bool clockwise, Action callback)
        {
            float timePerMove = 1.5f;


            //var signalUpLeft = _cordinatesGenerator.PositionAndSquare[PositionInGame.SignalUpLeft];
            //var signalUpRight = _cordinatesGenerator.PositionAndSquare[PositionInGame.SignalUpRight];
            //var signalDownLeft = _cordinatesGenerator.PositionAndSquare[PositionInGame.SignalDownLeft];
            //var signalDownRight = _cordinatesGenerator.PositionAndSquare[PositionInGame.SignalDownRight];
            playUpLeft    = _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayUpLeft];
            playUpRight   = _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayUpRight];
            playDownLeft  = _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayDownLeft];
            playDownRight = _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayDownRight];



            var moveToUpLeft = new CCMoveTo(timePerMove, new CCPoint(playUpLeft.Position.X, playUpLeft.Position.Y));

            var moveToUpRight = new CCMoveTo(timePerMove, new CCPoint(playUpRight.Position.X, playUpRight.Position.Y));



            var moveToDownRight = new CCMoveTo(timePerMove, new CCPoint(playDownRight.Position.X, playDownRight.Position.Y));


            var moveToDownLeft = new CCMoveTo(timePerMove, new CCPoint(playDownLeft.Position.X, playDownLeft.Position.Y));

            var        moveCompletedAction = new CCCallFunc(callback);
            CCSequence mySequence          = new CCSequence(moveToDownRight, moveCompletedAction);



            CCRotateBy rotate     = new CCRotateBy(0.5f, 45);
            var        rotateBack = rotate.Reverse();

            await DiagonalSquares(rotate);

            await MoveHalfWay(timePerMove);


            //var halfMoveCompletedAction = new CCCallFunc(() =>
            //{
            _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayUpLeft]    = playDownLeft;
            _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayUpRight]   = playUpLeft;
            _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayDownLeft]  = playDownRight;
            _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayDownRight] = playUpRight;

            playUpLeft.RunAction(moveToUpRight);
            playDownRight.RunAction(moveToDownLeft);
            playDownLeft.RunAction(moveToUpLeft);
            await playUpRight.RunActionAsync(mySequence);

            //await DiagonalSquares(rotateBack, callback);
            //});



            //}
            //else
            //{
            //    playUpLeft.RunAction(moveToDownLeft);
            //    playUpRight.RunAction(moveToUpLeft);
            //    playDownRight.RunAction(moveToUpRight);
            //    playDownLeft.RunAction(mySequence);

            //    _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayUpLeft] = playUpRight;
            //    _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayUpRight] = playDownRight;
            //    _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayDownLeft] = playUpLeft;
            //    _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayDownRight] = playDownLeft;
            //}
        }
        bool OnTouchBegan(CCTouch touch, CCEvent touchEvent)
        {
            CCSprite caller = touchEvent.CurrentTarget as CCSprite;

            if (caller.Tag == SpriteTypes.IconTag)
            {
                ReorderChild(caller, 999);
            }

            CurrentSpriteTouched = null;
            touchType            = Tags.Tag.None;

            startTime = DateTime.Now;

            if (windowFrame != null)
            {
                if (windowFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                {
                    if (closeButton.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                    {
                        isModal = false;

                        var scaleAction    = new CCScaleTo(0.2f, 0.05f);
                        var functionAction = new CCCallFunc(ClearWindow);
                        windowFrame.AddActions(false, scaleAction, functionAction);

                        return(true);
                    }

                    var mIcons = windowFrame.Children;

                    foreach (var mIcon in mIcons)
                    {
                        if (mIcon.Tag == SpriteTypes.IconTag && mIcon.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                        {
                            touchType = Tags.Tag.TransitionIcon;

                            var mContent = mIcon.GetChildByTag(SpriteTypes.ContentTag) as CCLabel;

                            if (mContent != null)
                            {
                                StoredIconReference mStoredRef = null;
                                foreach (StoredIconReference storedRef in storedList)
                                {
                                    var mLoopSprite  = storedRef.Sprite;
                                    var mLoopContent = mLoopSprite.GetChildByTag(SpriteTypes.ContentTag) as CCLabel;

                                    if (mLoopContent != null && mLoopContent.Text == mContent.Text)
                                    {
                                        var xMin      = (spriteModelFactory.DynamicHeight * 0.1f) / 2;
                                        var yLocation = mRandom.Next((int)(spriteModelFactory.DynamicHeight * 0.3f), (int)(spriteModelFactory.DynamicHeight - (spriteModelFactory.DynamicHeight * 0.3f)));
                                        var xLocation = mRandom.Next((int)(spriteModelFactory.DynamicWidth * 0.3f), (int)(spriteModelFactory.DynamicWidth - (spriteModelFactory.DynamicWidth * 0.3f)));

                                        var newIcon = spriteModelFactory.MakeIconBase64(storedRef.Base64, mLoopContent.Text,
                                                                                        xLocation, yLocation, storedRef.Scale, storedRef.TextScale, storedRef.TextVisible);

                                        var mIconRef = new IconReference(newIcon, storedRef.Base64, 1f, true);

                                        AddEventListener(mListener.Copy(), mIconRef.Sprite);
                                        iconList2.Add(mIconRef);

                                        AddChild(mIconRef.Sprite);

                                        mStoredRef = storedRef;
                                    }
                                }

                                if (mStoredRef != null)
                                {
                                    storedList.Remove(mStoredRef);
                                }
                            }

                            isModal = false;

                            iconList2.Remove(tempWindow);

                            windowFrame.RemoveChild(closeButton);

                            RemoveChild(windowFrame);

                            windowFrame = closeButton = null;
                            tempWindow  = null;

                            return(true);
                        }
                    }

                    return(false);
                }
            }

            #region ButtonSpecific Listeners

            if (caller.GetHashCode() == speakerFrame.GetHashCode())
            {
                foreach (IconReference iconRef in iconList2)
                {
                    var rect = iconRef.Sprite.BoundingBoxTransformedToWorld;

                    if (speakerFrame.BoundingBoxTransformedToParent.IntersectsRect(rect))
                    {
                        return(false);
                    }
                }

                if (speakerFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                {
                    touchType            = Tags.Tag.Speak;
                    CurrentSpriteTouched = speakerFrame;
                    caller.Opacity       = 155;

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (caller.GetHashCode() == addFrame.GetHashCode())
            {
                foreach (IconReference iconRef in iconList2)
                {
                    var rect = iconRef.Sprite.BoundingBoxTransformedToWorld;

                    if (addFrame.BoundingBoxTransformedToParent.IntersectsRect(rect))
                    {
                        return(false);
                    }
                }

                if (addFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                {
                    touchType            = Tags.Tag.Add;
                    CurrentSpriteTouched = addFrame;
                    caller.Opacity       = 155;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (caller.GetHashCode() == takePhotoFrame.GetHashCode())
            {
                foreach (IconReference iconRef in iconList2)
                {
                    var rect = iconRef.Sprite.BoundingBoxTransformedToWorld;

                    if (takePhotoFrame.BoundingBoxTransformedToParent.IntersectsRect(rect))
                    {
                        return(false);
                    }
                }

                if (takePhotoFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                {
                    touchType            = Tags.Tag.TakePhoto;
                    CurrentSpriteTouched = takePhotoFrame;
                    caller.Opacity       = 155;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (caller.GetHashCode() == addFolderFrame.GetHashCode())
            {
                foreach (IconReference iconRef in iconList2)
                {
                    var rect = iconRef.Sprite.BoundingBoxTransformedToWorld;

                    if (addFolderFrame.BoundingBoxTransformedToParent.IntersectsRect(rect))
                    {
                        return(false);
                    }
                }

                if (addFolderFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                {
                    touchType            = Tags.Tag.Folder;
                    CurrentSpriteTouched = addFolderFrame;
                    caller.Opacity       = 155;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (caller.GetHashCode() == singleFrame.GetHashCode())
            {
                foreach (IconReference iconRef in iconList2)
                {
                    var rect = iconRef.Sprite.BoundingBoxTransformedToWorld;

                    if (singleFrame.BoundingBoxTransformedToParent.IntersectsRect(rect))
                    {
                        return(false);
                    }
                }

                if (singleFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                {
                    touchType            = Tags.Tag.SingleMode;
                    CurrentSpriteTouched = singleFrame;
                    caller.Opacity       = 155;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (caller.GetHashCode() == multiFrame.GetHashCode())
            {
                foreach (IconReference iconRef in iconList2)
                {
                    var rect = iconRef.Sprite.BoundingBoxTransformedToWorld;

                    if (multiFrame.BoundingBoxTransformedToParent.IntersectsRect(rect))
                    {
                        return(false);
                    }
                }

                if (multiFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                {
                    touchType            = Tags.Tag.MultiMode;
                    CurrentSpriteTouched = multiFrame;
                    caller.Opacity       = 155;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            #endregion

            foreach (IconReference iconRef in iconList2)
            {
                if (iconRef.Sprite.Tag == SpriteTypes.IconTag)
                {
                    if (inSingleMode)
                    {
                        if (caller.GetHashCode() == iconRef.Sprite.GetHashCode())
                        {
                            if (iconRef.Sprite.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                            {
                                touchType = Tags.Tag.Icon;

                                CurrentSpriteTouched = iconRef.Sprite;
                                caller.Opacity       = 155;

                                DeSelectIcons();

                                caller.Color = Green;

                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        if (caller.GetHashCode() == iconRef.Sprite.GetHashCode())
                        {
                            if (iconRef.Sprite.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                            {
                                touchType            = Tags.Tag.Icon;
                                CurrentSpriteTouched = iconRef.Sprite;
                                caller.Opacity       = 155;

                                if (!sentenceFrame.Visible)
                                {
                                    caller.Color = Green;
                                }

                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                }
                else if (iconRef.Sprite.Tag == SpriteTypes.FolderTag)
                {
                    if (caller.GetHashCode() == iconRef.Sprite.GetHashCode())
                    {
                        if (iconRef.Sprite.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                        {
                            touchType            = Tags.Tag.FolderIcon;
                            CurrentSpriteTouched = iconRef.Sprite;
                            caller.Opacity       = 155;

                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }

            return(false);
        }