示例#1
0
        public void Draw(MafiaVideo video)
        {
            for (int row = -1; row < Mafia.SCREEN_HEIGHT / Mafia.BLOCK_WIDTH; row++)
            {
                for (int col = -1; col < Mafia.SCREEN_WIDTH / Mafia.BLOCK_WIDTH; col++)
                {
                    video.Draw(16, 0, 16, 16, 0, 0, col * Mafia.BLOCK_WIDTH, row * Mafia.BLOCK_WIDTH + ((int)Math.Round(32 * Math.Sin(Math.PI * timer / 180.0)) + 1024) % 16);
                }
            }

            for (int i = 0; i < 128; i++)
            {
                double x = Mafia.SCREEN_WIDTH / 2 - 128 + titleWaveWidth * Math.Cos(Math.PI * i / 32.0 + Math.PI * timer / 24.0 + Math.PI) + 3;
                int y = Mafia.SCREEN_HEIGHT / 2 - 64 + 3;
                video.DrawColor(0, 384, 256, 1, i, 0, (int)Math.Round(x), y + i, Color.FromArgb(128, Color.Black));
            }

            for (int i = 0; i < NUM_OBJECTS; i++)
            {
                objects[i].Draw(video);
            }

            for (int i = 0; i < 128; i++)
            {
                double x = Mafia.SCREEN_WIDTH / 2 - 128 + titleWaveWidth * Math.Cos(Math.PI * i / 32.0 + Math.PI * timer / 24.0) - 1;
                int y = Mafia.SCREEN_HEIGHT / 2 - 64 - 1;
                video.Draw(0, 384, 256, 1, i, 0, (int)Math.Round(x), y + i);
            }
        }
示例#2
0
        public override void Draw(MafiaVideo video, IntVector camera)
        {
            if (!ShouldDraw(camera))
            {
                return;
            }
            IntVector p = (IntVector)Position - camera;

            switch (type)
            {
            case Map.SPIKE_LEFT:
                video.Draw(48, 0, 16, 16, 0, 0, p.X, p.Y);
                break;

            case Map.SPIKE_UP:
                video.Draw(48, 0, 16, 16, 0, 1, p.X, p.Y);
                break;

            case Map.SPIKE_RIGHT:
                video.Draw(48, 0, 16, 16, 0, 2, p.X, p.Y);
                break;

            case Map.SPIKE_DOWN:
                video.Draw(48, 0, 16, 16, 0, 3, p.X, p.Y);
                break;

            default:
                video.Draw(32, 0, 16, 16, 0, 0, p.X, p.Y);
                break;
            }
        }
示例#3
0
文件: ThingList.cs 项目: sinshu/mafia
 public void Draw(MafiaVideo video, IntVector camera)
 {
     foreach (Thing thing in list)
     {
         thing.Draw(video, camera);
     }
 }
示例#4
0
        public void Draw(MafiaVideo video)
        {
            for (int row = -1; row < Mafia.SCREEN_HEIGHT / Mafia.BLOCK_WIDTH; row++)
            {
                for (int col = -1; col < Mafia.SCREEN_WIDTH / Mafia.BLOCK_WIDTH; col++)
                {
                    video.Draw(16, 0, 16, 16, 0, 0, col * Mafia.BLOCK_WIDTH, row * Mafia.BLOCK_WIDTH + ((int)Math.Round(32 * Math.Sin(Math.PI * timer / 180.0)) + 1024) % 16);
                }
            }

            for (int i = 0; i < 128; i++)
            {
                double x = Mafia.SCREEN_WIDTH / 2 - 128 + titleWaveWidth * Math.Cos(Math.PI * i / 32.0 + Math.PI * timer / 24.0 + Math.PI) + 3;
                int    y = Mafia.SCREEN_HEIGHT / 2 - 64 + 3;
                video.DrawColor(0, 384, 256, 1, i, 0, (int)Math.Round(x), y + i, Color.FromArgb(128, Color.Black));
            }

            for (int i = 0; i < NUM_OBJECTS; i++)
            {
                objects[i].Draw(video);
            }

            for (int i = 0; i < 128; i++)
            {
                double x = Mafia.SCREEN_WIDTH / 2 - 128 + titleWaveWidth * Math.Cos(Math.PI * i / 32.0 + Math.PI * timer / 24.0) - 1;
                int    y = Mafia.SCREEN_HEIGHT / 2 - 64 - 1;
                video.Draw(0, 384, 256, 1, i, 0, (int)Math.Round(x), y + i);
            }
        }
示例#5
0
文件: ThingList.cs 项目: sinshu/mafia
 public void Draw(MafiaVideo video, IntVector camera)
 {
     foreach (Thing thing in list)
     {
         thing.Draw(video, camera);
     }
 }
