コード例 #1
0
        private void createAnimation()
        {
            var timeBetween = 45;
            var msDuration  = RandomUtil.RandomInt(1000, 5500);

            if (RandomUtil.RandomInt(0, 100) < 25)
            {
                Motion = MotionManager.StartMotion(0, 0)
                         .Motion(new WaitMotion(msDuration))       //frame 1
                         .Motion(new WaitMotion(timeBetween))      //frame 1
                         .Motion(new WaitMotion(timeBetween))      //frame 2
                         .Motion(new WaitMotion(timeBetween))      //frame 3
                         .Motion(new WaitMotion(timeBetween))      //frame 4
                         .Motion(new WaitMotion(timeBetween))      //frame 5
                         .Motion(new WaitMotion(timeBetween))      //frame 6
                         .Motion(new WaitMotion(timeBetween))      //frame 7
                         .Motion(new WaitMotion(timeBetween * 6)); //frame 8 (blink)
                Motion.OnRender(render);
            }
            else
            {
                Motion = MotionManager.StartMotion(0, 0)
                         .Motion(new WaitMotion(msDuration))       //frame 1
                         .Motion(new WaitMotion(timeBetween * 3)); //frame 8 (blink)
                Motion.OnRender((layer, posx, posy, animationIndex, percent) => render(layer, posx, posy, animationIndex != 0 ? 8 : 0, 0));
            }


            Client.Timeout(createAnimation, msDuration + RandomUtil.RandomInt(2000, 5500));
        }
コード例 #2
0
        private bool startGame(TouchType eventtype, TouchRect touchbox, int x, int y, bool collide)
        {
            if (State.ShowingTutorial != 0)
            {
                return(true);
            }
            switch (eventtype)
            {
            case TouchType.TouchDown:
                if (State.StartClicked)
                {
                    return(false);
                }
                Client.PlaySoundEffect(Assets.Sounds.Click);
                State.StartClicked = true;

                IImage logoImage    = Assets.Images.Layouts.PenguinLogo;
                IImage shuffleImage = Assets.Images.Layouts.ShuffleLogo;

                PenguinLogoAnimation = MotionManager.StartMotion(Positions.PenguinLogoLocation)
                                       .Motion(new AnimationMotion(Layout.Width + 1000, Positions.PenguinLogoLocation.Y, 1000, AnimationEasing.SineEaseIn))
                                       .Motion(new WaitMotion(5000))
                                       .OnRender((layer, posX, posY, animationIndex, percentDone) => { mainLayer.DrawImage(logoImage, posX, posY, true); })
                                       .OnComplete(() => { });

                ShuffleLogoAnimation = MotionManager.StartMotion(Positions.ShuffleLogoLocation)
                                       .Motion(new AnimationMotion(Layout.Width + 1000, Positions.ShuffleLogoLocation.Y, 1400, AnimationEasing.SineEaseIn))
                                       .Motion(new WaitMotion(5000))
                                       .OnRender((layer, posX, posY, animationIndex, percentDone) => { mainLayer.DrawImage(shuffleImage, posX, posY, true); })
                                       .OnComplete(() => { });
                return(true);
            }
            return(false);
        }
