public void Action()
        {
            switch (step)
            {
            //遊戲進場說明
            case 0:
                Thread.Sleep(100);
                river.Action();
                river2.AntiAction();
                // 說明頁切換
                switch (explainPage)
                {
                case 1:
                    // mainCharater 動作
                    mainCharacter.Action();
                    mainCharacter.Jump(-7, 430);
                    break;

                case 2:
                    mainCharacter.Action();
                    break;

                case 3:
                    // yellowDragon 動作
                    yellowDragon[0].Action();
                    if (yellowDragon[0].Center.Y <= 350)
                    {
                        isUp = false;
                    }
                    else if (yellowDragon[0].Center.Y >= 600)
                    {
                        isUp = true;
                    }
                    if (isUp)
                    {
                        yellowDragon[0].Move(0, -20);
                    }
                    else if (!isUp)
                    {
                        yellowDragon[0].Move(0, 20);
                    }
                    break;
                }
                break;

            //遊戲開始
            case 1:
                countTime.StartT();
                Thread.Sleep(90);
                music.PlayMusic(4);

                if (yellowDragon[0] == null && yellowDragon[1] == null)
                {
                    if (winroad.Center.X < 520)
                    {
                        pinkDragon.Action();
                        pinkDragon.Move(-4, 0);
                        if (pinkDragon.isClick(mainCharacter.Center.X + 50, mainCharacter.Center.Y))
                        {
                            step = 5;
                        }
                    }
                    else
                    {
                        winroad.Move(-10, 0);
                        pinkDragon.Move(-10, 0);
                    }
                }

                // 所有圖片動畫
                if (winroad.Center.X > 520)
                {
                    river.Action();
                    river2.AntiAction();
                    grid.Action(-160, new Point(1900, 700), -10, 0);
                    background.Action(-440, new Point(1700, 340), -3, 0);
                }
                mainCharacter.Action();

                //---------------- Enemys
                Global.target = 0;
                for (int i = 0; i < yellow_NUM; i++)
                {
                    if (yellowDragon[i] != null)
                    {
                        Global.target += yellowDragon[i].Enemys;
                        yellowDragon[i].Action();
                        yellowDragon[i].Jump(grid.continuousActors[grid.continuousActors.Count - 1].Center, i);
                        if (yellowDragon[i].isClick(mainCharacter.Center.X, mainCharacter.Center.Y))
                        {
                            Console.WriteLine("撞到哪一隻 :" + i);
                            Global.HP -= 1;
                            music.PlayMusic(1);
                            if (Global.HP <= 0)
                            {
                                step = 3;
                            }
                            mainCharacter.Motion(2);
                        }
                        healthPts[i].Center = new Point(yellowDragon[i].Center.X, yellowDragon[i].Center.Y - 120);
                        healthPts[i].Health(yellowDragon[i].HP, 5);
                        if (yellowDragon[i].Enemys == 0 && yellowDragon[i] != null)
                        {
                            yellowDragon[i] = null;
                        }
                    }
                }

                // 恐龍是否走在路上
                touch = 0;
                for (int i = 0; i < grid.continuousActors.Count; i++)
                {
                    if (grid.continuousActors[i].isClick(mainCharacter.Center.X - 15, mainCharacter.Center.Y + 60))
                    {
                        touch++;
                        if (mainCharacter.Center.Y > 630)
                        {
                            touch--;
                        }
                    }
                }
                // 恐龍動作(跳/墜落)

                if (winroad.Center.X <= 750)
                {
                    mainCharacter.Center = new Point(mainCharacter.Center.X + 4, 550);
                }
                else
                {
                    mainCharacter.Jump2(-30, touch);
                }


                // 恐龍扣血
                if (mainCharacter.Center.Y > 950)
                {
                    Global.HP -= 1;
                    music.ContiPlayMusic("drop.wav");
                    if (Global.HP <= 0)
                    {
                        step = 3;
                    }
                    mainCharacter.Motion(2);
                    mainCharacter.Center = new Point(190, 190);
                    mainCharacter.t      = 0;
                    mainCharacter.isjump = false;
                }

                // 計時直到碰見粉紅
                if (!pinkDragon.isClick(mainCharacter.Center.X, mainCharacter.Center.Y))
                {
                    countTime.EndT();
                }
                break;

            //遊戲勝場
            case 2:
                music.StopMusic("cave2.wav");
                turn.TurnWin(pageName.mainPage);
                break;

            //遊戲敗場
            case 3:
                music.StopMusic("cave2.wav");
                turn.TurnGameOver(pageName.mainPage);
                break;

            case 4:
                Ranker ranker = new Ranker();
                ranker.Load();
                ranker.Clear();
                ranker.ShowRank(0);
                step = 6;
                break;

            case 5:
                switch (End)
                {
                case 0:
                    explain = new AnimateActor("story32", 1, new Point(550, 410), 2);
                    End     = 1;
                    Thread.Sleep(3500);
                    break;

                case 1:
                    explain.ClearImages();
                    explain.AddImage("story33", 1);
                    music.PlayMusic("hurt3.mp3");
                    End = 2;
                    Thread.Sleep(1000);
                    break;

                case 2:
                    explain.ClearImages();
                    explain.AddImage("story34", 1);
                    End = 3;
                    Thread.Sleep(2500);
                    music = null;
                    music = new Music("Stage1.mp3");
                    break;

                case 3:
                    explain.ClearImages();
                    explain.AddImage("story35", 1);
                    End = 4;
                    Thread.Sleep(2500);
                    break;

                case 4:
                    explain.ClearImages();
                    explain.AddImage("story36", 1);
                    Thread.Sleep(3500);
                    step = 4;
                    music.PlayMusic("Pass.mp3");
                    break;
                }

                break;

            case 6:
                turn.TurnWin(pageName.mainPage);
                break;
            }
        }