示例#6
0
        public void Draw(MafiaVideo video, IntVector camera)
        {
            int topRow    = camera.Y / Mafia.BLOCK_WIDTH;
            int bottomRow = (camera.Y + Mafia.SCREEN_HEIGHT) / Mafia.BLOCK_WIDTH;
            int leftCol   = camera.X / Mafia.BLOCK_WIDTH;
            int rightCol  = (camera.X + Mafia.SCREEN_WIDTH) / Mafia.BLOCK_WIDTH;

            int numRows = Mafia.SCREEN_HEIGHT / Mafia.BLOCK_WIDTH;
            int numCols = Mafia.SCREEN_WIDTH / Mafia.BLOCK_WIDTH;

            for (int row = 0; row <= numRows; row++)
            {
                for (int col = 0; col <= numCols; col++)
                {
                    video.Draw(16, 0, 16, 16, 0, 0, col * Mafia.BLOCK_WIDTH - (camera.X / 2) % 16, row * Mafia.BLOCK_WIDTH - (camera.Y / 2) % 16);
                }
            }

            for (int row = topRow; row <= bottomRow; row++)
            {
                for (int col = leftCol; col <= rightCol; col++)
                {
                    IntVector p = new IntVector(col * Mafia.BLOCK_WIDTH - camera.X, row * Mafia.BLOCK_WIDTH - camera.Y);
                    switch (this[row, col])
                    {
                    case NONE:
                        break;

                    case Map.SPIKE_LEFT:
                        video.Draw(48, 0, 16, 16, 0, 0, p.X, p.Y);
                        break;

                    case Map.SPIKE_UP:
                        video.Draw(48, 0, 16, 16, 0, 1, p.X, p.Y);
                        break;

                    case Map.SPIKE_RIGHT:
                        video.Draw(48, 0, 16, 16, 0, 2, p.X, p.Y);
                        break;

                    case Map.SPIKE_DOWN:
                        video.Draw(48, 0, 16, 16, 0, 3, p.X, p.Y);
                        break;

                    case LIFT_RETURN:
                        break;

                    case DOOR_SLIDE:
                        video.Draw(112, 0, 16, 16, 0, 0, p.X, p.Y);
                        break;

                    default:
                        video.Draw(32, 0, 16, 16, 0, 0, p.X, p.Y);
                        break;
                    }
                }
            }
        }
示例#7
0
        public override void Draw(MafiaVideo video, IntVector camera)
        {
            if (!ShouldDraw(camera, 0, 0, 2, 0))
            {
                return;
            }
            IntVector p = (IntVector)Position - camera - new IntVector(0, 12);

            video.Draw(128, 0, 16, 16, 0, pressed ? 1 : 0, p.X, p.Y);
        }
示例#8
0
文件: Spring.cs 项目: sinshu/mafia
        public override void Draw(MafiaVideo video, IntVector camera)
        {
            if (!ShouldDraw(camera, 0, 0, 16, 0))
            {
                return;
            }
            IntVector p = (IntVector)Position - camera - new IntVector(0, 16);

            video.Draw(0, 64, 16, 32, 0, animation, p.X, p.Y);
        }
示例#9
0
        public override void Draw(MafiaVideo video, IntVector camera)
        {
            if (!ShouldDraw(camera))
            {
                return;
            }
            IntVector p = (IntVector)Position - camera;

            video.Draw(176, 64, 8, 48, 0, 0, p.X, p.Y);
        }
示例#10
0
        public override void Draw(MafiaVideo video, IntVector camera)
        {
            if (!ShouldDraw(camera))
            {
                return;
            }
            IntVector p = (IntVector)Position - camera;

            video.Draw(0, 48, 16, 16, 0, animation, p.X, p.Y);
        }
示例#11
0
 public void Draw(MafiaVideo video)
 {
     IntVector p = (IntVector)position;
     if (type == MAFIA)
     {
         video.Draw(0, 16, 16, 32, 0, animation, p.X, p.Y);
     }
     else if (type == COIN)
     {
         video.Draw(0, 48, 16, 16, 0, animation, p.X, p.Y);
     }
 }
示例#12
0
        public void Draw(MafiaVideo video)
        {
            IntVector p = (IntVector)position;

            if (type == MAFIA)
            {
                video.Draw(0, 16, 16, 32, 0, animation, p.X, p.Y);
            }
            else if (type == COIN)
            {
                video.Draw(0, 48, 16, 16, 0, animation, p.X, p.Y);
            }
        }
示例#13
0
        private void DrawStageNumber(MafiaVideo video)
        {
            int number = stageIndex + 1;

            if (number < 10)
            {
                video.Draw(0, 160, 16, 16, 0, number, Mafia.SCREEN_WIDTH / 2 - 8, Mafia.SCREEN_HEIGHT / 2 - 8);
            }
            else
            {
                video.Draw(0, 160, 16, 16, 0, (number / 10) % 10, Mafia.SCREEN_WIDTH / 2 - 8 - 8, Mafia.SCREEN_HEIGHT / 2 - 8);
                video.Draw(0, 160, 16, 16, 0, number % 10, Mafia.SCREEN_WIDTH / 2 - 8 + 8, Mafia.SCREEN_HEIGHT / 2 - 8);
            }
        }
