Пример #1
0
        public RenderTextureIssue937()
        {
            /*
             *     1    2
             * A: A1   A2
             *
             * B: B1   B2
             *
             *  A1: premulti sprite
             *  A2: premulti render
             *
             *  B1: non-premulti sprite
             *  B2: non-premulti render
             */
            CCLayerColor background = new CCLayerColor(new CCColor4B(200, 200, 200, 255));

            AddChild(background);

            spritePremulti    = new CCSprite("Images/fire");
            spriteNonpremulti = new CCSprite("Images/fire");
        }
Пример #2
0
        public MainLayer()
        {
            base.TouchEnabled = true;

            CCSprite sprite = new CCSprite(ClickAndMoveTest.s_pPathGrossini);

            CCLayer layer = new CCLayerColor(new CCColor4B(255, 255, 0, 255));

            AddChild(layer, -1);

            AddChild(sprite, 0, ClickAndMoveTest.kTagSprite);
            sprite.Position = new CCPoint(20, 150);

            sprite.RunAction(new CCJumpTo(4, new CCPoint(300, 48), 100, 4));

            layer.RunAction(new CCRepeatForever(
                                (CCActionInterval)(CCSequence.FromActions(
                                                       new CCFadeIn(1),
                                                       new CCFadeOut(1)))
                                ));
        }
        void HandleViewCreated(object sender, EventArgs e)
        {
            var gameView = sender as CCGameView;

            if (gameView != null)
            {
                // This sets the game "world" resolution to 100x100:
                gameView.DesignResolution = new CCSizeI(100, 100);
                // GameScene is the root of the CocosSharp rendering hierarchy:
                //gameScene = new GameScene(gameView);
                gamescene = new CCScene(gameView);
                //add sprtie to layer add layer to scene
                var layer = new CCLayerColor();
                var box   = new CCDrawNode();
                box.DrawRect(new CCPoint(50, 50), 25, CCColor4B.Red);
                layer.AddChild(box);
                gamescene.AddLayer(layer);
                // Starts CocosSharp:
                gameView.RunWithScene(gamescene);
            }
        }
Пример #4
0
        public MainLayer()
        {
            base.isTouchEnabled = true;

            CCSprite sprite = CCSprite.spriteWithFile(ClickAndMoveTest.s_pPathGrossini);

            CCLayer layer = CCLayerColor.layerWithColor(new ccColor4B(255, 255, 0, 255));

            addChild(layer, -1);

            addChild(sprite, 0, ClickAndMoveTest.kTagSprite);
            sprite.position = new CCPoint(20, 150);

            sprite.runAction(CCJumpTo.actionWithDuration(4, new CCPoint(300, 48), 100, 4));

            layer.runAction(CCRepeatForever.actionWithAction(
                                (CCActionInterval)(CCSequence.actions(
                                                       CCFadeIn.actionWithDuration(1),
                                                       CCFadeOut.actionWithDuration(1)))
                                ));
        }
Пример #5
0
        public SystemFontTest()
        {
            size = Layer.VisibleBoundsWorldspace.Size;

            CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            menu.Position  = CCPoint.Zero;
            item1.Position = new CCPoint(size.Width / 2 - item2.ContentSize.Width * 2, item2.ContentSize.Height / 2);
            item2.Position = new CCPoint(size.Width / 2, item2.ContentSize.Height / 2);
            item3.Position = new CCPoint(size.Width / 2 + item2.ContentSize.Width * 2, item2.ContentSize.Height / 2);
            AddChild(menu, 1);

            blockSize = new CCSize(size.Width / 3, 200);

            var leftColor   = new CCLayerColor(new CCColor4B(100, 100, 100, 255));
            var centerColor = new CCLayerColor(new CCColor4B(200, 100, 100, 255));
            var rightColor  = new CCLayerColor(new CCColor4B(100, 100, 200, 255));

            leftColor.IgnoreAnchorPointForPosition   = false;
            centerColor.IgnoreAnchorPointForPosition = false;
            rightColor.IgnoreAnchorPointForPosition  = false;

            leftColor.AnchorPoint   = CCPoint.AnchorMiddleLeft;
            centerColor.AnchorPoint = CCPoint.AnchorMiddleLeft;
            rightColor.AnchorPoint  = CCPoint.AnchorMiddleLeft;

            leftColor.Position   = new CCPoint(0, size.Height / 2);
            centerColor.Position = new CCPoint(blockSize.Width, size.Height / 2);
            rightColor.Position  = new CCPoint(blockSize.Width * 2, size.Height / 2);

            AddChild(leftColor, -1);
            AddChild(rightColor, -1);
            AddChild(centerColor, -1);

            showFont(SystemFontTestScene.restartAction());
        }
Пример #6
0
        public LabelTTFA8Test()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayerColor layer = new CCLayerColor(new CCColor4B(128, 128, 128, 255));

            AddChild(layer, -10);

            // CCLabelBMFont
            CCLabelTTF label1 = new CCLabelTTF("Testing A8 Format", "Marker Felt", 38);

            AddChild(label1);
            label1.Color    = CCTypes.CCRed;
            label1.Position = new CCPoint(s.Width / 2, s.Height / 2);

            CCFadeOut          fadeOut = new CCFadeOut(2);
            CCFadeIn           fadeIn  = new CCFadeIn(2);
            CCFiniteTimeAction seq     = CCSequence.FromActions(fadeOut, fadeIn);
            CCRepeatForever    forever = new CCRepeatForever((CCActionInterval)seq);

            label1.RunAction(forever);
        }
Пример #7
0
        public override void ApplicationDidFinishLaunching(CCApplication app, CCWindow window)
        {
            app.PreferMultiSampling  = false;
            app.ContentRootDirectory = "Content";
            app.ContentSearchPaths.Add("hd");

            CCScene      scene = new CCScene(window);
            CCLayerColor layer = new CCLayerColor();
            var          label = new CCLabel("Tap Screen To Play!", "MarkerFelt-22", 22)
            {
                Position            = layer.VisibleBoundsWorldspace.Center,
                Color               = CCColor3B.Black,
                HorizontalAlignment = CCTextAlignment.Center,
                VerticalAlignment   = CCVerticalTextAlignment.Center,
                AnchorPoint         = CCPoint.AnchorLowerLeft,
                Dimensions          = layer.ContentSize
            };

            layer.AddChild(label);
            scene.AddChild(layer);
            window.RunWithScene(scene);
        }