Example #2
0
        int actorChange = 0; // 角色瀏覽標籤

        //------------ TurnTableStage 建構子 ----------//
        public TurnTableStage()
        {
            turn        = new TurnPage();
            ranker      = new Ranker();
            music       = new Music(5);
            turnTable   = new TurnTable();
            click       = 1;
            Global.TIME = 0;
            ranker.Load();

            wood       = new Actor("wood", new Point(250, 390), 0.9f);
            background = new Actor("mainpageBackground", new Point(550, 394), 1.5f);
            rankpic    = new Button("rank0", 1, new Point(795, 350), 1.3f);

            Page         = new Button("redPage", 1, new Point(760, 365), 1.06f);
            redButton    = new Button("redButton0", 2, new Point(150, 160), 1.5f);
            blueButton   = new Button("blueButton0", 2, new Point(150, 460), 1.5f);
            greenButton  = new Button("greenButton0", 2, new Point(250, 310), 1.5f);
            purpleButton = new Button("purpleButton0", 2, new Point(250, 610), 1.5f);

            nextButtonLeft  = new AnimateActor("nextButton0", 1, new Point(710, 670), 13);
            nextButtonRight = new AnimateActor("nextButton1", 1, new Point(805, 670), 13);
            intro0          = new AnimateActor("intro0", 1, new Point(765, 200), 1);
            intro1          = new AnimateActor("intro1", 1, new Point(765, 200), 1);
            intro2          = new AnimateActor("intro2", 1, new Point(765, 200), 1);
            intro3          = new AnimateActor("intro3", 1, new Point(765, 200), 1);
            intro4          = new AnimateActor("intro4", 1, new Point(765, 200), 1);
            intro5          = new AnimateActor("intro5", 1, new Point(765, 200), 1);
            intro6          = new AnimateActor("intro6", 1, new Point(765, 200), 1);

            greenDragon  = new MainCharactor("dragon", 2, new Point(775, 500), 4.5f);
            orangeDragon = new OrangeDragon("orangedragon", 2, new Point(770, 500), 2.5f);
            bird         = new YellowBird("YellowBird_Hit", 3, new Point(775, 500), 2.5f);
            tinyDragon   = new TinyDragon("tinyDragon", 3, new Point(760, 500), 2f);
            brownDragon  = new AnimateActor("browndragon", 2, new Point(750, 500), 2.5f);
            blackDragon  = new BlackDragon("blackdragon", 2, new Point(735, 500), 5);
            yellowDragon = new YellowDragon("yellowdragon", 2, new Point(755, 500), 2.5f);


            nameTextbox = new TextBox();
            SetNameTextbox();
            pageLabel = new Label();
            SetPageLabel();
            turnLabel = new Label();
            SetTurnLabel();

            mode01           = new AnimateActor("Mode0", 1, new Point(550, 600), 2f);
            mode02           = new AnimateActor("Mode1", 1, new Point(760, 600), 2f);
            storyMode        = new AnimateActor("Story0", 1, new Point(970, 600), 2f);;
            storyModeExplain = new AnimateActor("modeStory0", 1, new Point(750, 335), 2.55f);

            cloud = new AnimateActor("cloud", 1, new Point(760, 55), 1);
            // 模式按鈕
            switch (Global.Mode)
            {
            case 0:
                rBtn0 = new AnimateActor("rrBtn0", 1, new Point(550, 175), 1.5f);
                rBtn1 = new AnimateActor("rBtn1", 1, new Point(750, 175), 1.5f);
                rBtn2 = new AnimateActor("rBtn2", 1, new Point(960, 175), 1.5f);
                break;

            case 1:
                rBtn0 = new AnimateActor("rBtn0", 1, new Point(550, 175), 1.5f);
                rBtn1 = new AnimateActor("rrBtn1", 1, new Point(750, 175), 1.5f);
                rBtn2 = new AnimateActor("rBtn2", 1, new Point(960, 175), 1.5f);
                break;

            case 2:
                rBtn0 = new AnimateActor("rBtn0", 1, new Point(550, 175), 1.5f);
                rBtn1 = new AnimateActor("rBtn1", 1, new Point(750, 175), 1.5f);
                rBtn2 = new AnimateActor("rrBtn2", 1, new Point(960, 175), 1.5f);
                break;
            }
        }