示例#14
0
 public void Draw(MafiaVideo video)
 {
     video.FillScreen(Color.FromArgb(128, Color.Black));
     video.DrawStringCenter("ステージをえらんでください", 1, -63, Color.Black);
     video.DrawStringCenter("ステージをえらんでください", 0, -64, Color.White);
     if (stageIndex != 0)
     {
         video.Draw(176, 160, 8, 16, 0, 0, Mafia.SCREEN_WIDTH / 2 - 24, Mafia.SCREEN_HEIGHT / 2 - 8);
     }
     if (stageIndex != stages.Length - 1)
     {
         video.Draw(176, 160, 8, 16, 0, 1, Mafia.SCREEN_WIDTH / 2 + 16, Mafia.SCREEN_HEIGHT / 2 - 8);
     }
     DrawStageNumber(video);
     video.DrawStringCenter(stages[stageIndex].Title, 1, 25, Color.Black);
     video.DrawStringCenter(stages[stageIndex].Title, 0, 24, Color.White);
 }
示例#15
0
文件: Tiun.cs 项目: sinshu/mafia
 public override void Draw(MafiaVideo video, IntVector camera)
 {
     if (!ShouldDraw(camera)) return;
     IntVector p = (IntVector)Position - camera;
     if (type == TIUN)
     {
         video.Draw(0, 112, 16, 16, 0, 7 - (life / 2) % 8, p.X, p.Y);
     }
     else if (type == KIRA)
     {
         video.Draw(0, 112, 16, 16, 1, 7 - (life / 2) % 8, p.X, p.Y);
     }
     else if (type == MOKU)
     {
         video.Draw(0, 112, 16, 16, 2, 7 - (life / 2) % 8, p.X, p.Y);
     }
 }
示例#16
0
 public void Draw(MafiaVideo video)
 {
     video.FillScreen(Color.FromArgb(128, Color.Black));
     video.DrawStringCenter("�X�e�[�W������ł�������", 1, -63, Color.Black);
     video.DrawStringCenter("�X�e�[�W������ł�������", 0, -64, Color.White);
     if (stageIndex != 0)
     {
         video.Draw(176, 160, 8, 16, 0, 0, Mafia.SCREEN_WIDTH / 2 - 24, Mafia.SCREEN_HEIGHT / 2 - 8);
     }
     if (stageIndex != stages.Length - 1)
     {
         video.Draw(176, 160, 8, 16, 0, 1, Mafia.SCREEN_WIDTH / 2 + 16, Mafia.SCREEN_HEIGHT / 2 - 8);
     }
     DrawStageNumber(video);
     video.DrawStringCenter(stages[stageIndex].Title, 1, 25, Color.Black);
     video.DrawStringCenter(stages[stageIndex].Title, 0, 24, Color.White);
 }
示例#17
0
文件: GameScene.cs 项目: sinshu/mafia
 public void Draw(MafiaVideo video)
 {
     map.Draw(video, (IntVector)camera);
     things.Draw(video, (IntVector)camera);
     if (!player.Missed)
     {
         if (currentNumCoins == 0)
         {
             // video.Draw(0, 320, 128, 64, 0, 0, Mafia.SCREEN_WIDTH / 2 - 64, Mafia.SCREEN_HEIGHT / 2 - 32);
             double waveWidth = 0;
             if (clearTimer < 60)
             {
                 waveWidth = (60 - clearTimer) / 2;
             }
             for (int i = 0; i < 64; i++)
             {
                 double x = Mafia.SCREEN_WIDTH / 2 - 64 + waveWidth * Math.Cos(Math.PI * i / 16.0 + Math.PI * clearTimer / 12.0 + Math.PI) + 2;
                 int    y = Mafia.SCREEN_HEIGHT / 2 - 32;
                 video.DrawColor(0, 320, 128, 1, i, 0, (int)Math.Round(x), y + i + 2, Color.FromArgb(128, Color.Black));
             }
             for (int i = 0; i < 64; i++)
             {
                 double x = Mafia.SCREEN_WIDTH / 2 - 64 + waveWidth * Math.Cos(Math.PI * i / 16.0 + Math.PI * clearTimer / 12.0);
                 int    y = Mafia.SCREEN_HEIGHT / 2 - 32;
                 video.Draw(0, 320, 128, 1, i, 0, (int)Math.Round(x), y + i);
             }
         }
         else
         {
             if (gameTimer < 300)
             {
                 video.DrawStringCenter(title, 1, 1, Color.Black);
                 video.DrawStringCenter(title, 0, 0, Color.White);
             }
             else
             {
                 video.DrawString(title, 9, 9, Color.Black);
                 video.DrawString(title, 8, 8, Color.White);
             }
             video.Draw(0, 160, 16, 16, 0, (firstNumCoins - currentNumCoins) % 10, Mafia.SCREEN_WIDTH - 48, Mafia.SCREEN_HEIGHT - 16);
             video.Draw(0, 160, 16, 16, 0, 10, Mafia.SCREEN_WIDTH - 32, Mafia.SCREEN_HEIGHT - 16);
             video.Draw(0, 160, 16, 16, 0, firstNumCoins % 10, Mafia.SCREEN_WIDTH - 16, Mafia.SCREEN_HEIGHT - 16);
         }
     }
 }
