예제 #1
0
 protected virtual void Awake()
 {
     _timer.enabled        = false;
     _gameManager          = FindObjectOfType <GameManager>();
     _pauseOverlay         = GetComponentInChildren <PauseOverlay>();
     _pauseOverlay.Running = Running;
 }
예제 #2
0
파일: Game.cs 프로젝트: s1123787/ICTSE1b-3
 //Method to remove the pause overlay
 public void RemovePauseOverlay(PauseOverlay o, Canvas c)
 {
     //Remove endpoint objects from the screen
     c.Children.Remove(o.background);
     c.Children.Remove(o.pauseSprite);
     c.Children.Remove(o.resume);
     c.Children.Remove(o.restart);
     c.Children.Remove(o.menu);
 }
예제 #3
0
        public PlayState()
        {
            for (int i = 0; i < Constant.NumberBrickRate.Length; i++)
            {
                NumberBricks.AddRange(Enumerable.Repeat <int>(i, Constant.NumberBrickRate[i]));
            }

            gameObjects.AddChild(new SpriteGameObject("Sprites/Backgrounds/spr_play", Depth.Backgroud));
            gameObjects.AddChild(ListBrick.Instance);
            gameObjects.AddChild(ListBall.Instance);
            gameObjects.AddChild(Director.Instance);
            gameObjects.AddChild(ListItemAddBall.Instance);
            gameObjects.AddChild(ListItemAddCoin.Instance);
            gameObjects.AddChild(ListItemClearColumn.Instance);
            gameObjects.AddChild(ListItemClearRow.Instance);
            gameObjects.AddChild(ListItemSpreadBall.Instance);

            pauseButton = new Button("Sprites/Buttons/spr_pause", Depth.Button);
            gameObjects.AddChild(pauseButton);
            pauseButton.SetOriginToLeftCenter();
            pauseButton.LocalPosition = new Vector2(20, 75);

            guideButton = new Button("Sprites/Buttons/spr_guide", Depth.Button);
            gameObjects.AddChild(guideButton);
            guideButton.SetOriginToLeftCenter();
            guideButton.LocalPosition = new Vector2(130, 75);



            playHighScore = new TextGameObject("Fonts/PlayHighScore", Depth.Button, Color.White, TextGameObject.HorizontalAlignment.Right, TextGameObject.VerticalAlignment.Top);
            gameObjects.AddChild(playHighScore);
            playHighScore.LocalPosition = new Vector2(680, 30);

            playMoney = new TextGameObject("Fonts/PlayMoney", Depth.Button, Color.White, TextGameObject.HorizontalAlignment.Left, TextGameObject.VerticalAlignment.Center);
            gameObjects.AddChild(playMoney);
            playMoney.LocalPosition = new Vector2(120, 1132);

            playScore = new TextGameObject("Fonts/PlayScore", Depth.Button, Color.White, TextGameObject.HorizontalAlignment.Center, TextGameObject.VerticalAlignment.Top);
            gameObjects.AddChild(playScore);
            playScore.LocalPosition = new Vector2(350, 20);

            pauseOverlay = new PauseOverlay();
            gameObjects.AddChild(pauseOverlay);

            continueOverlay = new ContinueOverlay(this);
            gameObjects.AddChild(continueOverlay);

            endGameOverlay = new EndGameOverlay();
            gameObjects.AddChild(endGameOverlay);


            fireWorkMaker = new ListStar(Depth.BallNumber + 0.001f);
            gameObjects.AddChild(fireWorkMaker);
            Reset();
        }
예제 #4
0
 public void ChangeState()
 {
     paused = !paused;
     leftController.SetActive(!leftController.activeSelf);
     rightController.SetActive(!rightController.activeSelf);
     PauseOverlay.SetActive(!PauseOverlay.activeSelf);
     menuButton.SetActive(!menuButton.activeSelf);
     if (cheats)
     {
         CheatsButton.SetActive(!CheatsButton.activeSelf);
     }
 }