コード例 #3
0
        private bool tapCard(TouchType eventtype, TouchRect touchbox, int x, int y, bool collide)
        {
            if (eventtype == TouchType.TouchDown)
            {
                if (State.CardAnimationMotion != null)
                {
                    return(false);
                }

                Client.PlaySoundEffect(Assets.Sounds.Click);
                var    gc        = (Goal)touchbox.State;
                IImage goalImage = GoalPiece.GetGoalImage(gc);


                Goal[] goals = GameService.ClassicGameState.UnusedGoals;
                int    topRow = goals.Length / 2;
                int    bottomRow = goals.Length / 2 + goals.Length % 2;
                int    posx, posy;
                int    index = Array.IndexOf(goals, gc);

                int yAnimateOffset = 0;
                if (index < topRow)
                {
                    int centerOffset = (Positions.BottomCardAreaWidth / (topRow)) / 2;

                    posx           = ((Positions.BottomCardAreaWidth / topRow * (index))) + centerOffset;
                    posy           = (Positions.BottomCardSize / 2) - Positions.CardShadowHeight;
                    yAnimateOffset = 0;
                }
                else
                {
                    int centerOffset = (Positions.BottomCardAreaWidth / (bottomRow)) / 2;

                    posx           = ((Positions.BottomCardAreaWidth / bottomRow * (index - topRow))) + centerOffset;
                    posy           = Positions.BottomCardSize - 40 + Positions.BottomCardSize / 2 - Positions.CardShadowHeight;
                    yAnimateOffset = 300;
                }

                State.CurrentlySelectedGoal = gc;

                State.CardAnimationMotion = MotionManager.StartMotion(posx, posy, new AnimationMotion(Positions.Layout.Width / 2, posy - 850 - yAnimateOffset, 1500, AnimationEasing.BounceEaseIn))
                                            .Motion(new WaitMotion(1000))
                                            .Motion(new AnimationMotion(Positions.Layout.Width / 2, -3000, 1000, AnimationEasing.CubicEaseOut))
                                            .OnRender((layer, posX, posY, animationIndex, percentDone) => { MainLayer.DrawImage(goalImage, posX, posY, true); })
                                            .OnComplete(() =>
                {
                    gc.Used = true;

                    GameService.ClassicGameState.CurrentGoal = gc;
                    State.CardAnimationMotion = null;

                    GameService.ClassicGameState.GameState = GameSelectionState.SearchingBoard;
                    ScreenTransitioner.ChangeToBoardViewingScreen();
                });

                return(false);
            }
            return(true);
        }
コード例 #4
0
            public void Start()
            {
                MovingLeft = RandomUtil.RandomBool();


                StartY = RandomUtil.RandomInt(0, 800);
                EndY   = StartY + RandomUtil.RandomInt(-100, 100);
                var startPosition = new Point(MovingLeft ? 1900 + RandomUtil.RandomInt(0, 1200) : -500 - RandomUtil.RandomInt(0, 1200), StartY);
                var endPosition   = new Point(!MovingLeft ? 1900 + RandomUtil.RandomInt(0, 1200) : -500 - RandomUtil.RandomInt(0, 1200), EndY);

                int msDuration = RandomUtil.RandomInt(18000, 25000);

                Animation = MotionManager.StartMotion(startPosition).Motion(new AnimationMotion(endPosition, msDuration, AnimationEasing.Linear)).OnRender((mainLayer, x, y) => render(mainLayer, x, y)).OnComplete(() => Start());
            }
コード例 #5
0
        public void Init()
        {
            mainLayer = Renderer.CreateLayer(Layout);
            Renderer.AddLayer(mainLayer);
            State.SelectedNumberOfPlayers = 1;


            for (int j = 0; j < 6; j++)
            {
                TouchManager.PushClickRect(new TouchRect(State.Positions.NumberOfPlayersPositions[j].X, State.Positions.NumberOfPlayersPositions[j].Y, State.Positions.ButtonSize.X, State.Positions.ButtonSize.Y, numberOfPlayersClick, state: j + 1, pointIsCenter: true));
            }

            TouchManager.PushClickRect(new TouchRect(State.Positions.BackPosition.X, State.Positions.BackPosition.Y, 102, 113, backClick));

            //            TouchManager.PushClickRect(new TouchRect(State.Positions.ModesButtonPosition.X - 692, State.Positions.ModesButtonPosition.Y - 107, 1384, 215, changeModeClick));
            TouchManager.PushClickRect(new TouchRect(State.Positions.StartGamePosition.X, State.Positions.StartGamePosition.Y, Layout.Width, 257, startGameClick));

            State.StartClicked       = false;
            State.StartGameAnimation = MotionManager.StartMotion(0, -400)
                                       .Motion(new WaitMotion(500))
                                       .Motion(new AnimationMotion(0, 0, 500, AnimationEasing.CubicEaseIn))
                                       .Motion(new WaitMotion(500))
                                       .OnRender((layer, posX, posY, animationIndex, percentDone) => { drawStartGame(posY); })
                                       .OnComplete(() =>
            {
                if (State.StartClicked)
                {
                    if (!HasMultiplayer)
                    {
                        State.SelectedNumberOfPlayers = 1;
                    }

                    State.ScreenManager.StartGame(State.SelectedNumberOfPlayers, State.SelectedMode);
                }
            });

            State.MenuAnimation = MotionManager.StartMotion(-1500, 0)
                                  .Motion(new AnimationMotion(0, 0, 800, AnimationEasing.CubicEaseIn))
                                  .OnRender((layer, posX, posY, animationIndex, percentDone) => { drawMenu(posX); });

            GameService.CloudSubLayout.InitLayoutView(TouchManager);
        }