Example #3
0
        public void Action()
        {
            switch (step)
            {
            //遊戲進場說明
            case 0:
                Thread.Sleep(100);
                river.Action();
                river2.AntiAction();
                // 說明頁切換
                switch (explainPage)
                {
                case 0:
                    mainCharacter.Action();
                    // mainCharater 動作
                    if (mainCanJump)
                    {
                        if (mainCharacter.Center.Y >= 280 && touch == 0)
                        {
                            mainCharacter.Move(0, -3 * jumpt);
                            jumpt++;
                        }
                        else if (mainCharacter.Center.Y <= 430)
                        {
                            touch = -1;
                            mainCharacter.Move(0, 3 * jumpt);
                            jumpt--;
                            if (mainCharacter.Center.Y > 430)
                            {
                                mainCanJump = false;
                                jumpt       = 0;
                                touch       = 0;
                            }
                        }
                    }

                    break;

                case 1:
                    mainCharacter.Action();
                    break;

                case 2:
                    // yellowDragon 動作
                    yellowDragon[0].Action();
                    if (yellowDragon[0].Center.Y <= 350)
                    {
                        isUp = false;
                    }
                    else if (yellowDragon[0].Center.Y >= 600)
                    {
                        isUp = true;
                    }
                    if (isUp)
                    {
                        yellowDragon[0].Move(0, -20);
                    }
                    else if (!isUp)
                    {
                        yellowDragon[0].Move(0, 20);
                    }
                    break;
                }


                break;

            //遊戲開始
            case 1:
                countTime.StartT();
                Thread.Sleep(90);
                music.PlayMusic(4);
                if (yellowDragon[0].Enemys == 0 && yellowDragon[1].Enemys == 0)
                {
                    if (winroad.Center.X < 520)
                    {
                        pinkDragon.Action();
                        pinkDragon.Move(-4, 0);
                        if (pinkDragon.isClick(mainCharacter.Center.X + 50, mainCharacter.Center.Y))
                        {
                            step = 4;
                        }
                    }
                    else
                    {
                        winroad.Move(-10, 0);
                        pinkDragon.Move(-10, 0);
                    }
                }

                // 所有圖片動畫
                if (winroad.Center.X > 520)
                {
                    river.Action();
                    river2.AntiAction();
                    grid.Action(-160, new Point(1900, 700), -10, 0);
                    background.Action(-440, new Point(1700, 340), -3, 0);
                }
                mainCharacter.Action();

                //---------------- Enemys
                for (int i = 0; i < yellow_NUM; i++)
                {
                    if (yellowDragon[i] != null)
                    {
                        yellowDragon[i].Action();
                        yellowDragon[i].Jump(grid.continuousActors[grid.continuousActors.Count - 1].Center, i);
                        if (yellowDragon[i].isClick(mainCharacter.Center.X, mainCharacter.Center.Y))
                        {
                            Global.HP -= 1;
                            music.PlayMusic(1);
                            if (Global.HP <= 0)
                            {
                                step = 3;
                            }
                            mainCharacter.Motion(2);
                        }
                        healthPts[i].Center = new Point(yellowDragon[i].Center.X, yellowDragon[i].Center.Y - 120);
                        healthPts[i].Health(yellowDragon[i].HP, 5);
                    }
                }

                // 恐龍是否走在路上
                touch = 0;
                for (int i = 0; i < grid.continuousActors.Count; i++)
                {
                    if (grid.continuousActors[i].isClick(mainCharacter.Center.X - 15, mainCharacter.Center.Y + 60))
                    {
                        touch++;
                    }
                }

                // 恐龍動作(跳/墜落)
                if (ispower && jumpt > -10)
                {
                    jumpt--;
                }
                if (isjump)
                {
                    if (jumpt < 2)
                    {
                        mainCharacter.Move(0, -30 + jumpt);
                    }
                    else
                    {
                        isjump = false;
                        jumpt  = 0;
                    }

                    jumpt++;
                }
                else if (winroad.Center.X <= 750)
                {
                    mainCharacter.Center = new Point(mainCharacter.Center.X + 4, 550);
                }
                else if (touch == 0)
                {
                    mainCharacter.GMove(0, 3);
                }

                // 恐龍扣血
                if (mainCharacter.Center.Y > 950)
                {
                    Global.HP -= 1;
                    music.ContiPlayMusic("drop.wav");
                    if (Global.HP <= 0)
                    {
                        step = 3;
                    }
                    mainCharacter.Motion(2);
                    mainCharacter.Center = new Point(190, 190);
                    mainCharacter.t      = 0;
                    isjump = false;
                }

                // 計時直到碰見粉紅
                if (!pinkDragon.isClick(mainCharacter.Center.X, mainCharacter.Center.Y))
                {
                    countTime.EndT();
                }
                break;

            //遊戲勝場
            case 2:
                music.StopMusic("cave2.wav");
                turn.Turn(pageName.mainPage);
                break;

            //遊戲敗場
            case 3:
                music.StopMusic("cave2.wav");
                turn.Turn(pageName.mainPage);
                break;

            case 4:
                music.PlayMusic("Pass.mp3");
                Ranker ranker = new Ranker();
                ranker.Load();
                ranker.Clear();
                ranker.ShowRank(0);
                step = 2;
                break;
            }
        }
