Пример #1
0
    public void SpawnScorePanel(int s, bool end = false)
    {
        var player = FindObjectOfType <PlayerController>();

        // Compute distance
        float distToTravelPanel  = startHeight;
        float timeToTravel       = distToTravelPanel / panelsSpeed; // seconds
        float distToTravelPlayer = timeToTravel * player.speedForce;
        // Random Z
        float newZ = player.transform.position.z + zOffset;
        // Compute initial position
        Vector3 sharkPos = new Vector3(0f, startHeight, distToTravelPlayer + newZ);
        // Spawn
        GameObject prefab = panelPrefab;

        if (end)
        {
            prefab = endPanelPrefab;
        }
        GameObject panelObj = GameObject.Instantiate(prefab, sharkPos, Quaternion.identity);

        ScorePanel panel = panelObj.GetComponent <ScorePanel>();

        panel.speed = panelsSpeed;
        panel.SetScore(s);

        if (!end)
        {
            float a = 15;
            panelObj.transform.rotation = Quaternion.Euler(Random.Range(-a, a), Random.Range(-a, a), Random.Range(-a, a));
        }
    }
Пример #2
0
 public NewScoreForm(ScorePanel scorePanel)
 {
     InitializeComponent();
     buttonOK.Click += (s, e) =>
     {
         if (beatNumer.SelectedIndex != -1 && beatDenom.SelectedIndex != -1)
         {
             scorePanel.SetScore(int.Parse(beatNumer.Text), int.Parse(beatDenom.Text), (int)numOfMeasure.Value);
             Close();
         }
         else
         {
             MessageBox.Show("未選択箇所があります\n全ての項目に値を指定してください");
         }
     };
     buttonOK.DialogResult     = DialogResult.OK;
     buttonCancel.DialogResult = DialogResult.Cancel;
     beatNumer.SelectedIndex   = 3;
     beatDenom.SelectedIndex   = 2;
 }