コード例 #6
0
        public void InitLayoutView()
        {
            mainLayer = renderer.CreateLayer(Layout.Width, Layout.Height, Layout);
            renderer.AddLayer(mainLayer);

            TouchManager = new TouchManager(game.Client);
            TouchManager.PushClickRect(Positions.HelloWorldPosition, Assets.Images.Landing.HelloWorld, (type, box, x, y, collide) => {
                if (type == TouchType.TouchDown)
                {
                    if (!State.ShowWelcome)
                    {
                        State.ShowWelcome = true;
                    }
                }
                return(true);
            }, true);

            helloWorldAnimation = MotionManager
                                  .StartMotion(Positions.HelloWorldPosition.X, 0)
                                  .Motion(new AnimationMotion(Positions.HelloWorldPosition, 1600, AnimationEasing.SineEaseIn))
                                  .Motion(new AnimationMotion(Positions.HelloWorldPosition.X, Layout.Height / 4, 800, AnimationEasing.SineEaseIn))
                                  .Motion(new AnimationMotion(Positions.HelloWorldPosition, 600, AnimationEasing.SineEaseIn))
                                  .Motion(new FinishMotion())
                                  .OnRender((layer, posX, posY, animationIndex, percentDone) => {
                layer.Save();
                layer.DrawImage(Assets.Images.Landing.HelloWorld, posX, posY, true);
                layer.Restore();
            });

            welcomeAnimation = MotionManager
                               .StartMotion(Positions.WelcomePosition.X, 0)
                               .Motion(new AnimationMotion(Positions.WelcomePosition, 1600, AnimationEasing.SineEaseIn))
                               .Motion(new AnimationMotion(Positions.WelcomePosition.X, Layout.Height / 2, 800, AnimationEasing.SineEaseIn))
                               .Motion(new AnimationMotion(Positions.WelcomePosition, 600, AnimationEasing.SineEaseIn))
                               .Motion(new FinishMotion())
                               .OnRender((layer, posX, posY, animationIndex, percentDone) => {
                layer.Save();
                layer.DrawImage(Assets.Images.Landing.Welcome, posX, posY, true);
                layer.Restore();
            });
        }
コード例 #7
0
        public void SlideRight()
        {
            if (BgSlidingState != BgSlidingState.Left)
            {
                return;
            }

            BgSlidingState      = BgSlidingState.SlidingRight;
            BackgroundAnimation = MotionManager.StartMotion(0, 0)
                                  .Motion(new AnimationMotion(-384, 0, 800, AnimationEasing.SineEaseIn))
                                  .OnRender((layer, x, y) =>
            {
                layer.Translate(x, 0);
                layer.DrawImage(Assets.Images.Layouts.CloudlessMainBg, 0, 0);
            })
                                  .OnComplete(() =>
            {
                BackgroundAnimation = null;
                BgSlidingState      = BgSlidingState.Right;
            });
        }
コード例 #8
0
        private void PlayerWon(GoalPiece goal)
        {
            Point pos = Positions.CharacterPositions[State.CurrentChosenNumber.Character.CharacterNumber];

            State.Congrats = true;
            IImage goalImage = GoalPiece.GetGoalImage(GameService.ClassicGameState.CurrentGoal);

            State.CardAnimationMotion = MotionManager.StartMotion(Positions.CongratsPosition.X, Positions.CongratsPosition.Y, new WaitMotion(200))
                                        .Motion(new AnimationMotion(pos.X + 0, pos.Y + BoardConstants.TopAreaHeight, 2000, AnimationEasing.BounceEaseOut))
                                        .OnRender((layer, posX, posY, animationIndex, percentDone) =>
            {
                MainLayer.Save();
                MainLayer.SetDrawingTransparency(1 - percentDone);
                MainLayer.DrawImage(goalImage, posX, posY, 220, 220, true);
                MainLayer.Restore();
            }).OnComplete(() =>
            {
                GameService.ClassicGameState.Board.SquarePieces.Remove(goal);

                GameService.ClassicGameState.CharacterWon(State.CurrentChosenNumber.Character);
                ScreenTransitioner.ChangeToBoardCardSelectionScreen();
            });
        }