Пример #8
0
        public void newBlend(float dt)
        {
            CCLayerColor layer = (CCLayerColor)getChildByTag(kTagLayer);

            int src;
            int dst;

            if (layer.BlendFunc.dst == GL_ZERO)
            {
                src = 1;
                dst = 0x0303;
            }
            else
            {
                src = 0x0307;
                dst = GL_ZERO;
            }

            ccBlendFunc bf = new ccBlendFunc(src, dst);

            layer.BlendFunc = (bf);
        }
Пример #9
0
        public LabelTTFTest()
        {
            var    blockSize = new CCSize(200, 160);
            CCSize s         = CCDirector.SharedDirector.WinSize;

            CCLayerColor colorLayer = new CCLayerColor(new CCColor4B(100, 100, 100, 255), blockSize.Width, blockSize.Height);

            colorLayer.AnchorPoint = new CCPoint(0, 0);
            colorLayer.Position    = new CCPoint((s.Width - blockSize.Width) / 2, (s.Height - blockSize.Height) / 2);

            AddChild(colorLayer);

            CCMenuItemFont.FontSize = 30;
            CCMenu menu = new CCMenu(
                new CCMenuItemFont("Left", setAlignmentLeft),
                new CCMenuItemFont("Center", setAlignmentCenter),
                new CCMenuItemFont("Right", setAlignmentRight)
                );

            menu.AlignItemsVerticallyWithPadding(4);
            menu.Position = new CCPoint(50, s.Height / 2 - 20);
            AddChild(menu);

            menu = new CCMenu(
                new CCMenuItemFont("Top", setAlignmentTop),
                new CCMenuItemFont("Middle", setAlignmentMiddle),
                new CCMenuItemFont("Bottom", setAlignmentBottom)
                );
            menu.AlignItemsVerticallyWithPadding(4);
            menu.Position = new CCPoint(s.Width - 50, s.Height / 2 - 20);
            AddChild(menu);

            m_plabel      = null;
            m_eHorizAlign = CCTextAlignment.Left;
            m_eVertAlign  = CCVerticalTextAlignment.Top;

            updateAlignment();
        }
Пример #10
0
        public override bool Init()
        {
            // always call "super" init
            // Apple recommends to re-assign "self" with the "super" return value
            if (base.Init())
            {
                TouchEnabled = true;
                // ask director the the window size
                CCSize       size = CCDirector.SharedDirector.WinSize;
                CCLayerColor layer;
                for (int i = 0; i < 5; i++)
                {
                    layer             = new CCLayerColor(new CCColor4B((byte)(i * 20), (byte)(i * 20), (byte)(i * 20), 255));
                    layer.ContentSize = new CCSize(i * 100, i * 100);
                    layer.Position    = new CCPoint(size.Width / 2, size.Height / 2);
                    layer.AnchorPoint = new CCPoint(0.5f, 0.5f);
                    layer.IgnoreAnchorPointForPosition = true;
                    AddChild(layer, -1 - i);
                }

                // create and initialize a Label
                CCLabelTTF label = new CCLabelTTF("Hello World", "Marker Felt", 64);
                CCMenuItem item1 = new CCMenuItemFont("restart", restart);

                CCMenu menu = new CCMenu(item1);
                menu.AlignItemsVertically();
                menu.Position = new CCPoint(size.Width / 2, 100);
                AddChild(menu);

                // position the label on the center of the screen
                label.Position = new CCPoint(size.Width / 2, size.Height / 2);

                // add the label as a child to this Layer
                AddChild(label);
                return(true);
            }
            return(false);
        }
Пример #11
0
        public override bool init()
        {
            // always call "super" init
            // Apple recommends to re-assign "self" with the "super" return value
            if (base.init())
            {
                isTouchEnabled = true;
                // ask director the the window size
                CCSize       size = CCDirector.sharedDirector().getWinSize();
                CCLayerColor layer;
                for (int i = 0; i < 5; i++)
                {
                    layer                       = CCLayerColor.layerWithColor(new ccColor4B((byte)(i * 20), (byte)(i * 20), (byte)(i * 20), 255));
                    layer.contentSize           = new CCSize(i * 100, i * 100);
                    layer.position              = new CCPoint(size.width / 2, size.height / 2);
                    layer.anchorPoint           = new CCPoint(0.5f, 0.5f);
                    layer.isRelativeAnchorPoint = true;
                    addChild(layer, -1 - i);
                }

                // create and initialize a Label
                CCLabelTTF label = CCLabelTTF.labelWithString("Hello World", "Marker Felt", 64);
                CCMenuItem item1 = CCMenuItemFont.itemFromString("restart", this, restart);

                CCMenu menu = CCMenu.menuWithItems(item1);
                menu.alignItemsVertically();
                menu.position = new CCPoint(size.width / 2, 100);
                addChild(menu);

                // position the label on the center of the screen
                label.position = new CCPoint(size.width / 2, size.height / 2);

                // add the label as a child to this Layer
                addChild(label);
                return(true);
            }
            return(false);
        }
Пример #12
0
        public override void onEnter()
        {
            base.onEnter();

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

            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("zwoptex/grossini");
            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("zwoptex/grossini-generic");

            CCLayerColor layer1 = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(255, 0, 0, 255), 85, 121);

            layer1.position = (new CCPoint(s.width / 2 - 80 - (85.0f * 0.5f), s.height / 2 - (121.0f * 0.5f)));
            addChild(layer1);

            sprite1          = CCSprite.spriteWithSpriteFrame(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("grossini_dance_01.png"));
            sprite1.position = (new CCPoint(s.width / 2 - 80, s.height / 2));
            addChild(sprite1);

            sprite1.IsFlipX = (false);
            sprite1.IsFlipY = (false);

            CCLayerColor layer2 = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(255, 0, 0, 255), 85, 121);

            layer2.position = (new CCPoint(s.width / 2 + 80 - (85.0f * 0.5f), s.height / 2 - (121.0f * 0.5f)));
            addChild(layer2);

            sprite2          = CCSprite.spriteWithSpriteFrame(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("grossini_dance_generic_01.png"));
            sprite2.position = (new CCPoint(s.width / 2 + 80, s.height / 2));
            addChild(sprite2);

            sprite2.IsFlipX = (false);
            sprite2.IsFlipY = (false);

            schedule((startIn05Secs), 1.0f);

            counter = 0;
        }
