Example #1
0
        public GameOverLayer(int score)
        {
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesEnded = (touches, ccevent) => CCDirector.SharedDirector.ReplaceScene(GameLayer.Scene);

            EventDispatcher.AddEventListener(touchListener, this);

            string scoreMessage = String.Format("Game Over. You collected {0} bananas!", score);

            var scoreLabel = new CCLabelTtf(scoreMessage, "MarkerFelt", 22)
            {
                Position            = new CCPoint(CCDirector.SharedDirector.WinSize.Center.X, CCDirector.SharedDirector.WinSize.Center.Y + 50),
                Color               = new CCColor3B(CCColor4B.Yellow),
                HorizontalAlignment = CCTextAlignment.Center,
                VerticalAlignment   = CCVerticalTextAlignment.Center,
                Dimensions          = ContentSize
            };

            AddChild(scoreLabel);

            var playAgainLabel = new CCLabelTtf("Tap to Play Again", "MarkerFelt", 22)
            {
                Position            = CCDirector.SharedDirector.WinSize.Center,
                Color               = new CCColor3B(CCColor4B.Green),
                HorizontalAlignment = CCTextAlignment.Center,
                VerticalAlignment   = CCVerticalTextAlignment.Center,
                Dimensions          = ContentSize
            };

            AddChild(playAgainLabel);

            Color   = new CCColor3B(CCColor4B.Black);
            Opacity = 255;
        }
Example #2
0
 public AlignmentPanel(CCSize size, CCColor4B color)
 {
     Color   = new CCColor3B(color);
     Opacity = color.A;
     //AnchorPoint = CCPoint.AnchorMiddle;
     ContentSize = size;
 }
Example #3
0
        public GameOverLayer(int redScore, int blueScore)
        {
            Color   = new CCColor3B(CCColor4B.Black);
            Opacity = 255;

            _redScore  = redScore + 1;
            _blueScore = blueScore;

            if (_redScore > _blueScore)
            {
                _winningString = "RED TEAM WINS!";
            }
            else if (_blueScore > _redScore)
            {
                _winningString = "BLUE TEAM WINS!";
            }
            else
            {
                _winningString = "IT'S A TIE!";
            }

            _redString  = String.Format("Red Team: {0}", _redScore);
            _blueString = String.Format("Blue Team: {0}", _blueScore);

            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesEnded = HandleTouchEnded;
            AddEventListener(touchListener, this);
        }
Example #4
0
        void ExplodeBalloon()
        {
            CCSequence explosionSequence;
            CCColor4B  explosionColor = new CCColor4B(byte.Parse(balloonColor.Split(',')[0]), byte.Parse(balloonColor.Split(',')[1]),
                                                      byte.Parse(balloonColor.Split(',')[2]), 255);

            explosionSequence = new CCSequence(new CCScaleTo(0.6f, 100),
                                               new CCCallFunc(() => Color = new CCColor3B(explosionColor)),
                                               new CCCallFunc(() => UpdateColor()),
                                               new CCCallFunc(() =>
            {
                AddBalloon();
                ResetStopwatch();

                explosionSprite.Visible = false;

                explosionSprite.RunAction(new CCScaleTo(0.1f, 1));
            }));

            explosionSprite.Color    = new CCColor3B(explosionColor);
            explosionSprite.Position = balloonSprite.Position;
            explosionSprite.Visible  = true;

            explosionSprite.UpdateColor();
            philipsHue.SetBulbColor(int.Parse(explosionColor.R.ToString()), int.Parse(explosionColor.G.ToString()),
                                    int.Parse(explosionColor.B.ToString()));
            StopBackgroundMusic();
            ControlSound(false, BALLOON_POP_SOUND_FILE, "Play", SOUND_EFFECT_VOLUME);
            RemoveBalloon();

            explosionSprite.RunAction(explosionSequence);
        }
Example #5
0
        public GameTutorialLayer(bool startGameAfter) : base()
        {
            titleMessage = "How to play: Part {0} of " + tutorials.Length;

            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesEnded = (touches, ccevent) => {
                currentTutorial++;
                if (currentTutorial >= tutorials.Length)
                {
                    if (startGameAfter)
                    {
                        var mainGame             = GameMainLayer.CreateScene(Window);
                        var transitionToGameOver = new CCTransitionMoveInR(0.3f, mainGame);

                        Director.ReplaceScene(transitionToGameOver);
                    }
                    else
                    {
                        var mainGame             = GameStartLayer.CreateScene(Window);
                        var transitionToGameOver = new CCTransitionMoveInL(0.3f, mainGame);

                        Director.ReplaceScene(transitionToGameOver);
                    }
                }
                else
                {
                    SetCurrentMessages();
                }
            };

            AddEventListener(touchListener, this);
            Color   = new CCColor3B(127, 200, 205);
            Opacity = 255;
        }