Пример #3
0
        public MainForm()
        {
            InitializeComponent();
            #region 譜面パネルの初期化
            tabScore.TabPages.Clear();
            tabScore.Font      = new Font("Yu Gothic UI", 9);
            tabNoteButton.Font = tabScore.Font;
            for (int i = 0; i < tabPageCount; ++i)
            {
                TabPageEx tabPageEx = new TabPageEx("NewScore" + (i + 1));
                tabScore.TabPages.Add(tabPageEx);
                // PictureBoxの追加と初期化
                PictureBox pBox = new PictureBox
                {
                    Size = tabScore.TabPages[i].Size
                };
                // TabPageに初期化したPictureBoxを入れる
                tabScore.TabPages[i].Controls.Add(pBox);
                // ScrollBarの追加と初期化
                HScrollBar hScroll = new HScrollBar
                {
                    Size    = new Size(pBox.Width, 17),
                    Value   = 0,
                    Minimum = 0,
                    Dock    = DockStyle.Bottom
                };
                VScrollBar vScroll = new VScrollBar
                {
                    Size    = new Size(17, pBox.Height),
                    Value   = 0,
                    Minimum = 0,
                    Maximum = 0,
                    Dock    = DockStyle.Right,
                    Visible = false
                };
                // HScrollBarをPictureBoxに入れる
                pBox.Controls.Add(hScroll);
                pBox.Controls.Add(vScroll);
                // 初期化したPictureBoxとHScrollBarを使用してScorePanelを追加
                ScorePanel sPanel = new ScorePanel(pBox, hScroll, vScroll);
                sPanel.OperationManager.StatusChanged += (undo, redo) =>
                {
                    tsbUndo.Enabled = tsmiUndo.Enabled = undo;
                    tsbRedo.Enabled = tsmiRedo.Enabled = redo;
                };
                sPanel.OperationManager.Edited += () =>
                {
                    UpdateTextOfTabAndForm(true);
                    sPanel.IsEdited = true;
                };
                Status.CopyChanged  += (b) => tsbCopy.Enabled = tsbCut.Enabled = b;
                Status.PasteChanged += (b) => tsbPaste.Enabled = b;
                tsbCut.Enabled       = tsbCopy.Enabled = tsbPaste.Enabled = false;
                sPanel.SetScore(4, 4, 200);
                tabPageEx.ScorePanel = sPanel;
                // PictureBoxとHScrollBarの各種デリゲートの設定
                pBox.MouseWheel       += Score_MouseWheel;
                pBox.Paint            += Score_Paint;
                pBox.MouseClick       += Score_MouseClick;
                pBox.MouseDoubleClick += Score_MouseDoubleClick;
                pBox.MouseEnter       += Score_MouseEnter;
                pBox.MouseDown        += Score_MouseDown;
                pBox.MouseMove        += Score_MouseMove;
                pBox.MouseUp          += Score_MouseUp;
                hScroll.Scroll        += Score_Scroll;
                vScroll.Scroll        += Score_Scroll;
            }
            #endregion
            InitializeToolStrip();
            #region ノーツボタン追加
            NoteButtonManager noteButtonManager = new NoteButtonManager();
            noteButtonManager.ButtonClicked += (s, e) => SetMode(Mode.Add);
            flpNotePanel.Size     = tabNoteButton.TabPages[0].Size;
            flpNotePanel.Location = new Point();
            foreach (NoteButton noteButton in noteButtonManager)
            {
                flpNotePanel.Controls.Add(noteButton);
            }
            #endregion
            #region 各種ボタンに対するイベント紐づけ
            tabScore.SelectedIndexChanged += (s, e) =>
            {
                Text  = tabScore.SelectedTab.Text;
                Text += " - M4ple Editor";
                ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel;
                selectedPanel.OperationManager.OnStatusChanged();
            };
            #region ToolStripButton
            tsbAdd.Click                  += (s, e) => SetMode(Mode.Add);
            tsbEdit.Click                 += (s, e) => SetMode(Mode.Edit);
            tsbDelete.Click               += (s, e) => SetMode(Mode.Delete);
            tsbInvisibleSlideTap.Click    += TbsInvisibleSlideTap_Click;
            tscbBeat.SelectedIndexChanged += (s, e) => { Status.Beat = int.Parse(tscbBeat.Text); };
            tscbGrid.SelectedIndexChanged += (s, e) => { Status.Grid = int.Parse(tscbGrid.Text); };
            tsbNew.Click                  += New_Click;
            tsbOpen.Click                 += Open_Click;
            tsbSave.Click                 += Save_Click;
            tsbImport.Click               += Import_Click;
            tsbExport.Click               += (s, e) =>
            {
                ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel;
                selectedPanel.Export();
            };
            tsbCopy.Click    += Copy_Click;
            tsbCut.Click     += Cut_Click;
            tsbPaste.Click   += Paste_Click;
            tsbUndo.Click    += Undo_Click;
            tsbRedo.Click    += Redo_Click;
            tsbUndo.Enabled   = tsbRedo.Enabled = false;
            tsbZoomIn.Click  += ZoomIn_Click;
            tsbZoomOut.Click += ZoomOut_Click;
            #endregion
            #region ToolStripMenuItem(表示)
            tsmiIsShortNote.Click += (s, e) =>
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)s;
                Status.IsShortNoteVisible = menuItem.Checked = !menuItem.Checked;
                Refresh();
            };
            tsmiIsHold.Click += (s, e) =>
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)s;
                Status.IsHoldVisible = menuItem.Checked = !menuItem.Checked;
                Refresh();
            };
            tsmiIsSlide.Click += (s, e) =>
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)s;
                Status.IsSlideVisible = menuItem.Checked = !menuItem.Checked;
                Refresh();
            };
            tsmiIsSlideRelay.Click += (s, e) =>
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)s;
                Status.IsSlideRelayVisible = menuItem.Checked = !menuItem.Checked;
                Refresh();
            };
            tsmiIsSlideCurve.Click += (s, e) =>
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)s;
                Status.IsSlideCurveVisible = menuItem.Checked = !menuItem.Checked;
                Refresh();
            };
            tsmiIsAirHold.Click += (s, e) =>
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)s;
                Status.IsAirHoldVisible = menuItem.Checked = !menuItem.Checked;
                Refresh();
            };
            tsmiIsAir.Click += (s, e) =>
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)s;
                Status.IsAirVisible = menuItem.Checked = !menuItem.Checked;
                Refresh();
            };
            tsmiIsExTapDistinct.Click += (s, e) =>
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)s;
                Status.IsExTapDistinct = menuItem.Checked = !menuItem.Checked;
                Refresh();
            };
            tsmiIsEconomyMode.Click += (s, e) =>
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)s;
                Status.IsEconomyMode = menuItem.Checked = !menuItem.Checked;
                Refresh();
            };
            #endregion
            #region ToolStlipMenuItem(ファイル)
            tsmiNew.Click    += New_Click;
            tsmiOpen.Click   += Open_Click;
            tsmiSave.Click   += Save_Click;
            tsmiSaveAs.Click += (s, e) =>
            {
                ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel;
                bool       isSaved       = selectedPanel.SaveAs();
                UpdateTextOfTabAndForm(!isSaved);
            };
            tsmiImport.Click += Import_Click;
            tsmiExport.Click += (s, e) =>
            {
                ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel;
                selectedPanel.ExportAs();
            };
            tsmiQuit.Click += (s, e) =>
            {
                Close();
            };
            FormClosing += (s, e) =>
            {
                e.Cancel = !IsExit();
                Properties.Settings.Default.Save();
            };
            #endregion
            #region ToolStripMenuItem(編集)
            tsmiUndo.Click         += Undo_Click;
            tsmiRedo.Click         += Redo_Click;
            tsmiUndo.Enabled        = tsmiRedo.Enabled = false;
            tsmiCopy.Click         += Copy_Click;
            tsmiCut.Click          += Cut_Click;
            tsmiPaste.Click        += Paste_Click;
            tsmiPasteReverse.Click += (s, e) =>
            {
                ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel;
                selectedPanel.PasteNotes();
                selectedPanel.ReverseNotes();
                Refresh();
            };
            tsmiDelete.Click += (s, e) =>
            {
                ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel;
                selectedPanel.ClearAreaNotes();
                Refresh();
            };
            tsmiReverse.Click += (s, e) =>
            {
                ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel;
                selectedPanel.ReverseNotes();
                Refresh();
            };
            #endregion
            #region ToolStripMenuItem(ウィンドウ)
            tsmiSizeSmall.Click    += (s, e) => SetPanelSize(PanelSize.Small);
            tsmiSizeMiddle.Click   += (s, e) => SetPanelSize(PanelSize.Middle);
            tsmiSizeBig.Click      += (s, e) => SetPanelSize(PanelSize.Big);
            tsmiScaleHalf.Click    += (s, e) => SetScoreScale(ScoreScale.Half);
            tsmiScaleDefault.Click += (s, e) => SetScoreScale(ScoreScale.Default);
            tsmiScaleDouble.Click  += (s, e) => SetScoreScale(ScoreScale.Double);
            tsmiScaleQuad.Click    += (s, e) => SetScoreScale(ScoreScale.Quad);
            #endregion
            #region ToolStripMenuItem(ヘルプ)
            tsmiShowHelp.Click += (s, e) =>
            {
                System.Diagnostics.Process.Start("https://github.com/TinyTany/M4ple/wiki");
            };
            tsmiVersion.Click += (s, e) =>
            {
                new VersionInfoForm().ShowDialog();
            };
            #endregion
            #endregion
            #region ショートカットキー
            KeyDown += (s, e) =>
            {
                if (ModifierKeys == Keys.Alt)
                {
                    return;
                }
                switch (e.KeyCode)
                {
                case Keys.A:
                    tsbAdd.PerformClick();
                    break;

                case Keys.E:
                    tsbEdit.PerformClick();
                    break;

                case Keys.D:
                    tsbDelete.PerformClick();
                    break;

                case Keys.S:
                    tsbInvisibleSlideTap.PerformClick();
                    break;

                case Keys.B:
                    if (ModifierKeys == Keys.Shift)
                    {
                        tscbBeat.SelectedIndex =
                            tscbBeat.SelectedIndex == 0 ? tscbBeat.Items.Count - 1 : --tscbBeat.SelectedIndex;
                    }
                    else
                    {
                        tscbBeat.SelectedIndex = (tscbBeat.SelectedIndex + 1) % tscbBeat.Items.Count;
                    }
                    break;

                case Keys.G:
                    if (ModifierKeys == Keys.Shift)
                    {
                        tscbGrid.SelectedIndex =
                            tscbGrid.SelectedIndex == 0 ? tscbGrid.Items.Count - 1 : --tscbGrid.SelectedIndex;
                    }
                    else
                    {
                        tscbGrid.SelectedIndex = (tscbGrid.SelectedIndex + 1) % tscbGrid.Items.Count;
                    }
                    break;

                case Keys.OemPeriod:
                    noteButtonManager.SelectedButtonIncrease();
                    break;

                case Keys.Oemcomma:
                    noteButtonManager.SelectedButtonDecrease();
                    break;
                }
            };
            #endregion
            Resize += (s, e) =>
            {
                // HACK: 16と42はマジックナンバー的なもの(なぜかこの値で調整しないと大きさが合わない)
                tabScore.Size = new Size(
                    Width - tabScore.Location.X - tabScore.Margin.Right - 16,
                    Height - tabScore.Location.Y - tabScore.Margin.Bottom - 42);
                foreach (TabPageEx tabPageEx in tabScore.TabPages)
                {
                    tabPageEx.ScorePanel.ReSizePanel(tabScore.SelectedTab.Size);
                }
                tabNoteButton.Height = tabScore.Height;
                flpNotePanel.Height  = tabNoteButton.TabPages[0].Height;
            };

            #region tscbBeatの初期化
            beatItemList = new List <ToolStripValueItem>()
            {
                new ToolStripValueItem(4),
                new ToolStripValueItem(8),
                new ToolStripValueItem(12),
                new ToolStripValueItem(16),
                new ToolStripValueItem(24),
                new ToolStripValueItem(32),
                new ToolStripValueItem(48),
                new ToolStripValueItem(64),
                new ToolStripValueItem(96),
                new ToolStripValueItem(128),
                new ToolStripValueItem(192),
                new ToolStripValueItem(256),
                new ToolStripValueItem(384),
                new ToolStripValueItem(512),
                new ToolStripValueItem(768),
            };

            tscbBeat.Items.Clear();
            beatItemList.ForEach(x => tscbBeat.Items.Add(x));
            // NOTE: StatusでのBeatの初期値が16なのでそれに対応したインデックスにしておく
            var index = beatItemList.FindIndex(x => x.Value == Status.Beat);
            System.Diagnostics.Debug.Assert(index >= 0, "tscbBeatの初期インデックスが正しく設定されていません");
            tscbBeat.SelectedIndex = index;
            #endregion

            SetPanelSize(PanelSize.Big);
            SetScoreScale(ScoreScale.Default);
        }