Example #4
0
        //-------------Thread 裡面的 動作-------------//
        public void Move()
        {
            switch (step)
            {
            //遊戲進場
            case 0:
                Thread.Sleep(70);
                if (WingL != null)
                {
                    WingL.Action();
                }
                if (WingR != null)
                {
                    WingR.Action();
                }
                break;

            //遊戲開始
            case 1:
                //在Thread裡面的動作記得要睡覺。
                countTime.StartT();
                Thread.Sleep(70);

                //角色的翻轉動作。
                if (Cloud._Angle >= 0)
                {
                    mainCharactor.Action();
                }
                else
                {
                    mainCharactor.ReAction();
                }

                //角色的動態圖
                if (WingL != null)
                {
                    WingL.Action();
                }
                if (WingR != null)
                {
                    WingR.Action();
                }
                yellowBird.Action();

                //翅膀是否碰到
                if (WingL != null)
                {
                    if (WingL.isClick(mainCharactor.Center.X, mainCharactor.Center.Y))
                    {
                        music.ContiPlayMusic("getWings.mp3");
                        Global.target -= 1;
                        WingL          = null;
                    }
                }
                if (WingR != null)
                {
                    if (WingR.isClick(mainCharactor.Center.X, mainCharactor.Center.Y))
                    {
                        music.ContiPlayMusic("getWings.mp3");
                        Global.target -= 1;
                        WingR          = null;
                    }
                }

                if (WingL == null && WingR == null)
                {
                    music.PlayMusic("change.wav");
                    mainCharactor.Motion(3);
                    if (Global.Mode == 1)
                    {
                        step = 4;
                    }
                    else
                    {
                        step = 2;
                    }
                }

                // 黃色小鳥移動與刷新
                if (yellowBird.Center.X < 0 && (stone.Center.Y > 500))
                {
                    yellowBird.HP = 2;
                    yellowBird.Motion(0);
                    yellowBird.Center = new Point(1300, 100);
                    stone.t           = 0;
                    stone.Center      = yellowBird.Center;
                }
                else
                {
                    yellowBird.Move(-20, 0);
                }

                // 黃色小鳥丟石頭與否
                if (stone.Center.Y <= yellowBird.Center.Y + 100)
                {
                    //當小鳥超過主角會自動釋放物體
                    if (yellowBird.Center.X <= mainCharactor.Center.X && stone.Center.X > 0)
                    {
                        if (!countTime.Sec(1))
                        {
                            music.ContiPlayMusic("Stonrfalling.mp3");
                        }
                        stone.GMove(0, 1);
                    }
                    else
                    {
                        //石頭沒超過主角,和鳥一起移動
                        stone.Center = new Point(yellowBird.Center.X, yellowBird.Center.Y + 50);
                    }
                }
                else
                {
                    //石頭自然釋出
                    if (stone.isClick(mainCharactor.Center.X, mainCharactor.Center.Y - 50))
                    {
                        if (countTime.MilSec(500))
                        {
                            Global.HP -= 2;
                            music.PlayMusic(1);
                        }
                        music.StopMusic("Stonrfalling.mp3");

                        if (Global.HP <= 0)
                        {
                            step = 3;
                        }
                    }
                    if (Cloud.isClick(stone.Center.X, stone.Center.Y - 50))
                    {
                        music.PlayMusic("punch.mp3");
                        if (stone.Center.X > Cloud.Center.X)
                        {
                            Cloud._Angle += Convert.ToInt32(Math.Sqrt(Math.Pow(stone.Center.X - Cloud.Center.X, 2) + Math.Pow(stone.Center.Y - Cloud.Center.Y, 2)) / 60);
                        }
                        else
                        {
                            Cloud._Angle += -Convert.ToInt32(Math.Sqrt(Math.Pow(stone.Center.X - Cloud.Center.X, 2) + Math.Pow(stone.Center.Y - Cloud.Center.Y, 2)) / 50);
                        }
                    }

                    stone.GMove(0, 1);
                }

                if (mainCharactor.Center.Y + Convert.ToInt32(-a * Math.Tan(mainCharactor.Sita)) > 900)
                {
                    Global.HP--;
                    if (Global.HP <= 0)
                    {
                        step = 3;
                    }
                    a  = 0;
                    t1 = t2 = 0;
                }

                //當板子開始有角度的時候
                if (Cloud._Angle > 0)
                {
                    //角色在板子上的(加)速度
                    a -= Convert.ToInt32(10 * Math.Sin(mainCharactor.Sita)) * t1 / 2;
                    //角色的速度為零時,時間參數歸零,避免角色暴衝
                    if (Convert.ToInt32(10 * Math.Sin(mainCharactor.Sita)) * t1 / 2 == 0)
                    {
                        t1 = 0;
                    }
                    //另一側的時間參數歸零
                    t2 = 0;
                    //時間參數是隨著執行次數而增加的
                    t1++;

                    //角色在斜面上移動,y的位置利用角度去算出確實位置,以保證角色維持在斜面上移動。
                    mainCharactor.CloudMove(Cloud.Center, -a, Convert.ToInt32(-a * Math.Tan(mainCharactor.Sita)));
                    //角色和斜面同角度。
                    mainCharactor._Angle = Cloud._Angle;
                }
                else if (Cloud._Angle < 0)
                {
                    a -= Convert.ToInt32(10 * Math.Sin(mainCharactor.Sita)) * t2 / 2;
                    if (Convert.ToInt32(10 * Math.Sin(mainCharactor.Sita)) * t2 / 2 == 0)
                    {
                        t2 = 0;
                    }

                    t1 = 0;
                    t2++;
                    mainCharactor.CloudMove(Cloud.Center, -a, Convert.ToInt32(-a * Math.Tan(mainCharactor.Sita)));
                    mainCharactor._Angle = Cloud._Angle;
                }
                else if (Cloud._Angle == 0)
                {
                    mainCharactor._Angle = Cloud._Angle;
                    mainCharactor.CloudMove(Cloud.Center, -a, Convert.ToInt32(-a * Math.Tan(mainCharactor.Sita)));
                    t1 = t2 = 0;
                }
                countTime.EndT();
                break;

            //遊戲勝場
            case 2:
                turn.TurnWin(pageName.stage02);
                break;

            //遊戲敗場
            case 3:
                turn.TurnGameOver(pageName.mainPage);
                break;

            //遊戲過關
            case 4:
                music.PlayMusic("Pass.mp3");
                Ranker ranker = new Ranker();
                ranker.Load();
                ranker.Clear();
                ranker.ShowRank(1);
                step = 5;
                break;

            case 5:
                turn.TurnWin(pageName.mainPage);
                break;
            }
        }