示例#18
0
        public override void Draw(MafiaVideo video, IntVector camera)
        {
            if (!ShouldDraw(camera))
            {
                return;
            }
            IntVector p = (IntVector)Position - camera;

            if (type == TIUN)
            {
                video.Draw(0, 112, 16, 16, 0, 7 - (life / 2) % 8, p.X, p.Y);
            }
            else if (type == KIRA)
            {
                video.Draw(0, 112, 16, 16, 1, 7 - (life / 2) % 8, p.X, p.Y);
            }
            else if (type == MOKU)
            {
                video.Draw(0, 112, 16, 16, 2, 7 - (life / 2) % 8, p.X, p.Y);
            }
        }
示例#19
0
 public void Dispose()
 {
     if (bgm != null)
     {
         bgm.Dispose();
         bgm = null;
     }
     if (video != null)
     {
         video.Dispose();
         video = null;
     }
     if (input != null)
     {
         input.Dispose();
         input = null;
     }
     if (form != null)
     {
         form.Dispose();
         form = null;
     }
 }
示例#20
0
 public void Dispose()
 {
     if (bgm != null)
     {
         bgm.Dispose();
         bgm = null;
     }
     if (video != null)
     {
         video.Dispose();
         video = null;
     }
     if (input != null)
     {
         input.Dispose();
         input = null;
     }
     if (form != null)
     {
         form.Dispose();
         form = null;
     }
 }
示例#21
0
        public override void Draw(MafiaVideo video, IntVector camera)
        {
            if (!ShouldDraw(camera))
            {
                return;
            }
            if (missed)
            {
                return;
            }
            IntVector p = (IntVector)Position - camera;

            switch (Direction)
            {
            case LEFT:
                video.Draw(0, 16, 16, 32, 0, Animation, p.X, p.Y);
                break;

            case RIGHT:
                video.Draw(128, 16, 16, 32, 0, Animation, p.X, p.Y);
                break;
            }
        }
示例#22
0
文件: Coin.cs 项目: sinshu/mafia
 public override void Draw(MafiaVideo video, IntVector camera)
 {
     if (!ShouldDraw(camera)) return;
     IntVector p = (IntVector)Position - camera;
     video.Draw(0, 48, 16, 16, 0, animation, p.X, p.Y);
 }
示例#23
0
文件: Door.cs 项目: sinshu/mafia
 public override void Draw(MafiaVideo video, IntVector camera)
 {
     if (!ShouldDraw(camera)) return;
     IntVector p = (IntVector)Position - camera;
     video.Draw(176, 64, 8, 48, 0, 0, p.X, p.Y);
 }
示例#24
0
文件: Player.cs 项目: sinshu/mafia
 public override void Draw(MafiaVideo video, IntVector camera)
 {
     if (!ShouldDraw(camera)) return;
     if (missed) return;
     IntVector p = (IntVector)Position - camera;
     switch (Direction)
     {
         case LEFT:
             video.Draw(0, 16, 16, 32, 0, Animation, p.X, p.Y);
             break;
         case RIGHT:
             video.Draw(128, 16, 16, 32, 0, Animation, p.X, p.Y);
             break;
     }
 }