Example #6
0
 public Background(CCSize size, CCColor4B color)
 {
     Color       = new CCColor3B(color);
     Opacity     = color.A;
     AnchorPoint = CCPoint.AnchorMiddle;
     ContentSize = size;
 }
        public GameLayer()
        {
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesEnded = OnTouchesEnded;

            Color   = new CCColor3B(CCColor4B.White);
            Opacity = 255;

            // batch node for physics balls
            ballsBatch  = new CCSpriteBatchNode("balls", 100);
            ballTexture = ballsBatch.Texture;
            AddChild(ballsBatch, 1, 1);

            visibleBananas = new List <CCSprite>();
            hitBananas     = new List <CCSprite>();

            Schedule(t =>
            {
                visibleBananas.Add(AddBanana());
                elapsedTime += t;
                if (ShouldEndGame())
                {
                    EndGame();
                }
            }, 1.0f);

            Schedule(t => CheckCollision());

            AddGrass();
            AddSun();
            AddMonkey();
        }
Example #8
0
        //---------------------------------------------------------------------------------------------------------
        // GameSelectLayer constructor
        //---------------------------------------------------------------------------------------------------------
        public GameSelectLayer(Player activePlayer)
        {
            currentPlayer = activePlayer;

            Color   = new CCColor3B(0, 0, 0);
            Opacity = 255;
        }
Example #9
0
        public GameLayer()
        {
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesEnded = OnTouchesEnded;

            EventDispatcher.AddEventListener(touchListener, this);
            Color   = new CCColor3B(CCColor4B.White);
            Opacity = 255;

            visibleBananas = new List <CCSprite> ();
            hitBananas     = new List <CCSprite> ();

            monkey          = new CCSprite("Monkey");
            monkey.Position = CCDirector.SharedDirector.WinSize.Center;
            AddChild(monkey);

            Schedule((t) => {
                visibleBananas.Add(AddBanana());
                dt += t;
                if (ShouldEndGame())
                {
                    var gameOverScene = GameOverLayer.SceneWithScore(hitBananas.Count);
                    CCTransitionFadeDown transitionToGameOver = new CCTransitionFadeDown(1.0f, gameOverScene);
                    CCDirector.SharedDirector.ReplaceScene(transitionToGameOver);
                }
            }, 1.0f);

            Schedule((t) => {
                CheckCollision();
            });
        }
Example #10
0
        public GameScoresLayer()
        {
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesBegan = (touches, ccevent) => {
                var mainGame             = GameStartLayer.CreateScene(Window);
                var transitionToGameOver = new CCTransitionMoveInL(0.3f, mainGame);

                Director.ReplaceScene(transitionToGameOver);
            };

            AddEventListener(touchListener, this);

            scoreMessage = String.Format("Current High Score");

            Color = new CCColor3B(127, 200, 205);

            Opacity = 255;

            var moveUp   = new CCMoveBy(1.0f, new CCPoint(0.0f, 50.0f));
            var moveDown = moveUp.Reverse();

            // A CCSequence action runs the list of actions in ... sequence!
            CCSequence moveSeq = new CCSequence(new CCEaseBackInOut(moveUp), new CCEaseBackInOut(moveDown));

            repeatedAction = new CCRepeatForever(moveSeq);
        }
Example #11
0
        //---------------------------------------------------------------------------------------------------------
        // FreePlayLayer constructor
        //---------------------------------------------------------------------------------------------------------
        public FreePlayLayer(Player activePlayer)
        {
            currentPlayer = activePlayer;

            Color   = new CCColor3B(0, 0, 0);
            Opacity = 255;
        }
Example #12
0
 public ColoredCircleSprite(CCColor4B color, float r)
 {
     radius_ = r;
     Opacity = color.A;
     Color   = new CCColor3B(color.R, color.G, color.B);
     PreInit();
 }