Example #5
0
        //---------------- 加在 Form1.Thread 裡 ----------------//
        public void Move()
        {
            switch (step)
            {
            //遊戲進場
            case 0:
                Thread.Sleep(100);
                if (explain != null)
                {
                    explain.Action();
                }

                break;

            //遊戲開始
            case 1:
                music.ContiPlayMusic("fire2.mp3");
                //在Thread裡面的動作記得要睡覺。
                countTime.StartT();
                Thread.Sleep(50);
                mainCharactor.Action();
                blackDragon.Action();
                redfire.Action();
                bluefire.Action();

                //background.Center = new Point(background.Center.X + 30, background.Center.Y - 30);
                //background.Center = new Point(background.Center.X - 30, background.Center.Y + 30);

                //----------------  clouds
                clouds.Action(-150, new Point(1300, 0 + 50 * randomizer.Next(1, 5)), -1, 0);
                countTime.EndT();
                break;

            //遊戲勝場
            case 2:
                music.StopMusic("fire2.mp3");
                turn.TurnWin(pageName.stage03);
                music.PlayMusic("burned.mp3");
                break;

            //遊戲敗場
            case 3:
                music.StopMusic("fire2.mp3");

                turn.TurnGameOver(pageName.mainPage);
                break;

            //遊戲過關
            case 4:
                music.PlayMusic("Pass.mp3");
                Ranker ranker = new Ranker();
                ranker.Load();
                ranker.Clear();
                ranker.ShowRank(2);
                step = 5;
                break;

            case 5:
                turn.TurnWin(pageName.mainPage);
                break;
            }
        }