示例#25
0
文件: Map.cs 项目: sinshu/mafia
        public void Draw(MafiaVideo video, IntVector camera)
        {
            int topRow = camera.Y / Mafia.BLOCK_WIDTH;
            int bottomRow = (camera.Y + Mafia.SCREEN_HEIGHT) / Mafia.BLOCK_WIDTH;
            int leftCol = camera.X / Mafia.BLOCK_WIDTH;
            int rightCol = (camera.X + Mafia.SCREEN_WIDTH) / Mafia.BLOCK_WIDTH;

            int numRows = Mafia.SCREEN_HEIGHT / Mafia.BLOCK_WIDTH;
            int numCols = Mafia.SCREEN_WIDTH / Mafia.BLOCK_WIDTH;

            for (int row = 0; row <= numRows; row++)
            {
                for (int col = 0; col <= numCols; col++)
                {
                    video.Draw(16, 0, 16, 16, 0, 0, col * Mafia.BLOCK_WIDTH - (camera.X / 2) % 16, row * Mafia.BLOCK_WIDTH - (camera.Y / 2) % 16);
                }
            }

            for (int row = topRow; row <= bottomRow; row++)
            {
                for (int col = leftCol; col <= rightCol; col++)
                {
                    IntVector p = new IntVector(col * Mafia.BLOCK_WIDTH - camera.X, row * Mafia.BLOCK_WIDTH - camera.Y);
                    switch (this[row, col])
                    {
                        case NONE:
                            break;
                        case Map.SPIKE_LEFT:
                            video.Draw(48, 0, 16, 16, 0, 0, p.X, p.Y);
                            break;
                        case Map.SPIKE_UP:
                            video.Draw(48, 0, 16, 16, 0, 1, p.X, p.Y);
                            break;
                        case Map.SPIKE_RIGHT:
                            video.Draw(48, 0, 16, 16, 0, 2, p.X, p.Y);
                            break;
                        case Map.SPIKE_DOWN:
                            video.Draw(48, 0, 16, 16, 0, 3, p.X, p.Y);
                            break;
                        case LIFT_RETURN:
                            break;
                        case DOOR_SLIDE:
                            video.Draw(112, 0, 16, 16, 0, 0, p.X, p.Y);
                            break;
                        default:
                            video.Draw(32, 0, 16, 16, 0, 0, p.X, p.Y);
                            break;
                    }
                }
            }
        }
示例#26
0
        public void Run()
        {
            form = new Form();
            // �E�B���h�E�T�C�Y�•ς̕����ǂ��ˁH
            form.Icon = MafiaLoader.DefaultLoader.GetIcon("mafia.ico");
            form.Text = Mafia.TITLE;

            stages = new Stage[numStages];
            for (int i = 0; i < numStages; i++)
            {
                if (i < Mafia.NUM_STAGES)
                {
                    stages[i] = MafiaLoader.DefaultLoader.GetStage("stage" + i + ".stg");
                }
                else
                {
                    stages[i] = MafiaLoader.DefaultLoader.GetStage(stagePath[i - Mafia.NUM_STAGES]);
                }
            }
            if (stagePath.Length == 0)
            {
                currentStageIndex = 0;
            }
            else
            {
                currentStageIndex = Mafia.NUM_STAGES;
            }

            title = new TitleScene();
            select = new SelectScene(stages, 0);

            state = TITLE_SCENE;

            video = new MafiaVideo(form, MessageBox.Show("�t���X�N���[���ŋN�����܂����H", "�m�F", MessageBoxButtons.YesNo) == DialogResult.Yes);
            sound = new MafiaSound(form);
            input = new MafiaInput(form);

            try
            {
                bgm = new Audio(Application.StartupPath + "\\" + Mafia.RESOURCE_NAME + "\\mafia.mp3");
                bgm.Ending += new EventHandler(bgm_Ending);
            }
            catch
            {
            }

            form.Show();

            timer = new FpsTimer(Mafia.FPS, false);

            while (CheckState())
            {
                if (input.ShouldToggleFullscreen())
                {
                    video.ToggleFullscreen();
                }
                switch (state)
                {
                    case TITLE_SCENE:
                        // �C�F���h�E�Anull���ǂ����`�F�b�N���Ȃ���Ȃ��Ƃ͉�����
                        if (bgm != null && bgm.Playing)
                        {
                            bgm.Stop();
                        }
                        switch (title.Tick(input.GetCurrentTitleInput()))
                        {
                            case TitleScene.NONE:
                                if (timer.ShouldRender() && video.CheckDrawable())
                                {
                                    video.Begin();
                                    video.DrawTitleScene(title);
                                    video.DrawFps(timer.GetCurrentFps());
                                    video.End();
                                    video.Present();
                                }
                                break;
                            case TitleScene.START_GAME:
                                select.CurrentStage = currentStageIndex;
                                state = SELECT_SCENE_TITLE;
                                break;
                            case TitleScene.EXIT:
                                form.Close();
                                break;
                        }
                        break;
                    case SELECT_SCENE_TITLE:
                        {
                            title.Tick(TitleInput.Empty);
                            int result = select.Tick(input.GetCurrentSelectInput());
                            switch (result)
                            {
                                case SelectScene.NONE:
                                    if (timer.ShouldRender() && video.CheckDrawable())
                                    {
                                        video.Begin();
                                        video.DrawTitleScene(title);
                                        video.DrawSelectScene(select);
                                        video.DrawFps(timer.GetCurrentFps());
                                        video.End();
                                        video.Present();
                                    }
                                    sound.PlaySelectSound(select);
                                    break;
                                case SelectScene.GOTO_TITLE:
                                    state = TITLE_SCENE;
                                    break;
                                default:
                                    state = GAME_SCENE;
                                    game = stages[currentStageIndex = result].CreateGame();
                                    break;
                            }
                        }
                        break;
                    case GAME_SCENE:
                        if (bgm != null && !bgm.Playing)
                        {
                            bgm.Play();
                        }
                        switch (game.Tick(input.GetCurrentGameInput()))
                        {
                            case GameScene.NONE:
                                if (timer.ShouldRender() && video.CheckDrawable())
                                {
                                    video.Begin();
                                    video.DrawGameScene(game);
                                    video.DrawFps(timer.GetCurrentFps());
                                    video.End();
                                    video.Present();
                                }
                                sound.PlayGameSound(game);
                                break;
                            case GameScene.RESET_GAME:
                                sound.StopSounds();
                                game = stages[currentStageIndex].CreateGame();
                                break;
                            case GameScene.CLEAR_GAME:
                                sound.StopSounds();
                                currentStageIndex = (currentStageIndex + 1) % numStages;
                                game = stages[currentStageIndex].CreateGame();
                                break;
                            case GameScene.SELECT:
                                if (timer.ShouldRender() && video.CheckDrawable())
                                {
                                    video.Begin();
                                    video.DrawGameScene(game);
                                    video.DrawFps(timer.GetCurrentFps());
                                    video.End();
                                    video.Present();
                                }
                                sound.PlayGameSound(game);
                                select.CurrentStage = currentStageIndex;
                                state = SELECT_SCENE_GAME;
                                break;
                            case GameScene.GOTO_TITLE:
                                sound.StopSounds();
                                state = TITLE_SCENE;
                                break;
                        }
                        break;
                    case SELECT_SCENE_GAME:
                        game.Tick(GameInput.Empty);
                        {
                            int result = select.Tick(input.GetCurrentSelectInput());
                            switch (result)
                            {
                                case SelectScene.NONE:
                                    if (timer.ShouldRender() && video.CheckDrawable())
                                    {
                                        video.Begin();
                                        video.DrawGameScene(game);
                                        video.DrawSelectScene(select);
                                        video.DrawFps(timer.GetCurrentFps());
                                        video.End();
                                        video.Present();
                                    }
                                    sound.PlayGameSound(game);
                                    sound.PlaySelectSound(select);
                                    break;
                                case SelectScene.GOTO_TITLE:
                                    sound.StopSounds();
                                    state = TITLE_SCENE;
                                    break;
                                default:
                                    sound.StopSounds();
                                    game = stages[currentStageIndex = result].CreateGame();
                                    state = GAME_SCENE;
                                    break;
                            }
                        }
                        break;
                }
                Application.DoEvents();
                timer.Wait();
            }

            if (bgm != null)
            {
                if (bgm.Playing)
                {
                    bgm.Stop();
                }
                bgm.Dispose();
                bgm = null;
            }
            video.Dispose();
            video = null;
            sound.Dispose();
            sound = null;
            input.Dispose();
            input = null;
        }
