示例#1
0
        private void DifficultySelector_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selectedOption = DifficultySelector.GetItemText(DifficultySelector.SelectedItem);

            if (selectedOption == "Custom")
            {
                DifficultyCustomizer.Enabled = true;
            }
        }
示例#2
0
        private void StartGame_Click(object sender, EventArgs e)
        {
            string selectedOption   = DifficultySelector.GetItemText(DifficultySelector.SelectedItem);
            bool   noOptionSelected = false;

            switch (selectedOption)
            {
            case "Easy 8*8 (10 mines)":
                GameInfo.BoardX         = 8;
                GameInfo.BoardY         = 8;
                GameInfo.TotalMineCount = 10;
                break;

            case "Normal 16*16 (40 mines)":
                GameInfo.BoardX         = 16;
                GameInfo.BoardY         = 16;
                GameInfo.TotalMineCount = 40;
                break;

            case "Hard 30*16 (99 mines)":
                GameInfo.BoardX         = 30;
                GameInfo.BoardY         = 16;
                GameInfo.TotalMineCount = 99;
                break;

            case "Custom":
                GameInfo.BoardX         = (int)XCustomizer.Value;
                GameInfo.BoardY         = (int)YCustomizer.Value;
                GameInfo.TotalMineCount = (int)MinesCustomizer.Value;
                break;

            default:    //no item is selected
                noOptionSelected = true;
                break;
            }
            if (noOptionSelected == false)
            {
                Hide();//hide startup menu
                MinesweeperInstance = new Minesweeper();
                MinesweeperInstance.Show();
                GameInfo.GameStarted = true;
            }
        }
示例#3
0
    // 起動処理
    void Start()
    {
        int    difficulty = DifficultySelector.GetDifficulty(); // 難易度取得
        string scorefile  = "";                                 // スコア格納ファイルを指定するための変数宣言

        // 難易度による初期化処理
        switch (difficulty)
        {
        case 0:     // EASY
            scorefile = Application.streamingAssetsPath + "/easyscore";
            using (StreamReader reader = new StreamReader(scorefile, Encoding.GetEncoding("UTF-8"))) {
                bestScore = int.Parse(reader.ReadLine());
            }
            break;

        case 1:     // HARD
            maxHp    /= 2;
            scorefile = Application.streamingAssetsPath + "/hardscore";
            using (StreamReader reader = new StreamReader(scorefile, Encoding.GetEncoding("UTF-8"))) {
                bestScore = int.Parse(reader.ReadLine());
            }
            break;

        case 2:     // IMPOSSIBLE
            maxHp     = 1;
            scorefile = Application.streamingAssetsPath + "/owatascore";
            using (StreamReader reader = new StreamReader(scorefile, Encoding.GetEncoding("UTF-8"))) {
                bestScore = int.Parse(reader.ReadLine());
            }
            break;

        default:     // なにかの都合で難易度指定できなかったとき用
            hp        = maxHp;
            bestScore = 0;
            break;
        }
        hp    = maxHp;                             // 体力初期化
        score = 0;                                 // スコア初期化
        bestScoreText.text = bestScore.ToString(); // ベストスコア表示
    }
示例#4
0
    // 毎フレームごとの処理
    void Update()
    {
        // 入力を取得
        float inputLR   = Input.GetAxisRaw("Horizontal");
        float inputUD   = Input.GetAxisRaw("Vertical");
        float inputSlow = Input.GetAxisRaw("Fire3");

        float speed;

        if (inputSlow == 0)
        {
            speed = 0.1f;
        }
        else
        {
            speed = 0.05f;
        }
        // 移動
        if (inputLR > 0 && transform.position.x < 0.75)
        {
            transform.Translate(speed, 0, 0); // 右
        }
        else if (inputLR < 0 && transform.position.x > -7.75)
        {
            transform.Translate(-speed, 0, 0); // 左
        }

        if (inputUD > 0 && transform.position.y < 4.75)
        {
            transform.Translate(0, speed, 0); // 下
        }
        else if (inputUD < 0 && transform.position.y > -4.75)
        {
            transform.Translate(0, -speed, 0); // 上
        }

        // 弾発射
        if (Input.GetAxisRaw("Fire1") == 1)
        {
            // 発射
            if (shotTimer == 0)
            {
                Fire();
            }

            // 発射からの時間加算
            shotTimer += Time.deltaTime;
            if (shotTimer >= shotInterval)
            {
                shotTimer = 0; // 指定した時間が経過したら発射できるようにする
            }
        }
        else
        {
            shotTimer = 0; // 発射ボタンを離したら即発射可能に
        }

        // レベル変更
        double level_d = score / 1000; // スコアを1000で割ったものがレベルの参考値

        // 内部的なレベルは難易度によって変動
        int difficulty = DifficultySelector.GetDifficulty();

        switch (difficulty)
        {
        case 0:                                   // EASY
            level = (int)Math.Floor(level_d) + 1; // 参考値に1を足して切り捨て
            break;

        case 1:                                   // HARD
            level = (int)Math.Floor(level_d) + 3; // 参考値に3を足して切り捨て
            break;

        case 2:                                   // IMPOSSIBLE
            level = (int)Math.Floor(level_d) + 5; // 参考値に5を足して切り捨て
            break;

        default:     // 難易度選択ができなかった場合EASYと同じに
            level = (int)Math.Floor(level_d) + 1;
            break;
        }
        levelText.text = ((int)Math.Floor(level_d) + 1).ToString(); // 表示するレベルは難易度に関係なく基準値に1を足して切り捨てたもの

        // 時間経過でのスコア増加
        scoreTimer += Time.deltaTime;
        if (scoreTimer >= scoreWithTimeInterval)
        {
            score     += (int)Math.Floor(level_d) + 1;
            scoreTimer = 0;
        }

        // 各種表示類
        scoreText.text = score.ToString();                                    // スコア表示
        hpText.text    = hp.ToString();                                       // HP表示 (数字)
        slider.value   = (float)hp / (float)maxHp;                            // HP表示 (バー)
        GameObject[] tagObjects = GameObject.FindGameObjectsWithTag("Enemy"); // 敵の数のカウント
        enemyCountText.text = (tagObjects.Length).ToString();                 // 敵の数を表示
    }