Example #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 /// <param name="size"></param>
 /// <param name="color"></param>
 public LoadingLabel(string message, CCColor3B color) : base(message, color)
 {
     Color       = color;
     m_message   = message;
     AnchorPoint = CCPoint.AnchorUpperLeft;
     Schedule(UpdateLoading, INTERVAL);
 }
        public override void UpdateDisplayedColor(CCColor3B parentColor)
        {
            var displayedColor = CCColor3B.White;

            displayedColor.R = (byte)(RealColor.R * parentColor.R / 255.0f);
            displayedColor.G = (byte)(RealColor.G * parentColor.G / 255.0f);
            displayedColor.B = (byte)(RealColor.B * parentColor.B / 255.0f);

            UpdateColor();

            if (scale9Image != null)
            {
                scale9Image.UpdateDisplayedColor(displayedColor);
            }

            foreach (var child in protectedChildren)
            {
                child.UpdateDisplayedColor(displayedColor);
            }

            if (IsColorCascaded && Children != null)
            {
                foreach (var child in Children)
                {
                    child.UpdateDisplayedColor(displayedColor);
                }
            }
        }
Example #15
0
        public IntroLayer()
        {
            // create and initialize a Label
            label             = new CCLabelTtf("0", "MarkerFelt", 22);
            label.AnchorPoint = CCPoint.AnchorMiddleTop;
            label.PositionY   = VisibleBoundsWorldspace.MaxY - 20;

            // add the label as a child to this Layer
            AddChild(label);

            paddleSprite           = new CCSprite("paddle");
            paddleSprite.PositionX = 100;
            paddleSprite.PositionY = 100;

            AddChild(paddleSprite);

            ballSprite           = new CCSprite("ball");
            ballSprite.PositionX = 320;
            ballSprite.PositionY = 640;

            AddChild(ballSprite);

            // setup our color for the background
            Color   = new CCColor3B(CCColor4B.Blue);
            Opacity = 255;
        }
Example #16
0
        public TextLayer() : base()
        {
            Color   = new CCColor3B(32, 128, 32);
            Opacity = 255;

            BaseNode = new CCNodeGrid();
            var effect = CurrentAction;

            BaseNode.RunAction(effect);
            AddChild(BaseNode, 0, EffectTestScene.kTagBackground);

            var bg = new CCSprite(TestResource.s_back3);

            BaseNode.AddChild(bg, 0);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);

            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc      = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();

            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);

            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2      = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();

            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));
        }
        public LabelFNTFromHTTP()
        {
            m_time = 0;

            Color   = new CCColor3B(128, 128, 128);
            Opacity = 255;

            loading = new LoadingLabel();
            AddChild(loading);

            Schedule(step);

            ScheduleOnce((dt) =>
            {
                if (!loading.Visible)
                {
                    loading.RemoveFromParent();
                }
                else
                {
                    loading.StopAllActions();
                    loading.Scale = 1;
                    loading.Text  = "Loading Timeout";
                }
            },
                         5 // delay 5 seconds

                         );
        }
Example #18
0
        public GameLayer()
        {
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesEnded = OnTouchesEnded;

            AddEventListener(touchListener, this);
            Color   = new CCColor3B(CCColor4B.White);
            Opacity = 255;

            visibleBananas = new List <CCSprite>();
            hitBananas     = new List <CCSprite>();

            // batch node for physics balls
            ballsBatch  = new CCSpriteBatchNode("balls", 100);
            ballTexture = ballsBatch.Texture;
            AddChild(ballsBatch, 1, 1);

            AddGrass();
            AddSun();
            AddMonkey();

            StartScheduling();

            CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic("Sounds/backgroundMusic", true);
        }
 public ColoredCircleSprite(CCColor4B color, float r)
 {
     radius_ = r;
     Opacity = color.A;
     Color = new CCColor3B(color.R, color.G, color.B);
     PreInit();
 }