Пример #13
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLabelTTF label = new CCLabelTTF(title(), "arial", 18);

            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);

            string strSubtitle = subtitle();

            if (strSubtitle != null)
            {
                CCLabelTTF l = new CCLabelTTF(strSubtitle, "arial", 22);
                AddChild(l, 1);
                l.Position = new CCPoint(s.Width / 2, s.Height - 80);
            }

            CCMenuItemImage item1 = new CCMenuItemImage(s_pPathB1, s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(s_pPathR1, s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(s_pPathF1, s_pPathF2, nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            menu.Position  = new CCPoint(0, 0);
            item1.Position = new CCPoint(s.Width / 2 - 100, 30);
            item2.Position = new CCPoint(s.Width / 2, 30);
            item3.Position = new CCPoint(s.Width / 2 + 100, 30);

            AddChild(menu, 1);

            CCLayerColor background = new CCLayerColor(new CCColor4B(255, 0, 0, 255));

            AddChild(background, -10);
        }
Пример #14
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("zwoptex/grossini.plist");
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("zwoptex/grossini-generic.plist");

            CCLayerColor layer1 = new CCLayerColor(new CCColor4B(255, 0, 0, 255));

            layer1.Position = new CCPoint(s.Width / 2 - 80 - (85.0f * 0.5f), s.Height / 2 - (121.0f * 0.5f));
            AddChild(layer1);

            sprite1          = new CCSprite(CCSpriteFrameCache.SharedSpriteFrameCache["grossini_dance_01.png"]);
            sprite1.Position = (new CCPoint(s.Width / 2 - 80, s.Height / 2));
            AddChild(sprite1);

            sprite1.FlipX = false;
            sprite1.FlipY = false;

            CCLayerColor layer2 = new CCLayerColor(new CCColor4B(255, 0, 0, 255));

            layer2.Position = new CCPoint(s.Width / 2 + 80 - (85.0f * 0.5f), s.Height / 2 - (121.0f * 0.5f));
            AddChild(layer2);

            sprite2          = new CCSprite(CCSpriteFrameCache.SharedSpriteFrameCache["grossini_dance_generic_01.png"]);
            sprite2.Position = (new CCPoint(s.Width / 2 + 80, s.Height / 2));
            AddChild(sprite2);

            sprite2.FlipX = false;
            sprite2.FlipY = false;

            Schedule(startIn05Secs, 1.0f);

            counter = 0;
        }
Пример #15
0
        public override void OnEnter()
        {
            base.OnEnter();

            var listener = new CCEventListenerTouchAllAtOnce();

            listener.OnTouchesBegan = onTouchesBegan;
            listener.OnTouchesMoved = onTouchesMoved;
            listener.OnTouchesEnded = onTouchesEnded;

            AddEventListener(listener);

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLayerColor layer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80));

            layer.IgnoreAnchorPointForPosition = false;
            layer.Position = s.Center / 2;

            layer.ScaleX = (s.Width / 2) / s.Width;
            layer.ScaleY = (s.Height / 2) / s.Height;

            AddChild(layer, 1, kTagLayer);
        }
Пример #16
0
 public ModalLayer() : base()
 {
     layer = new CCLayerColor(new CCColor4B(0x11, 0x11, 0x11, 0x80));
 }
Пример #17
0
        //---------------------------------------------------------------------------------------------------------
        // NewGame - Used in menu selection
        //---------------------------------------------------------------------------------------------------------
        // Transitions to LevelLayer
        //---------------------------------------------------------------------------------------------------------
        void NewGame(object stuff = null)
        {
            if (currentPlayer.BranchProgression[1].LastLevelCompleted > -1)
            {
                //if (currentPlayer.LastLevelCompleted > -1) {
                CCRect bounds = VisibleBoundsWorldspace;

                PauseListeners(true);
                Application.Paused = true;

                var newGameLayer = new CCLayerColor(new CCColor4B(0, 0, 0, 230));
                AddChild(newGameLayer, 99999);

                // Add frame to layer
                frameSprite             = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("frame.png")));
                frameSprite.AnchorPoint = CCPoint.AnchorMiddle;
                frameSprite.Position    = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2);
                newGameLayer.AddChild(frameSprite);

                newGameWarning                     = new CCLabel("This will erase your current progress!\n\n\nProceed?", GOTHIC_56_WHITE_FNT);
                newGameWarning.AnchorPoint         = CCPoint.AnchorMiddle;
                newGameWarning.Scale               = 1.5f;
                newGameWarning.Position            = new CCPoint(frameSprite.BoundingBox.Center);
                newGameWarning.HorizontalAlignment = CCTextAlignment.Center;
                newGameLayer.AddChild(newGameWarning);

                okLabel             = new CCLabel("OK", GOTHIC_44_HD_FNT);
                okLabel.AnchorPoint = CCPoint.AnchorMiddle;
                okLabel.Scale       = 1.5f;

                cancelLabel             = new CCLabel("Cancel", GOTHIC_44_HD_FNT);
                cancelLabel.AnchorPoint = CCPoint.AnchorMiddle;
                cancelLabel.Scale       = 1.5f;

                var okItem = new CCMenuItemLabel(okLabel, okSender => {
                    newGameLayer.RemoveFromParent();
                    ResumeListeners(true);
                    Application.Paused = false;

                    currentPlayer = new Player();
                    currentPlayer.WriteData(currentPlayer);

                    var mainGame         = LevelLayer.CreateScene(Window, levels, currentPlayer);
                    var transitionToGame = new CCTransitionFade(2.0f, mainGame);
                    Director.ReplaceScene(transitionToGame);
                });
                okItem.Position = bounds.Center;

                var cancelItem = new CCMenuItemLabel(cancelLabel, cancelSender => {
                    newGameLayer.RemoveFromParent();
                    ResumeListeners(true);
                    Application.Paused = false;
                });
                cancelItem.Position = bounds.Center;

                var closeMenu = new CCMenu(okItem, cancelItem);
                closeMenu.AlignItemsHorizontally(50);
                closeMenu.AnchorPoint = CCPoint.AnchorMiddleBottom;
                closeMenu.Position    = new CCPoint(bounds.Size.Width / 2, frameSprite.BoundingBox.MinY + (okLabel.BoundingBox.Size.Height * 2.5f));

                newGameLayer.AddChild(closeMenu);
            }
            else
            {
                var mainGame         = LevelLayer.CreateScene(Window, levels, currentPlayer);
                var transitionToGame = new CCTransitionFade(2.0f, mainGame);
                Director.ReplaceScene(transitionToGame);
            }
        }