示例#27
0
文件: Thing.cs 项目: sinshu/mafia
 public abstract void Draw(MafiaVideo video, IntVector camera);
示例#28
0
文件: Switch.cs 项目: sinshu/mafia
 public override void Draw(MafiaVideo video, IntVector camera)
 {
     if (!ShouldDraw(camera, 0, 0, 2, 0)) return;
     IntVector p = (IntVector)Position - camera - new IntVector(0, 12);
     video.Draw(128, 0, 16, 16, 0, pressed ? 1 : 0, p.X, p.Y);
 }
示例#29
0
        public void Run()
        {
            form = new Form();
            // ウィンドウサイズ可変の方が良くね?
            form.Icon = MafiaLoader.DefaultLoader.GetIcon("mafia.ico");
            form.Text = Mafia.TITLE;

            stages = new Stage[numStages];
            for (int i = 0; i < numStages; i++)
            {
                if (i < Mafia.NUM_STAGES)
                {
                    stages[i] = MafiaLoader.DefaultLoader.GetStage("stage" + i + ".stg");
                }
                else
                {
                    stages[i] = MafiaLoader.DefaultLoader.GetStage(stagePath[i - Mafia.NUM_STAGES]);
                }
            }
            if (stagePath.Length == 0)
            {
                currentStageIndex = 0;
            }
            else
            {
                currentStageIndex = Mafia.NUM_STAGES;
            }

            title  = new TitleScene();
            select = new SelectScene(stages, 0);

            state = TITLE_SCENE;

            video = new MafiaVideo(form, MessageBox.Show("フルスクリーンで起動しますか?", "確認", MessageBoxButtons.YesNo) == DialogResult.Yes);
            sound = new MafiaSound(form);
            input = new MafiaInput(form);

            try
            {
                bgm         = new Audio(Application.StartupPath + "\\" + Mafia.RESOURCE_NAME + "\\mafia.mp3");
                bgm.Ending += new EventHandler(bgm_Ending);
            }
            catch
            {
            }

            form.Show();

            timer = new FpsTimer(Mafia.FPS, false);

            while (CheckState())
            {
                if (input.ShouldToggleFullscreen())
                {
                    video.ToggleFullscreen();
                }
                switch (state)
                {
                case TITLE_SCENE:
                    // イェンドウ、nullかどうかチェックしなきゃならんとは何事か
                    if (bgm != null && bgm.Playing)
                    {
                        bgm.Stop();
                    }
                    switch (title.Tick(input.GetCurrentTitleInput()))
                    {
                    case TitleScene.NONE:
                        if (timer.ShouldRender() && video.CheckDrawable())
                        {
                            video.Begin();
                            video.DrawTitleScene(title);
                            video.DrawFps(timer.GetCurrentFps());
                            video.End();
                            video.Present();
                        }
                        break;

                    case TitleScene.START_GAME:
                        select.CurrentStage = currentStageIndex;
                        state = SELECT_SCENE_TITLE;
                        break;

                    case TitleScene.EXIT:
                        form.Close();
                        break;
                    }
                    break;

                case SELECT_SCENE_TITLE:
                {
                    title.Tick(TitleInput.Empty);
                    int result = select.Tick(input.GetCurrentSelectInput());
                    switch (result)
                    {
                    case SelectScene.NONE:
                        if (timer.ShouldRender() && video.CheckDrawable())
                        {
                            video.Begin();
                            video.DrawTitleScene(title);
                            video.DrawSelectScene(select);
                            video.DrawFps(timer.GetCurrentFps());
                            video.End();
                            video.Present();
                        }
                        sound.PlaySelectSound(select);
                        break;

                    case SelectScene.GOTO_TITLE:
                        state = TITLE_SCENE;
                        break;

                    default:
                        state = GAME_SCENE;
                        game  = stages[currentStageIndex = result].CreateGame();
                        break;
                    }
                }
                break;

                case GAME_SCENE:
                    if (bgm != null && !bgm.Playing)
                    {
                        bgm.Play();
                    }
                    switch (game.Tick(input.GetCurrentGameInput()))
                    {
                    case GameScene.NONE:
                        if (timer.ShouldRender() && video.CheckDrawable())
                        {
                            video.Begin();
                            video.DrawGameScene(game);
                            video.DrawFps(timer.GetCurrentFps());
                            video.End();
                            video.Present();
                        }
                        sound.PlayGameSound(game);
                        break;

                    case GameScene.RESET_GAME:
                        sound.StopSounds();
                        game = stages[currentStageIndex].CreateGame();
                        break;

                    case GameScene.CLEAR_GAME:
                        sound.StopSounds();
                        currentStageIndex = (currentStageIndex + 1) % numStages;
                        game = stages[currentStageIndex].CreateGame();
                        break;

                    case GameScene.SELECT:
                        if (timer.ShouldRender() && video.CheckDrawable())
                        {
                            video.Begin();
                            video.DrawGameScene(game);
                            video.DrawFps(timer.GetCurrentFps());
                            video.End();
                            video.Present();
                        }
                        sound.PlayGameSound(game);
                        select.CurrentStage = currentStageIndex;
                        state = SELECT_SCENE_GAME;
                        break;

                    case GameScene.GOTO_TITLE:
                        sound.StopSounds();
                        state = TITLE_SCENE;
                        break;
                    }
                    break;

                case SELECT_SCENE_GAME:
                    game.Tick(GameInput.Empty);
                    {
                        int result = select.Tick(input.GetCurrentSelectInput());
                        switch (result)
                        {
                        case SelectScene.NONE:
                            if (timer.ShouldRender() && video.CheckDrawable())
                            {
                                video.Begin();
                                video.DrawGameScene(game);
                                video.DrawSelectScene(select);
                                video.DrawFps(timer.GetCurrentFps());
                                video.End();
                                video.Present();
                            }
                            sound.PlayGameSound(game);
                            sound.PlaySelectSound(select);
                            break;

                        case SelectScene.GOTO_TITLE:
                            sound.StopSounds();
                            state = TITLE_SCENE;
                            break;

                        default:
                            sound.StopSounds();
                            game  = stages[currentStageIndex = result].CreateGame();
                            state = GAME_SCENE;
                            break;
                        }
                    }
                    break;
                }
                Application.DoEvents();
                timer.Wait();
            }

            if (bgm != null)
            {
                if (bgm.Playing)
                {
                    bgm.Stop();
                }
                bgm.Dispose();
                bgm = null;
            }
            video.Dispose();
            video = null;
            sound.Dispose();
            sound = null;
            input.Dispose();
            input = null;
        }