コード例 #9
0
        public void Init()
        {
            State = new LandingAreaLayoutState();
            State.SoundSubLayout = new SoundSubLayout(Client);

            setNextHop();
            GameService.CloudSubLayout.InitLayoutView(TouchManager);
            GameService.CloudSubLayout.SlideLeft();
            mainLayer = Renderer.CreateLayer(Layout.Width, Layout.Height, Layout);
            Renderer.AddLayer(mainLayer);


            TouchManager.PushClickRect(new TouchRect(Positions.StartLocation.X, Positions.StartLocation.Y, 1300, 324, startGame, true));
            TouchManager.PushClickRect(new TouchRect(Positions.TutorialButtonPosition.X, Positions.TutorialButtonPosition.Y, 200, 200, tutorialTrigger, true));

            TouchManager.PushClickRect(new TouchRect(Positions.AboutBubblePosition + Positions.AboutContactUsPosition, Positions.AboutButtonSize, aboutContactTouch));
            TouchManager.PushClickRect(new TouchRect(Positions.AboutBubblePosition + Positions.AboutRatePosition, Positions.AboutButtonSize, aboutRateTouch));

            TouchManager.PushClickRect(new TouchRect(Positions.AboutOpenPenguinPosition, 533, 512, toggleOpening, true));


            TouchManager.PushClickRect(new TouchRect(0, 0, 1536, 2048, closeBox));

            IImage logoImage    = Assets.Images.Layouts.PenguinLogo;
            IImage shuffleImage = Assets.Images.Layouts.ShuffleLogo;

            PenguinLogoAnimation = MotionManager.StartMotion(-1000, Positions.PenguinLogoLocation.Y)
                                   .Motion(new WaitMotion(300))
                                   .Motion(new AnimationMotion(Positions.PenguinLogoLocation.X, Positions.PenguinLogoLocation.Y, 500, AnimationEasing.SineEaseIn))
                                   .OnRender((layer, posX, posY, animationIndex, percentDone) => mainLayer.DrawImage(logoImage, posX, posY, true))
                                   .OnComplete(() => { });

            ShuffleLogoAnimation = MotionManager.StartMotion(-1000, Positions.ShuffleLogoLocation.Y)
                                   .Motion(new WaitMotion(300))
                                   .Motion(new AnimationMotion(Positions.ShuffleLogoLocation.X, Positions.ShuffleLogoLocation.Y, 600, AnimationEasing.SineEaseIn))
                                   .OnRender((layer, posX, posY, animationIndex, percentDone) => mainLayer.DrawImage(shuffleImage, posX, posY, true))
                                   .OnComplete(() => { });

            PlayButtonAnimation = MotionManager.StartMotion(-1000, Positions.StartLocation.Y)
                                  .Motion(new WaitMotion(300))
                                  .Motion(new AnimationMotion(Positions.StartLocation, 700, AnimationEasing.SineEaseIn))
                                  .OnRender((layer, posX, posY, animationIndex, percentDone) => mainLayer.DrawImage(Assets.Images.Layouts.PlayButton, posX, posY, true))
                                  .OnComplete(() => { });


            State.AboutState = AboutState.Closed;


            IImage penguinImage = Assets.Images.About.MainPenguin;

            AboutOpenDialogAnimation = MotionManager.StartMotion(0, 0)
                                       .Motion(new AnimationMotion(0, 100, 600, AnimationEasing.Linear))
                                       .OnRender((layer, posX, posY, animationIndex, percentDone) =>
            {
                layer.Save();
                layer.SetDrawingTransparency(posY / 100f);
                aboutBoxRender(layer);
                layer.Restore();
            });

            RandomPenguinHop = MotionManager.StartMotion(Positions.AboutPenguinPosition)
                               .Motion(new AnimationMotion(Positions.AboutPenguinPosition.X, Positions.AboutPenguinPosition.Y - 25, 200, AnimationEasing.CubicEaseOut))
                               .Motion(new AnimationMotion(Positions.AboutPenguinPosition, 150, AnimationEasing.CubicEaseIn))
                               .Motion(new AnimationMotion(Positions.AboutPenguinPosition.X, Positions.AboutPenguinPosition.Y - 50, 200, AnimationEasing.CubicEaseOut))
                               .Motion(new AnimationMotion(Positions.AboutPenguinPosition, 150, AnimationEasing.CubicEaseIn))
                               .OnRender((layer, posX, posY, animationIndex, percentDone) => { mainLayer.DrawImage(penguinImage, posX, posY, true); })
                               .DontStart();


            InitialPenguinHop = MotionManager.StartMotion(Positions.AboutPenguinPosition.X, Positions.AboutPenguinPosition.Y + 1000)
                                .Motion(new WaitMotion(300))
                                .Motion(new AnimationMotion(Positions.AboutPenguinPosition.X, Positions.AboutPenguinPosition.Y - 25, 1000, AnimationEasing.CubicEaseOut))
                                .Motion(new AnimationMotion(Positions.AboutPenguinPosition, 150, AnimationEasing.CubicEaseIn))
                                .Motion(new AnimationMotion(Positions.AboutPenguinPosition.X, Positions.AboutPenguinPosition.Y - 50, 200, AnimationEasing.CubicEaseOut))
                                .Motion(new AnimationMotion(Positions.AboutPenguinPosition, 150, AnimationEasing.CubicEaseIn))
                                .OnRender((layer, posX, posY, animationIndex, percentDone) => { mainLayer.DrawImage(penguinImage, posX, posY, true); });

            AboutCloseDialogAnimation = MotionManager.StartMotion(0, 100)
                                        .Motion(new AnimationMotion(0, 0, 600, AnimationEasing.Linear))
                                        .OnRender((layer, posX, posY, animationIndex, percentDone) =>
            {
                layer.Save();
                layer.SetDrawingTransparency(posY / 100f);
                aboutBoxRender(layer);
                layer.Restore();
            });

            AboutOpenAnimation = MotionManager.StartMotion(Positions.AboutPenguinPosition,
                                                           new AnimationMotion(Positions.AboutOpenPenguinPosition, 600, AnimationEasing.BounceEaseOut))
                                 .OnRender((layer, posX, posY, animationIndex, percentDone) => { mainLayer.DrawImage(penguinImage, posX, posY, true); }).OnComplete(() =>
            {
                setNextHop();
                State.AboutState = AboutState.Opened;
            });

            AboutCloseAnimation = MotionManager.StartMotion(Positions.AboutOpenPenguinPosition,
                                                            new AnimationMotion(Positions.AboutPenguinPosition, 400, AnimationEasing.CubicEaseIn))
                                  .OnRender((layer, posX, posY, animationIndex, percentDone) => { mainLayer.DrawImage(penguinImage, posX, posY, true); }).OnComplete(() =>
            {
                setNextHop();
                State.AboutState = AboutState.Closed;
            });

            StartGameAnimation = MotionManager.StartMotion(Positions.AboutPenguinPosition).
                                 Motion(new AnimationMotion(Positions.AboutPenguinPosition.X, 1300, 400, AnimationEasing.QuadEaseOut)).
                                 Motion(new AnimationMotion(Positions.AboutPenguinPosition.X, Positions.AboutPenguinPosition.Y + 100, 350, AnimationEasing.QuadEaseIn)).
                                 Motion(new AnimationMotion(Positions.AboutPenguinPosition.X, 700, 400, AnimationEasing.QuadEaseOut)).
                                 Motion(new AnimationMotion(Positions.AboutPenguinPosition.X, Positions.AboutPenguinPosition.Y + 200, 350, AnimationEasing.QuadEaseIn)).
                                 Motion(new AnimationMotion(Positions.AboutPenguinPosition.X, -500, 500, AnimationEasing.QuadEaseOut))
                                 .OnRender((layer, posX, posY, animationIndex, percentDone) => { mainLayer.DrawImage(penguinImage, posX, posY, true); }).OnComplete(() =>
            {
                GameService.CloudSubLayout.SlideRight();
                _screenTransitioner.ChangeToSettingsScreen();
            });


            State.SoundSubLayout.InitLayoutView(TouchManager);
        }