Пример #18
0
        public override void OnEnter()
        {
            base.OnEnter();

            // create a transparent color layer
            // in which we are going to add our rendertextures
            var          color = new CCColor4B(0, 0, 0, 0);
            CCSize       size  = CCDirector.SharedDirector.WinSize;
            CCLayerColor layer = new CCLayerColor(color);

            // create the first render texture for inScene
            CCRenderTexture inTexture = new CCRenderTexture((int)size.Width, (int)size.Height);

            if (null == inTexture)
            {
                return;
            }

            inTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f);
            inTexture.Position           = new CCPoint(size.Width / 2, size.Height / 2);
            inTexture.AnchorPoint        = new CCPoint(0.5f, 0.5f);

            //  render inScene to its texturebuffer
            inTexture.Begin();
            m_pInScene.Visit();
            inTexture.End();

            // create the second render texture for outScene
            CCRenderTexture outTexture = new CCRenderTexture((int)size.Width, (int)size.Height);

            outTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f);
            outTexture.Position           = new CCPoint(size.Width / 2, size.Height / 2);
            outTexture.AnchorPoint        = new CCPoint(0.5f, 0.5f);

            //  render outScene to its texturebuffer
            outTexture.Begin();
            m_pOutScene.Visit();
            outTexture.End();

            // create blend functions

            var blend1 = new CCBlendFunc(CCOGLES.GL_ONE, CCOGLES.GL_ONE);                                          // inScene will lay on background and will not be used with alpha
            var blend2 = new CCBlendFunc(CCMacros.CCDefaultSourceBlending, CCMacros.CCDefaultDestinationBlending); // OGLES.GL_SRC_ALPHA, OGLES.GL_ONE_MINUS_SRC_ALPHA); // we are going to blend outScene via alpha

            // set blendfunctions
            inTexture.Sprite.BlendFunc  = blend1;
            outTexture.Sprite.BlendFunc = blend2;

            // add render textures to the layer
            layer.AddChild(inTexture);
            layer.AddChild(outTexture);

            // initial opacity:
            inTexture.Sprite.Opacity  = 255;
            outTexture.Sprite.Opacity = 255;

            // create the blend action
            CCAction layerAction = CCSequence.FromActions
                                   (
                new CCFadeTo(m_fDuration, 0),
                new CCCallFunc((HideOutShowIn)),
                new CCCallFunc((Finish))
                                   );


            //// run the blend action
            outTexture.Sprite.RunAction(layerAction);

            // add the layer (which contains our two rendertextures) to the scene
            AddChild(layer, 2, kSceneFade);
        }
Пример #19
0
        //---------------------------------------------------------------------------------------------------------
        // PlayerDelete
        //---------------------------------------------------------------------------------------------------------
        // Deletes player information
        //---------------------------------------------------------------------------------------------------------
        void PlayerDelete(object stuff)
        {
            PauseListeners(true);
            Application.Paused = true;

            var playerResetLayer = new CCLayerColor(new CCColor4B(0, 0, 0, 230));

            AddChild(playerResetLayer, 99999);

            // Add frame to layer
            var frameSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("frame.png")));

            frameSprite.AnchorPoint = CCPoint.AnchorMiddle;
            frameSprite.Position    = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2);
            playerResetLayer.AddChild(frameSprite);

            string playerName       = string.Empty;
            var    sentMenuItem     = (CCMenuItemImage)stuff;
            var    playerSlotString = sentMenuItem.UserData.ToString();

            if (playerSlotString == "Slot1")
            {
                playerName = player1.Name;
            }
            else if (playerSlotString == "Slot2")
            {
                playerName = player1.Name;
            }
            else if (playerSlotString == "Slot3")
            {
                playerName = player1.Name;
            }

            var playerNameLabel = new CCLabel(playerName, GOTHIC_56_WHITE_HD_FNT);

            playerNameLabel.AnchorPoint         = CCPoint.AnchorMiddle;
            playerNameLabel.Scale               = 2;
            playerNameLabel.PositionX           = frameSprite.BoundingBox.Center.X;
            playerNameLabel.PositionY           = frameSprite.BoundingBox.MaxY - 200;
            playerNameLabel.HorizontalAlignment = CCTextAlignment.Center;
            playerResetLayer.AddChild(playerNameLabel);

            var newGameWarning = new CCLabel("This will erase your current progress!\n\n\nProceed?", GOTHIC_56_WHITE_FNT);

            newGameWarning.AnchorPoint         = CCPoint.AnchorMiddle;
            newGameWarning.Scale               = 1.5f;
            newGameWarning.Position            = new CCPoint(frameSprite.BoundingBox.Center);
            newGameWarning.HorizontalAlignment = CCTextAlignment.Center;
            playerResetLayer.AddChild(newGameWarning);

            var okLabel = new CCLabel("OK", GOTHIC_44_HD_FNT);

            okLabel.AnchorPoint = CCPoint.AnchorMiddle;
            okLabel.Scale       = 1.5f;

            var cancelLabel = new CCLabel("Cancel", GOTHIC_44_HD_FNT);

            cancelLabel.AnchorPoint = CCPoint.AnchorMiddle;
            cancelLabel.Scale       = 1.5f;

            var okItem = new CCMenuItemLabel(okLabel, okSender => {
                playerResetLayer.RemoveFromParent();
                ResumeListeners(true);
                Application.Paused = false;

                if (playerSlotString == "Slot1")
                {
                    player1 = new Player(PlayerSlot.slot1);
                    player1.WriteData(player1);
                }
                else if (playerSlotString == "Slot2")
                {
                    player2 = new Player(PlayerSlot.slot2);
                    player2.WriteData(player2);
                }
                else if (playerSlotString == "Slot3")
                {
                    player3 = new Player(PlayerSlot.slot3);
                    player3.WriteData(player3);
                }

                UpdateUI();
            });

            okItem.Position = bounds.Center;

            var cancelItem = new CCMenuItemLabel(cancelLabel, cancelSender => {
                playerResetLayer.RemoveFromParent();
                ResumeListeners(true);
                Application.Paused = false;
            });

            cancelItem.Position = bounds.Center;

            var closeMenu = new CCMenu(okItem, cancelItem);

            closeMenu.AlignItemsHorizontally(50);
            closeMenu.AnchorPoint = CCPoint.AnchorMiddleBottom;
            closeMenu.Position    = new CCPoint(bounds.Size.Width / 2, frameSprite.BoundingBox.MinY + (okLabel.BoundingBox.Size.Height * 2.5f));

            playerResetLayer.AddChild(closeMenu);
        }