示例#5
0
文件: Menu.cs 项目: csatari/pixeek
        public static void CreateNewGameMenu()
        {
            MenuElement       root = new MenuElement();
            MenuSpriteElement bg   = new MenuSpriteElement("GUI/newgame_menu.jpg", new Rectangle(0, 0, GameManager.Width, GameManager.Height));

            root.AddChild(bg);

            {
                Rectangle exitRect = new Rectangle(GameManager.Width - 152, 1, 151, 71);
                MenuButtonElement exitButton = new MenuButtonElement(exitRect, delegate()
                {
                    CreateMainMenu();
                });
                exitButton.AddChild(new MenuSpriteElement("GUI/button_bg", exitRect, "BACK"));
                bg.AddChild(exitButton);
            }

            Rectangle musicRect = new Rectangle(GameManager.Width - 500, 1, 151, 71);
            MenuButtonElement musicButton = new MenuButtonElement(musicRect, delegate()
            {
                if (!music)
                {
                    music     = true;
                    musicText = "MUSIC: ON";
                }
                else
                {
                    music     = false;
                    musicText = "MUSIC: OFF";
                }
                musicSpriteElement.Text = musicText;
            });

            musicSpriteElement = new MenuSpriteElement("GUI/button_bg", musicRect, musicText);
            musicButton.AddChild(musicSpriteElement);
            bg.AddChild(musicButton);

            Rectangle vibRect = new Rectangle(GameManager.Width - 345, 1, 190, 71);
            MenuButtonElement vibButton = new MenuButtonElement(vibRect, delegate()
            {
                if (!vibration)
                {
                    vibration = true;
                    vibText   = "VIBRATION: ON";
                }
                else
                {
                    vibration = false;
                    vibText   = "VIBRATION: OFF";
                }
                vibrationSpriteElement.Text = vibText;
            });

            vibrationSpriteElement = new MenuSpriteElement("GUI/button_bg", vibRect, vibText);
            vibButton.AddChild(vibrationSpriteElement);
            bg.AddChild(vibButton);



            {
                DifficultySelector selector = new DifficultySelector();
                bg.AddChild(selector);

                int baseX = Convert.ToInt32(0.279 * GameManager.Width);
                int baseY = Convert.ToInt32(0.359 * GameManager.Height);
                int YDiff = Convert.ToInt32(0.085 * GameManager.Height);
                {
                    Rectangle easyRect = new Rectangle(baseX,
                                                       baseY + YDiff * 0,
                                                       Convert.ToInt32(0.078 * GameManager.Width),
                                                       Convert.ToInt32(0.077 * GameManager.Height));
                    MenuButtonElement easyButton = new MenuButtonElement(easyRect, delegate()
                    {
                        selectedDifficulty = Game.Difficulty.EASY;
                    });
                    easyButton.AddChild(new MenuSpriteElement(null, easyRect, "EASY", 1.5f));
                    selector.AddElementForDifficulty(Game.Difficulty.EASY, easyButton);
                }

                {
                    Rectangle easyRect = new Rectangle(baseX, baseY + YDiff * 1, Convert.ToInt32(0.078 * GameManager.Width), Convert.ToInt32(0.077 * GameManager.Height));
                    MenuButtonElement easyButton = new MenuButtonElement(easyRect, delegate()
                    {
                        selectedDifficulty = Game.Difficulty.NORMAL;
                    });
                    easyButton.AddChild(new MenuSpriteElement(null, easyRect, "NORMAL", 1.5f));
                    selector.AddElementForDifficulty(Game.Difficulty.NORMAL, easyButton);
                }

                {
                    Rectangle easyRect = new Rectangle(baseX, baseY + YDiff * 2, Convert.ToInt32(0.078 * GameManager.Width), Convert.ToInt32(0.077 * GameManager.Height));
                    MenuButtonElement easyButton = new MenuButtonElement(easyRect, delegate()
                    {
                        selectedDifficulty = Game.Difficulty.HARD;
                    });
                    easyButton.AddChild(new MenuSpriteElement(null, easyRect, "HARD", 1.5f));
                    selector.AddElementForDifficulty(Game.Difficulty.HARD, easyButton);
                }
            }

            {
                GameModeSelector selector = new GameModeSelector();
                bg.AddChild(selector);

                int baseX = Convert.ToInt32(0.1 * GameManager.Width);
                int baseY = Convert.ToInt32(0.388 * GameManager.Height);
                int YDiff = Convert.ToInt32(0.085 * GameManager.Height);
                {
                    Rectangle easyRect = new Rectangle(baseX, baseY + YDiff * 0, Convert.ToInt32(0.078 * GameManager.Width), Convert.ToInt32(0.077 * GameManager.Height));
                    MenuButtonElement easyButton = new MenuButtonElement(easyRect, delegate()
                    {
                        selectedGameMode = Game.GameMode.NORMAL;
                    });
                    easyButton.AddChild(new MenuSpriteElement(null, easyRect, "NORMAL", 1.5f));
                    selector.AddElementForDifficulty(Game.GameMode.NORMAL, easyButton);
                }

                {
                    Rectangle easyRect = new Rectangle(baseX, baseY + YDiff * 1, Convert.ToInt32(0.078 * GameManager.Width), Convert.ToInt32(0.077 * GameManager.Height));
                    MenuButtonElement easyButton = new MenuButtonElement(easyRect, delegate()
                    {
                        selectedGameMode = Game.GameMode.ENDLESS;
                    });
                    easyButton.AddChild(new MenuSpriteElement(null, easyRect, "ENDLESS", 1.5f));
                    selector.AddElementForDifficulty(Game.GameMode.ENDLESS, easyButton);
                }

                {
                    Rectangle easyRect = new Rectangle(baseX, baseY + YDiff * 2, Convert.ToInt32(0.078 * GameManager.Width), Convert.ToInt32(0.077 * GameManager.Height));
                    MenuButtonElement easyButton = new MenuButtonElement(easyRect, delegate()
                    {
                        selectedGameMode = Game.GameMode.TIME;
                    });
                    easyButton.AddChild(new MenuSpriteElement(null, easyRect, "TIME", 1.5f));
                    selector.AddElementForDifficulty(Game.GameMode.TIME, easyButton);
                }
            }

            {
                Rectangle playRect = new Rectangle(Convert.ToInt32(0.78125 * GameManager.Width), Convert.ToInt32(0.444 * GameManager.Height), Convert.ToInt32(0.114 * GameManager.Width), Convert.ToInt32(0.0583 * GameManager.Height));
                MenuButtonElement playButton = new MenuButtonElement(playRect,
                                                                     delegate()
                {
                    //GameManager.Instance.SwitchScene(new Prototype());
                    GameManager.Instance.SwitchScene(new Game.GameModel(imageDatabase, selectedGameMode, selectedDifficulty, music, vibration));
                }
                                                                     );
                bg.AddChild(playButton);
                playButton.AddChild(new MenuSpriteElement("GUI/button_play.png", playRect));
            }

            GameManager.Instance.SwitchScene(new Menu(root));
        }
    // Start is called before the first frame update
    void Start()
    {
        int difficulty = DifficultySelector.GetDifficulty();
        int score      = PlayerController.GetScore();

        string line;

        int[]  scores = new int[10];
        string output = "";

        string scorefile = "";

        switch (difficulty)
        {
        case 0:
            scorefile = Application.streamingAssetsPath + "/easyscore";
            break;

        case 1:
            scorefile = Application.streamingAssetsPath + "/hardscore";
            break;

        case 2:
            scorefile = Application.streamingAssetsPath + "/owatascore";
            break;
        }

        using (StreamReader reader = new StreamReader(scorefile, Encoding.GetEncoding("UTF-8"))) {
            int loop = 0;
            while ((line = reader.ReadLine()) != null)
            {
                scores[loop] = int.Parse(line);
                loop++;
            }
        }
        for (int i = 0; i <= 9; i++)
        {
            if (score > scores[i])
            {
                for (int j = 8; j >= i; j--)
                {
                    scores[j + 1] = scores[j];
                }
                scores[i] = score;
                ranking  += score.ToString() + " ← Here\n";
                for (int j = i + 1; j <= 8; j++)
                {
                    ranking += scores[j].ToString() + "\n";
                }
                ranking += scores[9].ToString();
                break;
            }
            else
            {
                ranking += scores[i].ToString() + "\n";
                if (i == 9)
                {
                    ranking += "--------\n" + score.ToString() + " ← Here";
                }
            }
        }
        for (int i = 0; i <= 8; i++)
        {
            output += scores[i].ToString() + "\n";
        }
        output += scores[9].ToString();
        using (FileStream fs = new FileStream(scorefile, FileMode.Open)) {
            fs.SetLength(0);
            StreamWriter writer = new StreamWriter(fs);
            writer.Write(output);
            writer.Close();
        }
        Invoke("ShowRanking", 5f);
    }