Exemplo n.º 1
0
        public HomeLayer() : base(CCColor4B.White)
        {
            sprLogo = new CCSprite("logo.png");
            AddChild(sprLogo);

            mniAbout = new CCMenuItemImage(new CCSprite("btnAbout.png"), new CCSprite("btnAboutSelected.png"), delegate(object obj)
            {
                GameView.Director.PushScene(AboutLayer.AboutScene(GameView));
            });

            mniScore = new CCMenuItemImage(new CCSprite("btnScore.png"), new CCSprite("btnScoreSelected.png"), delegate(object obj)
            {
                GameView.Director.PushScene(ScoreLayer.ScoreScene(GameView));
            });

            mniStart = new CCMenuItemImage(new CCSprite("btnStart.png"), new CCSprite("btnStartSelected.png"), delegate(object obj)
            {
                GameView.Director.PushScene(GameLayer.GameScene(GameView));
            });


            mnuMain = new CCMenu(new CCMenuItem[] { mniStart, mniScore, mniAbout });
            mnuMain.AlignItemsVertically(MENU_SPACING);

            AddChild(mnuMain);
        }
Exemplo n.º 2
0
        private void CheckCollision()
        {
            RemoveNoParentNodes();

            //check if player intersects with enemy bullets
            foreach (EnemyBullet eb in visileEnemyBullets)
            {
                bool hit = eb.BoundingBoxTransformedToParent.IntersectsRect(player.BoundingBoxTransformedToParent);
                if (hit)
                {
                    Explode(eb.Position);
                    eb.RemoveFromParent();
                    healthBar.Decrease(eb.Damage);
                }
            }
            //check if player intersects with enemies
            foreach (CCSprite enemy in visibleEnemies)
            {
                bool hit = enemy.BoundingBoxTransformedToParent.IntersectsRect(player.BoundingBoxTransformedToParent);
                if (hit)
                {
                    Explode(enemy.Position);
                    Explode(player.Position);
                    enemy.RemoveFromParent();
                    healthBar.Decrease(1);
                }
            }

            //check if enemies intersects with player bullets
            foreach (PlayerBullet pb in visiblePlayerBullets)
            {
                foreach (CCSprite enemy in visibleEnemies)
                {
                    bool hit = pb.BoundingBoxTransformedToParent.IntersectsRect(enemy.BoundingBoxTransformedToParent);
                    if (hit)
                    {
                        Explode(pb.Position);
                        pb.RemoveFromParent();
                        if (enemy is Enemy)
                        {
                            enemy.RemoveFromParent();
                            score += (enemy as Enemy).Score;
                        }
                        else
                        {
                            Boss b = enemy as Boss;
                            b.HealthBar.Decrease(1);
                            if (b.HealthBar.Health == 0)
                            {
                                b.RemoveFromParent();
                                score += b.Score;
                            }
                        }
                    }
                }
            }

            //check GAME END
            if (healthBar.Health == 0)
            {
                GameView.Director.PushScene(ScoreLayer.ScoreScene(GameView));
            }

            RemoveNoParentNodes();
        }