Example #20
0
        public GameLayer()
        {
            TouchEnabled = true;


            localBananas = new List <CCSprite> ();

            localMonkey = new CCSprite("MonkeyLocal");

            localMonkey.PositionY = 0;
            localMonkey.PositionX = CCDirector.SharedDirector.WinSize.Width / 2;
            AddChild(localMonkey);


            remoteMonkey           = new CCSprite("MonkeyRemote");
            remoteMonkey.PositionY = CCDirector.SharedDirector.WinSize.Height - remoteMonkey.ContentSizeInPixels.Height / 2;
            remoteMonkey.PositionX = CCDirector.SharedDirector.WinSize.Width / 2;
            AddChild(remoteMonkey);

            if (!Context.isRoomCreator)
            {
                byte[] message = buildStartMessage();
                sendWarpUpdate(message);
                beginLocalGame();
            }

            Color   = new CCColor3B(XNA.Color.ForestGreen);
            Opacity = 255;
        }
        public GameOverLayer(int score, int remoteScore)
        {
            TouchEnabled = true;

            string scoreMessage = String.Format("Game Over. You collected {0} bananas \r\n Opponent collected {1} bananas!", score, remoteScore);

            var scoreLabel = new CCLabelTTF(scoreMessage, "MarkerFelt", 22)
            {
                Position = new CCPoint(CCDirector.SharedDirector.WinSize.Center.X, CCDirector.SharedDirector.WinSize.Center.Y + 50),
                Color    = new CCColor3B(XNA.Color.Yellow)
            };

            AddChild(scoreLabel);

            var playAgainLabel = new CCLabelTTF("Tap to Play Again", "MarkerFelt", 22)
            {
                Position = CCDirector.SharedDirector.WinSize.Center,
                Color    = new CCColor3B(XNA.Color.Green)
            };

            AddChild(playAgainLabel);

            Color   = new CCColor3B(XNA.Color.Black);
            Opacity = 255;
            // Clean up the room from the server
            if (Context.isRoomCreator)
            {
                WarpClient.GetInstance().DeleteRoom(Context.gameRoomId);
            }
        }
Example #22
0
 public IntroLayer()
 {
     // setup our color for the background
     Color         = new CCColor3B(CCColor4B.Red);
     Opacity       = 0;
     renderCommand = new CCCustomCommand(RenderUI);
 }
Example #23
0
        public LabelSystemFont168()
        {
            Color   = new CCColor3B(200, 191, 231);
            Opacity = 255;

            fadeOut = new CCFadeOutBLTiles(1f, new CCGridSize(10, 10));

            Schedule(StressIt, 2.0f);
        }
Example #24
0
 public override void StartWithTarget(CCNode target)
 {
     base.StartWithTarget(target);
     var protocol = m_pTarget as ICCRGBAProtocol;
     if (protocol != null)
     {
         m_from = protocol.Color;
     }
 }
Example #25
0
        public LabelFNTGlyphDesigner()
        {
            Color   = new CCColor3B(128, 128, 128);
            Opacity = 255;

            // CCLabelBMFont
            label1 = new CCLabel("Testing Glyph Designer", "fonts/futura-48.fnt");
            AddChild(label1);
        }
Example #26
0
        private void MakeLabel(string text, string font, int textsize, int x, int y, CCColor3B color)//method for creating simple labels
        {
            CCLabel label = new CCLabel(text, font, textsize, CCLabelFormat.SpriteFont);

            label.Position = new CCPoint(x, y);
            label.Color    = color;
            m_labels.Add(label);
            AddChild(label);
        }
Example #27
0
        public bool InitWithDuration(float duration, byte red, byte green, byte blue)
        {
            if (base.InitWithDuration(duration))
            {
                m_to = new CCColor3B(red, green, blue);
                return true;
            }

            return false;
        }
        public DrawNodeDrawPolygon()
        {
            Color         = new CCColor3B(127, 127, 127);
            Opacity       = 255;
            drawTriangles = new CCDrawNode();

            AddChild(drawTriangles, 10);

            backGround = new CCDrawNode();
        }
Example #29
0
        public override void StartWithTarget(CCNode target)
        {
            base.StartWithTarget(target);
            var protocol = m_pTarget as ICCRGBAProtocol;

            if (protocol != null)
            {
                m_from = protocol.Color;
            }
        }
Example #30
0
        public bool InitWithDuration(float duration, byte red, byte green, byte blue)
        {
            if (base.InitWithDuration(duration))
            {
                m_to = new CCColor3B(red, green, blue);
                return(true);
            }

            return(false);
        }
Example #31
0
        public void DrawTexture(string texturePath, CCPoint position, CCSize size, CCColor3B color, float opacity)
        {
            CCSprite sprite = new CCSprite(texturePath)
            {
                Position = position, Color = color, ContentSize = size
            };

            Sprites.Add(sprite);
            AddChild(sprite);
        }
Example #32
0
 public CCTintToState (CCTintTo action, CCNode target)
     : base (action, target)
 {   
     ColorTo = action.ColorTo;
     var protocol = Target;
     if (protocol != null)
     {
         ColorFrom = protocol.Color;
     }
 }