示例#30
0
文件: Thing.cs 项目: sinshu/mafia
 public abstract void Draw(MafiaVideo video, IntVector camera);
示例#31
0
 private void DrawStageNumber(MafiaVideo video)
 {
     int number = stageIndex + 1;
     if (number < 10)
     {
         video.Draw(0, 160, 16, 16, 0, number, Mafia.SCREEN_WIDTH / 2 - 8, Mafia.SCREEN_HEIGHT / 2 - 8);
     }
     else
     {
         video.Draw(0, 160, 16, 16, 0, (number / 10) % 10, Mafia.SCREEN_WIDTH / 2 - 8 - 8, Mafia.SCREEN_HEIGHT / 2 - 8);
         video.Draw(0, 160, 16, 16, 0, number % 10, Mafia.SCREEN_WIDTH / 2 - 8 + 8, Mafia.SCREEN_HEIGHT / 2 - 8);
     }
 }
示例#32
0
文件: FallBlock.cs 项目: sinshu/mafia
 public override void Draw(MafiaVideo video, IntVector camera)
 {
     if (!ShouldDraw(camera)) return;
     IntVector p = (IntVector)Position - camera;
     switch (type)
     {
         case Map.SPIKE_LEFT:
             video.Draw(48, 0, 16, 16, 0, 0, p.X, p.Y);
             break;
         case Map.SPIKE_UP:
             video.Draw(48, 0, 16, 16, 0, 1, p.X, p.Y);
             break;
         case Map.SPIKE_RIGHT:
             video.Draw(48, 0, 16, 16, 0, 2, p.X, p.Y);
             break;
         case Map.SPIKE_DOWN:
             video.Draw(48, 0, 16, 16, 0, 3, p.X, p.Y);
             break;
         default:
             video.Draw(32, 0, 16, 16, 0, 0, p.X, p.Y);
             break;
     }
 }