Пример #20
0
        //---------------------------------------------------------------------------------------------------------
        // PlayerInfo
        //---------------------------------------------------------------------------------------------------------
        // Displays the player information popup
        // TODO: modify the information shown to match player class attributes
        //---------------------------------------------------------------------------------------------------------
        void PlayerInfo(object stuff)
        {
            Player currentPlayer;
            var    sentMenuItem     = (CCMenuItemImage)stuff;
            var    playerSlotString = sentMenuItem.UserData.ToString();

            if (playerSlotString == "Slot1")
            {
                currentPlayer = player1;
            }
            else if (playerSlotString == "Slot2")
            {
                currentPlayer = player2;
            }
            else if (playerSlotString == "Slot3")
            {
                currentPlayer = player3;
            }

            PauseListeners(true);
            Application.Paused = true;

            var playerStatsLayer = new CCLayerColor(new CCColor4B(0, 0, 0, 230));

            AddChild(playerStatsLayer, 99999);

            // Add frame to layer
            var frameSprite = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("frame.png")));

            frameSprite.AnchorPoint = CCPoint.AnchorMiddle;
            frameSprite.Position    = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2);
            frameSprite.ScaleY      = 1.3f;
            playerStatsLayer.AddChild(frameSprite);

            var titleLabel = new CCLabel("Player Stats", GOTHIC_56_WHITE_HD_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1f
            };
            var titleMenuItem   = new CCMenuItemLabel(titleLabel);
            var playerNameLabel = new CCLabel(string.Format("Player Name: {0}", currentPlayer.Name), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var playerNameMenuItem = new CCMenuItemLabel(playerNameLabel);
            //var lastLevelLabel = new CCLabel ((currentPlayer.LastLevelCompleted == -1) ?  "Last Level Completed: Not Started Yet" : string.Format ("Last Level Completed: {0}", currentPlayer.LastLevelCompleted), GOTHIC_56_WHITE_FNT) {
            // TODO: instead of last level competed, change to report next level to be played
            var lastLevelLabel = new CCLabel((currentPlayer.BranchProgression[1].BranchState == CompletionState.notStarted) ?  "Last Level Completed: Not Started Yet" : string.Format("Last Level Completed: {0}", currentPlayer.BranchProgression[1].LastLevelCompleted), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var lastLevelMenuItem = new CCMenuItemLabel(lastLevelLabel);
            var coinsLabel        = new CCLabel(string.Format("Coins: {0}", currentPlayer.Coins), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var coinsMenuItem  = new CCMenuItemLabel(coinsLabel);
            var highScoreLabel = new CCLabel(string.Format("High Score: {0}", currentPlayer.TotalScores), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var highScoreMenuItem = new CCMenuItemLabel(highScoreLabel);
            var tapStrengthLabel  = new CCLabel(string.Format("Tap Strength: {0}", currentPlayer.PersistentTapStrength), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var tapStrengthMenuItem       = new CCMenuItemLabel(tapStrengthLabel);
            var percentChanceNextSeqLabel = new CCLabel(string.Format("Next in Sequence Luck: {0}%", currentPlayer.ChanceToRollNextSeq), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var percentChanceNextSeqMenuItem = new CCMenuItemLabel(percentChanceNextSeqLabel);
            var percentChanceBonusLabel      = new CCLabel(string.Format("Bonus Bubble Luck: {0}%", currentPlayer.ChanceToRollBonus), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var percentChanceBonusMenuItem = new CCMenuItemLabel(percentChanceBonusLabel);

            var timeBonusLabel = new CCLabel(string.Format("Additional Level Time: {0} Seconds", currentPlayer.PersistentTimeBonus), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var timeBonusMenuItem = new CCMenuItemLabel(timeBonusLabel);

            var time2xBonusLabel = new CCLabel(string.Format("2x Bonus Timer Extra: {0} Seconds", currentPlayer.Persistent2xTimeBonus), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var time2xBonusMenuItem = new CCMenuItemLabel(time2xBonusLabel);

            var time3xBonusLabel = new CCLabel(string.Format("3x Bonus Timer Extra: {0} Seconds", currentPlayer.Persistent3xTimeBonus), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var time3xBonusMenuItem = new CCMenuItemLabel(time3xBonusLabel);

            var highlightNextAvailableLabel = new CCLabel("Highlight Next Sequence Bubble: " + ((currentPlayer.HighlightNextPurchased) ? "Yes" : "No"), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = Scale = 1.0f
            };
            var highlightNextMenuItem = new CCMenuItemLabel(highlightNextAvailableLabel);

            var okButtonLabel = new CCLabel("OK", GOTHIC_30_HD_FNT)
            {
                AnchorPoint = AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 2.0f
            };
            var okButtonMenuItem = new CCMenuItemLabel(okButtonLabel, okSender => {
                playerStatsLayer.RemoveFromParent();
                ResumeListeners(true);
                Application.Paused = false;
            });

            var playerStatsMenu = new CCMenu(titleMenuItem, playerNameMenuItem, lastLevelMenuItem, coinsMenuItem, highScoreMenuItem, tapStrengthMenuItem, percentChanceNextSeqMenuItem, percentChanceBonusMenuItem,
                                             timeBonusMenuItem, time2xBonusMenuItem, time3xBonusMenuItem, highlightNextMenuItem, okButtonMenuItem);

            playerStatsMenu.AnchorPoint = CCPoint.AnchorMiddle;
            playerStatsMenu.Position    = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2);
            playerStatsMenu.AlignItemsVertically(40);

            playerStatsLayer.AddChild(playerStatsMenu);
        }
Пример #21
0
        //---------------------------------------------------------------------------------------------------------
        // PlayerStats
        //---------------------------------------------------------------------------------------------------------
        // Show player information summary in a popup
        //---------------------------------------------------------------------------------------------------------
        void PlayerStats(object stuff = null)
        {
            CCRect bounds = VisibleBoundsWorldspace;

            PauseListeners(true);
            Application.Paused = true;

            var playerStatsLayer = new CCLayerColor(new CCColor4B(0, 0, 0, 230));

            AddChild(playerStatsLayer, 99999);

            // Add frame to layer
            frameSprite             = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("frame.png")));
            frameSprite.AnchorPoint = CCPoint.AnchorMiddle;
            frameSprite.Position    = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2);
            frameSprite.ScaleY      = 1.3f;
            playerStatsLayer.AddChild(frameSprite);

            var titleLabel = new CCLabel("Player Stats", GOTHIC_56_WHITE_HD_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1f
            };
            var titleMenuItem   = new CCMenuItemLabel(titleLabel);
            var playerNameLabel = new CCLabel(string.Format("Player Name: {0}", currentPlayer.Name), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var playerNameMenuItem = new CCMenuItemLabel(playerNameLabel);
            //var lastLevelLabel = new CCLabel (string.Format ("Last Level Completed: {0}", currentPlayer.LastLevelCompleted), GOTHIC_56_WHITE_FNT) {
            var lastLevelLabel = new CCLabel(string.Format("Last Level Completed: {0}", currentPlayer.BranchProgression[1].LastLevelCompleted), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var lastLevelMenuItem = new CCMenuItemLabel(lastLevelLabel);
            var coinsLabel        = new CCLabel(string.Format("Coins: {0}", currentPlayer.Coins), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var coinsMenuItem  = new CCMenuItemLabel(coinsLabel);
            var highScoreLabel = new CCLabel(string.Format("High Score: {0}", currentPlayer.TotalScores), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var highScoreMenuItem = new CCMenuItemLabel(highScoreLabel);
            var tapStrengthLabel  = new CCLabel(string.Format("Tap Strength: {0}", currentPlayer.PersistentTapStrength), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var tapStrengthMenuItem       = new CCMenuItemLabel(tapStrengthLabel);
            var percentChanceNextSeqLabel = new CCLabel(string.Format("Next in Sequence Luck: {0}%", currentPlayer.ChanceToRollNextSeq), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var percentChanceNextSeqMenuItem = new CCMenuItemLabel(percentChanceNextSeqLabel);
            var percentChanceBonusLabel      = new CCLabel(string.Format("Bonus Bubble Luck: {0}%", currentPlayer.ChanceToRollBonus), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var percentChanceBonusMenuItem = new CCMenuItemLabel(percentChanceBonusLabel);

            var timeBonusLabel = new CCLabel(string.Format("Additional Level Time: {0} Seconds", currentPlayer.PersistentTimeBonus), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var timeBonusMenuItem = new CCMenuItemLabel(timeBonusLabel);

            var time2xBonusLabel = new CCLabel(string.Format("2x Bonus Timer Extra: {0} Seconds", currentPlayer.Persistent2xTimeBonus), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var time2xBonusMenuItem = new CCMenuItemLabel(time2xBonusLabel);

            var time3xBonusLabel = new CCLabel(string.Format("3x Bonus Timer Extra: {0} Seconds", currentPlayer.Persistent3xTimeBonus), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 1.0f
            };
            var time3xBonusMenuItem = new CCMenuItemLabel(time3xBonusLabel);

            var highlightNextAvailableLabel = new CCLabel("Highlight Next Sequence Bubble: " + ((currentPlayer.HighlightNextPurchased) ? "Yes" : "No"), GOTHIC_56_WHITE_FNT)
            {
                AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = Scale = 1.0f
            };
            var highlightNextMenuItem = new CCMenuItemLabel(highlightNextAvailableLabel);

            var okButtonLabel = new CCLabel("OK", GOTHIC_30_HD_FNT)
            {
                AnchorPoint = AnchorPoint = CCPoint.AnchorMiddle,
                Scale       = 2.0f
            };
            var okButtonMenuItem = new CCMenuItemLabel(okButtonLabel, okSender => {
                playerStatsLayer.RemoveFromParent();
                ResumeListeners(true);
                Application.Paused = false;
            });

            var playerStatsMenu = new CCMenu(titleMenuItem, playerNameMenuItem, lastLevelMenuItem, coinsMenuItem, highScoreMenuItem, tapStrengthMenuItem, percentChanceNextSeqMenuItem, percentChanceBonusMenuItem,
                                             timeBonusMenuItem, time2xBonusMenuItem, time3xBonusMenuItem, highlightNextMenuItem, okButtonMenuItem);

            playerStatsMenu.AnchorPoint = CCPoint.AnchorMiddle;
            playerStatsMenu.Position    = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2);
            playerStatsMenu.AlignItemsVertically(40);

            playerStatsLayer.AddChild(playerStatsMenu);
        }
Пример #22
0
 public DisplayTerrain(Dictionary <int, string> spriteKey, int[,] terrainMap, CCLayerColor layer)
     : this(spriteKey, terrainMap)
 {
 }
Пример #23
0
        public override void OnEnter()
        {
            base.OnEnter();

            // create a transparent color layer
            // in which we are going to add our rendertextures
            var color = new CCColor4B(0, 0, 0, 0);
            CCSize size = CCDirector.SharedDirector.WinSize;
            CCLayerColor layer = new CCLayerColor(color);

            // create the first render texture for inScene
            CCRenderTexture inTexture = new CCRenderTexture((int) size.Width, (int) size.Height);

            if (null == inTexture)
            {
                return;
            }

            inTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f);
            inTexture.Position = new CCPoint(size.Width / 2, size.Height / 2);
            inTexture.AnchorPoint = new CCPoint(0.5f, 0.5f);

            //  render inScene to its texturebuffer
            inTexture.Begin();
            m_pInScene.Visit();
            inTexture.End();

            // create the second render texture for outScene
            CCRenderTexture outTexture = new CCRenderTexture((int) size.Width, (int) size.Height);
            outTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f);
            outTexture.Position = new CCPoint(size.Width / 2, size.Height / 2);
            outTexture.AnchorPoint = new CCPoint(0.5f, 0.5f);

            //  render outScene to its texturebuffer
            outTexture.Begin();
            m_pOutScene.Visit();
            outTexture.End();

            // create blend functions

            var blend1 = new CCBlendFunc(CCOGLES.GL_ONE, CCOGLES.GL_ONE); // inScene will lay on background and will not be used with alpha
            var blend2 = CCBlendFunc.NonPremultiplied; // we are going to blend outScene via alpha 

            // set blendfunctions
            inTexture.Sprite.BlendFunc = blend1;
            outTexture.Sprite.BlendFunc = blend2;

            // add render textures to the layer
            layer.AddChild(inTexture);
            layer.AddChild(outTexture);

            // initial opacity:
            inTexture.Sprite.Opacity = 255;
            outTexture.Sprite.Opacity = 255;

            // create the blend action
            CCAction layerAction = CCSequence.FromActions
                (
                    new CCFadeTo (m_fDuration, 0),
                    new CCCallFunc((HideOutShowIn)),
                    new CCCallFunc((Finish))
                );


            //// run the blend action
            outTexture.Sprite.RunAction(layerAction);

            // add the layer (which contains our two rendertextures) to the scene
            AddChild(layer, 2, kSceneFade);
        }
Пример #24
0
        //---------------------------------------------------------------------------------------------------------
        // AddedToScene
        //---------------------------------------------------------------------------------------------------------
        //
        protected override void AddedToScene()
        {
            base.AddedToScene();

            // Use the bounds to layout the positioning of our drawable assets
            CCRect bounds = VisibleBoundsWorldspace;

            Bubbles = new CCNode();
            AddChild(Bubbles);

            //initialize every bool in BubbleArray to false.  True if there is a bubble there.
            for (int i = 0; i < MAX_BUBBLES_X; i++)
            {
                BubbleOccupiedArray [i] = false;
            }

            branches = ReadBranches(branchInfo);
            levels   = ReadLevels(levelInfo);

            currentPlayer = new Player();


            if (File.Exists(currentPlayer.PlayerDataFile))
            {
                currentPlayer = Player.ReadData(currentPlayer);
            }
            else
            {
                currentPlayer.WriteData(currentPlayer);
            }

            // options popup
            optionsStd             = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("gear_std.png")));
            optionsStd.AnchorPoint = CCPoint.AnchorMiddle;
            optionsSel             = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("gear_sel.png")));
            optionsSel.AnchorPoint = CCPoint.AnchorMiddle;

            var optionPopup = new CCMenuItemImage(optionsStd, optionsSel, sender => {
                PauseListeners(true);
                Application.Paused = true;

                var optionsLayer = new CCLayerColor(new CCColor4B(0, 0, 0, 200));
                AddChild(optionsLayer, 99999);

                // Add frame to layer
                frameSprite             = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("frame.png")));
                frameSprite.AnchorPoint = CCPoint.AnchorMiddle;
                frameSprite.Position    = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2);
                optionsLayer.AddChild(frameSprite);

                var highlightOnLabel = new CCLabel("Highlight Next: On", GOTHIC_56_WHITE_FNT)
                {
                    AnchorPoint = CCPoint.AnchorMiddle,
                    Scale       = 2.0f
                };
                var highlightOffLabel = new CCLabel("Highlight Next: Off", GOTHIC_56_WHITE_FNT)
                {
                    AnchorPoint = CCPoint.AnchorMiddle,
                    Scale       = 2.0f
                };

                var highlightOnMenuItem  = new CCMenuItemLabel(highlightOnLabel);
                var highlightOffMenuItem = new CCMenuItemLabel(highlightOffLabel);

                highlightToggleMenuItem               = new CCMenuItemToggle(ToggleHighlight, highlightOnMenuItem, highlightOffMenuItem);
                highlightToggleMenuItem.Enabled       = currentPlayer.HighlightNextPurchased;
                highlightToggleMenuItem.PositionX     = frameSprite.BoundingBox.MidX;
                highlightToggleMenuItem.PositionY     = frameSprite.BoundingBox.MinY + (highlightToggleMenuItem.BoundingBox.Size.Height * 10f);
                highlightToggleMenuItem.SelectedIndex = (currentPlayer.IsHighlightNextActive) ? 0 : 1;

                var optionMenu         = new CCMenu(highlightToggleMenuItem);
                optionMenu.AnchorPoint = CCPoint.AnchorMiddleBottom;
                optionMenu.Position    = CCPoint.Zero;
                optionsLayer.AddChild(optionMenu);

                okLabel             = new CCLabel("OK", GOTHIC_44_HD_FNT);
                okLabel.AnchorPoint = CCPoint.AnchorMiddle;
                okLabel.Scale       = 2.0f;

                var closeItem = new CCMenuItemLabel(okLabel, closeSender => {
                    optionsLayer.RemoveFromParent();
                    ResumeListeners(true);
                    Application.Paused = false;
                });

                closeItem.PositionX = frameSprite.BoundingBox.MidX;
                closeItem.PositionY = frameSprite.BoundingBox.MinY + (closeItem.BoundingBox.Size.Height * 1.5f);

                var closeMenu         = new CCMenu(closeItem);
                closeMenu.AnchorPoint = CCPoint.AnchorMiddleBottom;
                closeMenu.Position    = CCPoint.Zero;

                optionsLayer.AddChild(closeMenu);
            });

            optionPopup.AnchorPoint = CCPoint.AnchorMiddle;
            optionPopup.Position    = new CCPoint(bounds.Size.Width / 10, bounds.Size.Height / 14);

            var optionItemsMenu = new CCMenu(optionPopup);

            optionItemsMenu.AnchorPoint = CCPoint.AnchorLowerLeft;
            optionItemsMenu.Position    = CCPoint.Zero;

            AddChild(optionItemsMenu);

            //---------------------------------------------------------------------------------------------------------
            //Menu Elements
            //---------------------------------------------------------------------------------------------------------

            newGameLabel             = new CCLabel("New Game", GOTHIC_44_HD_FNT);
            newGameLabel.AnchorPoint = CCPoint.AnchorMiddle;
            newGameLabel.Scale       = 2.0f;
            var menuItemNewGame = new CCMenuItemLabel(newGameLabel, NewGame);

            continueGameLabel             = new CCLabel("Continue", GOTHIC_44_HD_FNT);
            continueGameLabel.AnchorPoint = CCPoint.AnchorMiddle;
            continueGameLabel.Scale       = 2.0f;
            var menuItemContinueGame = new CCMenuItemLabel(continueGameLabel, ContinueGame);

            playerStatsLabel             = new CCLabel("Player Stats", GOTHIC_44_HD_FNT);
            playerStatsLabel.AnchorPoint = CCPoint.AnchorMiddle;
            playerStatsLabel.Scale       = 2.0f;
            var menuItemPlayerStats = new CCMenuItemLabel(playerStatsLabel, PlayerStats);

            shopLabel             = new CCLabel("Shop", GOTHIC_44_HD_FNT);
            shopLabel.AnchorPoint = CCPoint.AnchorMiddle;
            shopLabel.Scale       = 2.0f;
            var menuItemShop = new CCMenuItemLabel(shopLabel, Shop);

            var menu = new CCMenu(menuItemNewGame, menuItemContinueGame, menuItemPlayerStats, menuItemShop)
            {
                Position    = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2),
                AnchorPoint = CCPoint.AnchorMiddle
            };

            menu.AlignItemsVertically(150);

            AddChild(menu);

            rtLogo             = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("bb_retrotek.png")));
            rtLogo.AnchorPoint = CCPoint.AnchorMiddle;
            rtLogo.Position    = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 14);
            //rtLogo.RunAction (repeatedAction);
            AddChild(rtLogo);

            title             = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("bb_title.png")));
            title.AnchorPoint = CCPoint.AnchorMiddle;
            title.Position    = new CCPoint(bounds.Size.Width / 2, (bounds.Size.Height / 7) * 6);
            title.RunAction(repeatedAction);
            AddChild(title);

            //if (currentPlayer.LastLevelCompleted < 0) {
            if (currentPlayer.BranchProgression[1].LastLevelCompleted < 0)
            {
                menuItemNewGame.Enabled      = true;
                menuItemContinueGame.Enabled = false;
                menuItemPlayerStats.Enabled  = false;
            }
            else
            {
                menuItemNewGame.Enabled      = true;
                menuItemContinueGame.Enabled = true;
                menuItemPlayerStats.Enabled  = true;
            }

            Schedule(_ => CheckForFadedBubbles());
        }