Example #33
0
        public CCTintToState(CCTintTo action, CCNode target)
            : base(action, target)
        {
            ColorTo = action.ColorTo;
            var protocol = Target;

            if (protocol != null)
            {
                ColorFrom = protocol.Color;
            }
        }
        public DrawNodeTriangleVertex()
        {
            Color                   = new CCColor3B(127, 127, 127);
            Opacity                 = 255;
            drawTriangles           = new CCDrawNode();
            drawTriangles.BlendFunc = CCBlendFunc.NonPremultiplied;

            AddChild(drawTriangles, 10);

            backGround = new CCDrawNode();
        }
        public void PreInit()
        {
            Radius = 10.0f;
            numberOfSegments = 36;
            Color = new CCColor3B(CCColor4B.White);

            circleVertices = new CCPoint[numberOfSegments];

            if (circleVertices.Count() == 0)
                Console.WriteLine(@"Ack!! malloc in colored circle failed");
        }
 protected override void OnHandlePropTypeColor3(CCNode node, CCNode parent, string propertyName, CCColor3B color, CCBReader reader)
 {
     if (propertyName == PROPERTY_COLOR)
     {
         ((CCLabelBMFont) node).Color = color;
     }
     else
     {
         base.OnHandlePropTypeColor3(node, parent, propertyName, color, reader);
     }
 }
 protected override void OnHandlePropTypeColor3(CCNode node, CCNode parent, string propertyName, CCColor3B color, CCBReader reader)
 {
     if (propertyName == PROPERTY_STARTCOLOR)
     {
         ((CCLayerGradient) node).StartColor = color;
     }
     else if (propertyName == PROPERTY_ENDCOLOR)
     {
         ((CCLayerGradient) node).EndColor = color;
     }
     else
     {
         base.OnHandlePropTypeColor3(node, parent, propertyName, color, reader);
     }
 }
        public void PreInit()
        {
            Radius = 10.0f;
            numberOfSegments = 36;

            //self.shaderProgram = [[CCShaderCache sharedShaderCache] programForKey:kCCShader_PositionColor];
            // default blend function
            //blendFunc = new CCBlendFunc( CCOGLES. CCDrawManager.BlendState.ColorSourceBlend, ;  //new CCBlendFunc( CC_BLEND_SRC, CC_BLEND_DST };
            //var tmpColor = ;
            Color = new CCColor3B(CCColor4B.White);
            //Opacity = tmpColor.A;

            circleVertices = new CCPoint[numberOfSegments]; // new CCPoint( malloc(sizeof(CGPoint)*(numberOfSegments));

            if (circleVertices.Count() == 0)
                Console.WriteLine(@"Ack!! malloc in colored circle failed");

        }
 protected override void OnHandlePropTypeColor3(CCNode node, CCNode parent, string propertyName, CCColor3B color, CCBReader reader)
 {
     if (propertyName == PROPERTY_TITLECOLOR_NORMAL)
     {
         ((CCControlButton) node).SetTitleColorForState(color, CCControlState.Normal);
     }
     else if (propertyName == PROPERTY_TITLECOLOR_HIGHLIGHTED)
     {
         ((CCControlButton) node).SetTitleColorForState(color, CCControlState.Highlighted);
     }
     else if (propertyName == PROPERTY_TITLECOLOR_DISABLED)
     {
         ((CCControlButton) node).SetTitleColorForState(color, CCControlState.Disabled);
     }
     else
     {
         base.OnHandlePropTypeColor3(node, parent, propertyName, color, reader);
     }
 }
        public override void UpdateDisplayedColor(CCColor3B parentColor)
        {

            var displayedColor = CCColor3B.White;
            displayedColor.R = (byte)(RealColor.R * parentColor.R / 255.0f);
            displayedColor.G = (byte)(RealColor.G * parentColor.G / 255.0f);
            displayedColor.B = (byte)(RealColor.B * parentColor.B / 255.0f);

            UpdateColor();

            if (scale9Image != null)
            {
                scale9Image.UpdateDisplayedColor(displayedColor);
            }

            foreach (var child in protectedChildren)
            {
                child.UpdateDisplayedColor(displayedColor);
            }

            if (IsColorCascaded && Children != null)
            {
                foreach (var child in Children)
                {
                    child.UpdateDisplayedColor(displayedColor);
                }
            }
        }
Example #41
0
 public CCTintTo (float duration, byte red, byte green, byte blue) : base (duration)
 {
     ColorTo = new CCColor3B (red, green, blue);
 }