Пример #4
0
    void Update()
    {
        switch (gameState)
        {
        case GameState.Start:
            if (GameInput.IsTriggered())
            {
                score = 0;
                scorePanel.SetScore(score);
                HidePanels();

                sounds.PlayStartRound();

                //Note: this code is not recommended because it uses reflection.
                Invoke("StartRound", 1);

                gameState = GameState.Idle;
            }

            break;

        case GameState.Playing:
            if (GameInput.IsTriggered())
            {
                sounds.PlayShoot();

                var start   = theCamera.transform.position;
                var end     = start + theCamera.transform.forward * hitDistance;
                var hitInfo = new RaycastHit();
                var hit     = Physics.Linecast(start, end, out hitInfo);

                bullets--;
                scorePanel.SetBullets(bullets);

                if (hit)
                {
                    var colliderHit = hitInfo.collider;
                    if (colliderHit.tag == "Duck")
                    {
                        score++;

                        var duck = colliderHit.GetComponent <Duck>();
                        duck.Hit();
                        sounds.StopFly();

                        scorePanel.SetScore(score);
                        sounds.PlayScoring();

                        if (score < totalDucksPerRound)
                        {
                            gameState = GameState.Scoring;
                            Invoke("StartRound", 1);
                        }
                        else
                        {
                            gameState = GameState.YouWin;
                            Invoke("ShowYouWin", 1);
                        }
                    }
                }
                else if (bullets <= 0)
                {
                    gameState = GameState.GameOver;

                    FlyAway();

                    sounds.StopFly();
                    sounds.PlayLose();

                    Invoke("ShowGameOver", 1);
                }
            }

            break;
        }
    }