Пример #25
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCRect visibleBounds = VisibleBoundsWorldspace;
            var    origin        = Layer.VisibleBoundsWorldspace.Origin;
            var    size          = Layer.VisibleBoundsWorldspace.Size;

            var sprite1 = new TouchableSprite();
            var texture = CCTextureCache.SharedTextureCache.AddImage("Images/CyanSquare.png");

            sprite1.Texture  = texture;
            sprite1.Position = origin + new CCPoint(size.Width / 2, size.Height / 2) + new CCPoint(-80, 80);
            AddChild(sprite1, -10);

            var sprite2 = new TouchableSprite();

            texture          = CCTextureCache.SharedTextureCache.AddImage("Images/MagentaSquare.png");
            sprite2.Texture  = texture;
            sprite2.Position = origin + new CCPoint(size.Width / 2, size.Height / 2);
            AddChild(sprite2, -20);

            var sprite3 = new TouchableSprite();

            texture          = CCTextureCache.SharedTextureCache.AddImage("Images/YellowSquare.png");
            sprite3.Texture  = texture;
            sprite3.Position = CCPoint.Zero;
            sprite2.AddChild(sprite3, -1);

            CCMenuItemFont.FontSize = 20;
            CCMenuItemFont.FontName = "arial";

            var popup = new CCMenuItemFont("Popup", (sender) =>
            {
                this.PauseListeners(true);

                var colorLayer = new CCLayerColor(new CCColor4B(0, 0, 255, 100));
                AddChild(colorLayer, 99999);

                var closeItem = new CCMenuItemFont("close", (closeSender) =>
                {
                    colorLayer.RemoveFromParent();
                    this.ResumeListeners(true);
                });

                closeItem.Position = visibleBounds.Center;

                var closeMenu         = new CCMenu(closeItem);
                closeMenu.AnchorPoint = CCPoint.AnchorLowerLeft;
                closeMenu.Position    = CCPoint.Zero;

                colorLayer.AddChild(closeMenu);
            });

            popup.AnchorPoint = CCPoint.AnchorMiddleRight;
            popup.Position    = new CCPoint(visibleBounds.Origin.X + visibleBounds.Size.Width,
                                            visibleBounds.Origin.Y + visibleBounds.Size.Height / 2);

            var menu = new CCMenu(popup);

            menu.AnchorPoint = CCPoint.AnchorLowerLeft;
            menu.Position    = CCPoint.Zero;

            AddChild(menu);
        }
Пример #26
0
        public EndScene(CCWindow mainWindow) : base(mainWindow)
        {
            CCLayerColor layer = new CCLayerColor(CCColor4B.Aquamarine);

            this.AddChild(layer);
        }