예제 #5
0
파일: Game.cs 프로젝트: s1123787/ICTSE1b-3
 public void OnEscKeyIsPressed(object source, EventArgs e)
 {
     //Check if the game is active
     if (playing)
     {
         pauseOverlay = new PauseOverlay();
         pauseOverlay.resumeIsPressed  += OnPressedOnResume;
         pauseOverlay.restartIsPressed += OnPressedOnRestart;
         pauseOverlay.pressedOnMenu    += OnPressedOnMenu;
         AddPauseOverlay(pauseOverlay, GameCanvas);
         GameTimer.Pause();
         FreezePlayer   = true;
         playing        = false;
         pauseActivated = true;
     }
 }
예제 #6
0
파일: Game.cs 프로젝트: s1123787/ICTSE1b-3
 public void OnPressedOnRestart(object source, EventArgs e)
 {
     PlayAgain();
     if (pauseOverlay != null)
     {
         RemovePauseOverlay(pauseOverlay, GameCanvas);
         pauseOverlay = null;
     }
     else if (gameOverOverlay != null)
     {
         RemoveGameOverOverlay(gameOverOverlay, GameCanvas);
         gameOverOverlay = null;
     }
     else
     {
         RemoveGameWonOverlay(gameWonOverlay, GameCanvas);
         gameWonOverlay = null;
     }
 }
예제 #7
0
        public override void Reset()
        {
            base.Reset();

            Add(pauseOverlay = new PauseOverlay
            {
                Depth    = -1,
                OnResume = () => Logger.Log(@"Resume"),
                OnRetry  = () => Logger.Log(@"Retry"),
                OnQuit   = () => Logger.Log(@"Quit")
            });
            AddButton("Pause", pauseOverlay.Show);
            AddButton("Add Retry", delegate
            {
                retryCount++;
                pauseOverlay.Retries = retryCount;
            });

            retryCount = 0;
        }
예제 #8
0
        public void PauseGame(bool pause)
        {
            foreach (GameComponent component in Components)
            {
                if (!(component is Player) && !(component is InputManager))
                {
                    component.Enabled = !pause;
                }
            }

            if (_songPlaying)
            {
                musicPlayer.PauseAll(pause);
            }

            if (pause)
            {
                PauseOverlay pauseOverlay = new PauseOverlay(this, null);
                pauseOverlay.DrawOrder = 100;
                Components.Add(pauseOverlay);
            }
        }
예제 #9
0
        public override void Reset()
        {
            base.Reset();

            retryCount = 0;

            Add(pauseOverlay = new PauseOverlay
            {
                OnResume = () => Logger.Log(@"Resume"),
                OnRetry  = () => Logger.Log(@"Retry"),
                OnQuit   = () => Logger.Log(@"Quit"),
            });
            Add(failOverlay = new FailOverlay
            {
                OnRetry = () => Logger.Log(@"Retry"),
                OnQuit  = () => Logger.Log(@"Quit"),
            });

            AddStep(@"Pause", delegate {
                if (failOverlay.State == Visibility.Visible)
                {
                    failOverlay.Hide();
                }
                pauseOverlay.Show();
            });
            AddStep("Fail", delegate {
                if (pauseOverlay.State == Visibility.Visible)
                {
                    pauseOverlay.Hide();
                }
                failOverlay.Show();
            });
            AddStep("Add Retry", delegate
            {
                retryCount++;
                pauseOverlay.Retries = retryCount;
                failOverlay.Retries  = retryCount;
            });
        }
예제 #10
0
        public override bool onKeyPress(Keys key)
        {
            if (!base.onKeyPress(key))
            {
                if (key == Keys.Space)
                {
                    CurrentWorld.PlayerJump();
                    return(true);
                }
                else if (key == Keys.R)
                {
                    CurrentWorld.Reset();
                    return(true);
                }
                else if (key == Keys.Escape)
                {
                    if (State == ScreenState.Active)
                    {
                        PauseOverlay overlay = new PauseOverlay("Paused", 100, 100, (int)Universal.GameSize.X - 200, (int)Universal.GameSize.Y - 320);
                        overlay.Color = Colors.BackgroundSecondary;
                        PushOverlay(overlay);
                        resumeButton.Visible = true;
                        menuButton.Visible   = true;
                        State = ScreenState.Paused;
                    }
                    else
                    {
                        PopOverlay();
                        resumeButton.Visible = false;
                        menuButton.Visible   = false;
                        State = ScreenState.Active;
                    }
                    return(true);
                }
            }

            return(false);
        }