示例#33
0
文件: Spring.cs 项目: sinshu/mafia
 public override void Draw(MafiaVideo video, IntVector camera)
 {
     if (!ShouldDraw(camera, 0, 0, 16, 0)) return;
     IntVector p = (IntVector)Position - camera - new IntVector(0, 16);
     video.Draw(0, 64, 16, 32, 0, animation, p.X, p.Y);
 }
示例#34
0
文件: GameScene.cs 项目: sinshu/mafia
 public void Draw(MafiaVideo video)
 {
     map.Draw(video, (IntVector)camera);
     things.Draw(video, (IntVector)camera);
     if (!player.Missed)
     {
         if (currentNumCoins == 0)
         {
             // video.Draw(0, 320, 128, 64, 0, 0, Mafia.SCREEN_WIDTH / 2 - 64, Mafia.SCREEN_HEIGHT / 2 - 32);
             double waveWidth = 0;
             if (clearTimer < 60)
             {
                 waveWidth = (60 - clearTimer) / 2;
             }
             for (int i = 0; i < 64; i++)
             {
                 double x = Mafia.SCREEN_WIDTH / 2 - 64 + waveWidth * Math.Cos(Math.PI * i / 16.0 + Math.PI * clearTimer / 12.0 + Math.PI) + 2;
                 int y = Mafia.SCREEN_HEIGHT / 2 - 32;
                 video.DrawColor(0, 320, 128, 1, i, 0, (int)Math.Round(x), y + i + 2, Color.FromArgb(128, Color.Black));
             }
             for (int i = 0; i < 64; i++)
             {
                 double x = Mafia.SCREEN_WIDTH / 2 - 64 + waveWidth * Math.Cos(Math.PI * i / 16.0 + Math.PI * clearTimer / 12.0);
                 int y = Mafia.SCREEN_HEIGHT / 2 - 32;
                 video.Draw(0, 320, 128, 1, i, 0, (int)Math.Round(x), y + i);
             }
         }
         else
         {
             if (gameTimer < 300)
             {
                 video.DrawStringCenter(title, 1, 1, Color.Black);
                 video.DrawStringCenter(title, 0, 0, Color.White);
             }
             else
             {
                 video.DrawString(title, 9, 9, Color.Black);
                 video.DrawString(title, 8, 8, Color.White);
             }
             video.Draw(0, 160, 16, 16, 0, (firstNumCoins - currentNumCoins) % 10, Mafia.SCREEN_WIDTH - 48, Mafia.SCREEN_HEIGHT - 16);
             video.Draw(0, 160, 16, 16, 0, 10, Mafia.SCREEN_WIDTH - 32, Mafia.SCREEN_HEIGHT - 16);
             video.Draw(0, 160, 16, 16, 0, firstNumCoins % 10, Mafia.SCREEN_WIDTH - 16, Mafia.SCREEN_HEIGHT - 16);
         }
     }
 }