Exemple #1
0
    private void StartLevel(GameState.Level level, float initialTime)
    {
        if (level == GameState.Level.None)
        {
            this.DisplayCredits();
            return;
        }

        this.GameState.SetCurrentLevel(level, initialTime);
        this.GetTree().ChangeScene("res://scenes/levels/BaseLevel.tscn");
    }
Exemple #2
0
    private void InitLevel(string levelNodeGroupName, GameState.Level level)
    {
        var highScore = this.GameState.GetHighScoreFor(level);
        var previousLevelHighScore = this.GameState.GetHighScoreFor(this.GameState.GetPreviousLevel(level));

        if (level != GameState.Level.One)
        {
            this.GetNode <Button>(levelNodeGroupName + "/Button").Disabled = (previousLevelHighScore == 0);
        }

        this.GetNode <Label>(levelNodeGroupName + "/Score").Text = StopWatch.TimeElapsedAsString(highScore);
    }
Exemple #3
0
    private Terrain AddTerrain(GameState.Level level)
    {
        var TerrainPrototype = ResourceLoader.Load <PackedScene>(GetTerrainScenePath(level));

        var terrain = (Terrain)TerrainPrototype.Instance();

        terrain.Connect(nameof(Terrain.BoulderGenerated), this, "OnBoulderGenerated");
        terrain.Connect(nameof(Terrain.PresentationStarted), this, "OnTerrainPresentationStarted");
        terrain.Connect(nameof(Terrain.PresentationEnded), this, "OnTerrainPresentationEnded");

        this.AddChild(terrain);

        return(terrain);
    }
    ///<summary>
    ///Returns the level in which we are
    ///Devuelve el nivel en que nos encontramos
    ///<returns>
    ///String level;
    /// </returns>
    ///</summary>
    string getLevel()
    {
        GameState.Level currentLevel = this.gameS.level;
        string          level        = "Null";

        switch (currentLevel)
        {
        case GameState.Level.Easy: level = "Easy_level"; break;

        case GameState.Level.Medium: level = "Medium_Level"; break;

        case GameState.Level.Hard: level = "Hard_Level"; break;
        }
        return(level);
    }
Exemple #5
0
    private static string GetTerrainScenePath(GameState.Level level)
    {
        switch (level)
        {
        case GameState.Level.One: return("res://scenes/levels/Level1/Terrain.tscn");

        case GameState.Level.Two: return("res://scenes/levels/Level2/Terrain.tscn");

        case GameState.Level.Three: return("res://scenes/levels/Level3/Terrain.tscn");

        case GameState.Level.Four: return("res://scenes/levels/Level4/Terrain.tscn");

        default: throw new NotImplementedException();
        }
    }
Exemple #6
0
    protected void InitNodes(GameState.Level level, string checkPoint)
    {
        this.Character              = this.GetNode <Character>("Character");
        this.Background             = this.GetNode <Background>("Background");
        this.HUD                    = this.GetNode <HUD>("HUD");
        this.ImpactLocator          = this.GetNode <ImpactLocator>("ImpactLocator");
        this.BoulderGeneratorFollow = this.GetNode <RemoteTransform2D>("Character/BoulderGeneratorFollow");
        this.CameraFollow           = this.GetNode <RemoteTransform2D>("Character/CameraFollow");
        this.Music                  = this.GetNode <AudioStreamPlayer>("Audio/Music");
        this.LostSound              = this.GetNode <AudioStreamPlayer>("Audio/LostSound");

        this.Terrain = this.AddTerrain(level);

        this.BoulderGeneratorFollow.RemotePath = new NodePath("../../Terrain/BoulderGenerator");

        this.Character.GlobalPosition = this.Terrain.UseCheckPoint(checkPoint);

        this.Background.AdjustMotion(this.Terrain.LevelLength);

        this.LevelAudio.Reset();
        this.LevelAudio.AddPlayerToMuteControl(this.Music);
    }
Exemple #7
0
        public void Reset(int n, int k, bool playerFirstMove, Color playerColor, Color computerColor, GameState.Level level)
        {
            GameState.Instance.k             = k;
            GameState.Instance.n             = n;
            GameState.Instance.playerColor   = playerColor;
            GameState.Instance.computerColor = computerColor;
            GameState.Instance.availableNumbers.Clear();
            GameState.Instance.player.Clear();
            GameState.Instance.computer.Clear();
            GameState.Instance.chosen      = new int[2];
            GameState.Instance.currentMove = playerFirstMove ? GameState.Movement.PlayersChoice : GameState.Movement.ComputersChoice;

            GameState.Instance.computerDifferences = new Dictionary <int, List <Tuple <int, int> > >();
            GameState.Instance.playerDifferences   = new Dictionary <int, List <Tuple <int, int> > >();

            GameState.Instance.level    = level;
            GameState.Instance.gameOver = false;

            for (int i = 1; i <= n; i++)
            {
                GameState.Instance.availableNumbers.Add(i);
            }

            playerLabel.BackColor           = playerColor;
            playersNumbersLabel.BackColor   = playerColor;
            computerLabel.BackColor         = computerColor;
            computersNumbersLabel.BackColor = computerColor;

            KLabel.Text = "k: " + k;
            if (level == GameState.Level.Easy)
            {
                levelLabel.Text = "łatwy";
            }
            else if (level == GameState.Level.Medium)
            {
                levelLabel.Text = "średni";
            }
            else
            {
                levelLabel.Text = "trudny";
            }

            playersNumbersLabel.Text   = "?";
            computersNumbersLabel.Text = "?";
            round = 0;

            buttons = new Button[n];
            buttonsPanel.Controls.Clear();
            int dim     = (int)Math.Ceiling(Math.Sqrt(Math.Ceiling((double)n / 2)));
            int over    = (int)Math.Floor((double)((2 * dim * dim - n) / (2 * dim)));
            int columns = 2 * dim;
            int rows    = dim - over;

            buttonsPanel.ColumnCount = columns;
            buttonsPanel.RowCount    = rows;

            buttonsPanel.ColumnStyles.Clear();
            buttonsPanel.RowStyles.Clear();

            for (int r = 0; r < columns; r++)
            {
                buttonsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columns));
            }
            for (int c = 0; c < rows; c++)
            {
                buttonsPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / rows));
            }
            int counter = 1;

            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < columns; c++)
                {
                    if (counter <= n)
                    {
                        Button newButton = new Button {
                            Text = counter.ToString(), Dock = DockStyle.Fill
                        };
                        newButton.Click += new EventHandler(this.numberButton_Click);
                        buttonsPanel.Controls.Add(newButton, c, r);
                        buttons[counter - 1] = newButton;
                        counter++;
                    }
                }
            }

            nextRound();
            updateAction();
        }
Exemple #8
0
 public static void showGameWindow(int n, int k, bool playerFirstMove, Color playerColor, Color computerColor, GameState.Level level)
 {
     newGameControl.Enabled  = false;
     newGameControl.Visible  = false;
     gameOverControl.Enabled = false;
     gameOverControl.Visible = false;
     gameControl.Enabled     = true;
     gameControl.Visible     = true;
     gameControl.Reset(n, k, playerFirstMove, playerColor, computerColor, level);
 }
Exemple #9
0
 private void StartLevel(GameState.Level level)
 {
     this.GameState.ResetCheckPoint();
     this.StartLevel(level, 0);
 }