예제 #11
0
파일: Game.cs 프로젝트: s1123787/ICTSE1b-3
 //Method to add pause overlay to the screen
 public void AddPauseOverlay(PauseOverlay o, Canvas c)
 {
     //Add everything to the screen
     Canvas.SetTop(o.background, o.backgroundY);
     Canvas.SetLeft(o.background, o.backgroundX);
     c.Children.Add(o.background);
     Panel.SetZIndex(o.background, 99);
     Canvas.SetTop(o.pauseSprite, o.pauseSpriteY);
     Canvas.SetLeft(o.pauseSprite, o.pauseSpriteX);
     c.Children.Add(o.pauseSprite);
     Panel.SetZIndex(o.pauseSprite, 99);
     Canvas.SetTop(o.resume, o.resumeY);
     Canvas.SetLeft(o.resume, o.resumeX);
     c.Children.Add(o.resume);
     Panel.SetZIndex(o.resume, 99);
     Canvas.SetTop(o.restart, o.restartY);
     Canvas.SetLeft(o.restart, o.restartX);
     c.Children.Add(o.restart);
     Panel.SetZIndex(o.restart, 99);
     Canvas.SetTop(o.menu, o.menuY);
     Canvas.SetLeft(o.menu, o.menuX);
     c.Children.Add(o.menu);
     Panel.SetZIndex(o.menu, 99);
 }
예제 #12
0
        public GameScreen()
        {
            AddRange(new Drawable[]
            {
                pauseOverlay = new PauseOverlay
                {
                    OnContinue = () =>
                    {
                        pauseOverlay.Hide();

                        // TODO: add countdown timer
                    },
                    OnRestart = () =>
                    {
                        // TODO
                    },
                    OnStop = Exit
                },
                bg = new Background(@"Backgrounds/game_default")
                {
                    FillMode = FillMode.Fill,
                    Anchor   = Anchor.Centre,
                    Origin   = Anchor.Centre
                },
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    Children         = new Drawable[]
                    {
                        circle1 = new HitCircle
                        {
                            Anchor = Anchor.BottomCentre,
                            Origin = Anchor.BottomCentre,
                            Margin = new MarginPadding
                            {
                                Right  = 850,
                                Bottom = 410
                            }
                        },
                        circle2 = new HitCircle
                        {
                            Anchor = Anchor.BottomCentre,
                            Origin = Anchor.BottomCentre,
                            Margin = new MarginPadding
                            {
                                Right  = 760,
                                Bottom = 260
                            }
                        },
                        circle3 = new HitCircle
                        {
                            Anchor = Anchor.BottomCentre,
                            Origin = Anchor.BottomCentre,
                            Margin = new MarginPadding
                            {
                                Right  = 545,
                                Bottom = 135
                            }
                        },
                        circle4 = new HitCircle
                        {
                            Anchor = Anchor.BottomCentre,
                            Origin = Anchor.BottomCentre,
                            Margin = new MarginPadding
                            {
                                Bottom = 35,
                                Right  = 300
                            }
                        },
                        circle5 = new HitCircle
                        {
                            Anchor = Anchor.BottomCentre,
                            Origin = Anchor.BottomCentre,
                            Margin = new MarginPadding
                            {
                                Bottom = 10
                            }
                        },
                        circle6 = new HitCircle
                        {
                            Anchor = Anchor.BottomCentre,
                            Origin = Anchor.BottomCentre,
                            Margin = new MarginPadding
                            {
                                Bottom = 35,
                                Left   = 300
                            }
                        },
                        circle7 = new HitCircle
                        {
                            Anchor = Anchor.BottomCentre,
                            Origin = Anchor.BottomCentre,
                            Margin = new MarginPadding
                            {
                                Left   = 545,
                                Bottom = 135
                            }
                        },
                        circle8 = new HitCircle
                        {
                            Anchor = Anchor.BottomCentre,
                            Origin = Anchor.BottomCentre,
                            Margin = new MarginPadding
                            {
                                Left   = 760,
                                Bottom = 260
                            }
                        },
                        circle9 = new HitCircle
                        {
                            Anchor = Anchor.BottomCentre,
                            Origin = Anchor.BottomCentre,
                            Margin = new MarginPadding
                            {
                                Left   = 850,
                                Bottom = 410
                            }
                        }
                    }
                }
            });
        }