示例#1
0
 // Use this for initialization
 void Start()
 {
     //ゲームコントロールスクリプトの取得
     {
         var go = GameObject.Find("GameControl");
         GameControl = go.GetComponent<gamemain>();
         Camera2DControl = go.GetComponent<camera2d>();
         effectcontrol = go.GetComponent<effect_control>();
     }
     {
         var go = GameObject.Find("SoundContrlo");
         soundcontrol = go.GetComponent<sound>();
     }
     {
         //プレイヤーのgameobjectから動作を判断する
         var go = GameObject.Find("character_template_3head_Control");
         playercntrol = go.GetComponent<player>();
     }
 }
示例#2
0
    //コリジョンコールバック
    public void collision_callback( gamemain.COLLISION my, gamemain.COLLISION you )
    {
        switch( you.coltype )
        {
        case gamemain.COLTYPE.EN_COLTYPE_PLAYER:
            //相手がプレイヤー
            break;
        case gamemain.COLTYPE.EN_COLTYPE_PLAYER_SHOT:
            if (my.coltype == gamemain.COLTYPE.EN_COLTYPE_ENEMY)
            {
                //相手がプレイヤー攻撃
                player playerclass = you.obj.GetComponent<player>();
                enemy enemyclass = my.obj.GetComponent<enemy>();

                if ((hit_muteki == 0 ) && ( life > 0 ))
                {
                    life -= 1;										//ライフ

                    //SE再生
                    soundcontrol.PlaySE( sound.SE_TYPE.HIT1 );
                    //ノックバック設定
                    enemyclass.Set_knockback( 30, playerclass.direction );
                    enemyclass.setjump(1000);
                    //エフェクトの作成
                    effectcontrol.CreateEffect(0, you.x, you.y);
                    effectcontrol.CreateEffect(6, you.x, you.y);
                    effectcontrol.CreateEffect(8, you.x, you.y);
                }
            }
            break;
        case gamemain.COLTYPE.EN_COLTYPE_ENEMY:
            //相手が敵
            break;
        case gamemain.COLTYPE.EN_COLTYPE_ENEMY_SHOT:
            //相手が敵の攻撃
            break;
        case gamemain.COLTYPE.EN_COLTYPE_ITEM:
            //相手がアイテム
            break;
        }
    }
示例#3
0
 // Use this for initialization
 void Start()
 {
     //ゲームコントロールスクリプトの取得
     {
         var go = GameObject.Find("GameControl");
         GameControl = go.GetComponent<gamemain>();
         Camera2DControl = go.GetComponent<camera2d>();
         effectcontrol = go.GetComponent<effect_control>();
     }
     {
         var go = GameObject.Find("SoundContrlo");
         soundcontrol = go.GetComponent<sound>();
     }
     direction = 0;									//左向き
 }
示例#4
0
    //コリジョンコールバック
    public void collision_callback( gamemain.COLLISION my, gamemain.COLLISION you )
    {
        switch( you.coltype )
        {
        case gamemain.COLTYPE.EN_COLTYPE_PLAYER:
            //相手がプレイヤー
            break;
        case gamemain.COLTYPE.EN_COLTYPE_PLAYER_SHOT:
            //相手がプレイヤー攻撃
            break;
        case gamemain.COLTYPE.EN_COLTYPE_ENEMY:
            if (my.coltype == gamemain.COLTYPE.EN_COLTYPE_PLAYER)
            {
                //相手が敵
                //重ならない様に位置を補正
                //敵側の位置もここで補正するので敵側に補正処理はいらない
                player playerclass = my.obj.GetComponent<player>();
                enemy enemyclass = you.obj.GetComponent<enemy>();

                Vector2 mypos = playerclass.player_pos;
                Vector2 youpos = enemyclass.player_pos;

                if ( mypos.x < youpos.x )
                {
                    //自分の右側から相手の左側を引くと移動量がでる
                    float move_x = ( mypos.x + ( my.w / 2.0f ) ) - ( youpos.x - ( you.w / 2.0f ) );
                    move_x = move_x / 2.0f;

                    mypos.x = mypos.x - move_x;
                    playerclass.player_pos = mypos;

                    youpos.x = youpos.x + move_x;
                    enemyclass.player_pos = youpos;
                }
                else
                {
                    //自分の右側から相手の左側を引くと移動量がでる
                    float move_x = ( youpos.x + ( you.w / 2.0f ) ) - ( mypos.x - ( my.w / 2.0f ) );
                    move_x = move_x / 2.0f;

                    mypos.x = mypos.x + move_x;
                    playerclass.player_pos = mypos;

                    youpos.x = youpos.x - move_x;
                    enemyclass.player_pos = youpos;
                }

            }
            if (my.coltype == gamemain.COLTYPE.EN_COLTYPE_PLAYER_SHOT)
            {
            }
            break;
        case gamemain.COLTYPE.EN_COLTYPE_ENEMY_SHOT:
            //相手が敵の攻撃
            if (my.coltype == gamemain.COLTYPE.EN_COLTYPE_PLAYER)
            {
                //相手がプレイヤー攻撃
                player playerclass = my.obj.GetComponent<player>();
                enemy enemyclass = you.obj.GetComponent<enemy>();

                if (hit_muteki == 0 )
                {
                    if ( defense == true )
                    {
                        //SE再生
                        soundcontrol.PlaySE( sound.SE_TYPE.DEFENSE );
                        //ノックバック設定
                        playerclass.Set_defense_knockback( 10, enemyclass.direction );
                        enemyclass.Set_knockback( 20, playerclass.direction );
        //						playerclass.setjump(1000);
                        //エフェクトの作成
                        effectcontrol.CreateEffect(1, you.x, you.y);
        //						effectcontrol.CreateEffect(7, you.x, you.y);
        //						effectcontrol.CreateEffect(8, you.x, you.y);
                    }
                    else
                    {
                        //SE再生
                        soundcontrol.PlaySE( sound.SE_TYPE.HIT1 );
                        //ノックバック設定
                        playerclass.Set_knockback( 30, enemyclass.direction );
                        playerclass.setjump(1000);
                        Set_damege_flash( 20 );
                        //エフェクトの作成
                        effectcontrol.CreateEffect(0, you.x, you.y);
                        effectcontrol.CreateEffect(6, you.x, you.y);
                        effectcontrol.CreateEffect(8, you.x, you.y);
                    }
                }
            }
            break;
        case gamemain.COLTYPE.EN_COLTYPE_ITEM:
            //相手がアイテム
            break;
        }
    }
        protected override void LoadContent()
        {
            ressource.loadcontent(Content);
            spriteBatch = new SpriteBatch(GraphicsDevice);

            gameover = new GameOverScreen(this, spriteBatch, ressource.ecriture, ressource.gameover);
            Components.Add(gameover);
            gameover.hide();

            edm = new EDM(this, spriteBatch);
            Components.Add(edm);
            edm.hide();

            pause = new menudepause(this, spriteBatch, ressource.ecriture, ressource.pixel);
            Components.Add(pause);
            pause.hide();

            menu = new menu(this, spriteBatch, Content.Load<SpriteFont>("SpriteFont"), ressource.templar);
            Components.Add(menu);
            menu.hide();

            menudujeu = new menudujeu(this, spriteBatch, Content.Load<SpriteFont>("spriteFont"), ressource.th);
            Components.Add(menudujeu);
            menudujeu.hide();

            option = new option(this, spriteBatch, Content.Load<SpriteFont>("spriteFont"), ressource.option);
            Components.Add(option);
            option.hide();

            main = new gamemain(this, spriteBatch, activeScreen);
            Components.Add(main);
            main.hide();

            activeScreen = menu;
            activeScreen.Show();

            MediaPlayer.Play(ressource.menu);
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume = 0;

            SoundEffect.MasterVolume = 0.05f;

            ecran = false;
        }
        protected override void Update(GameTime gameTime)
        {
            /* timer_musique++;

            while (MediaPlayer.Volume != 10)
                if (timer_musique == 30)
                {
                    MediaPlayer.Volume++;
                    timer_musique = 0;
                }*/

            keyboard = Keyboard.GetState();

            # region gameover
            if (activeScreen == gameover)
            {
                if (checkKey(Keys.Enter))
                {
                    if (gameover.SelectedIndex == 0)
                    {

                    }

                    if (gameover.SelectedIndex == 1)
                    {
                        ressource.selection.Play();
                        activeScreen.hide();
                        activeScreen = menu;
                        activeScreen.Show();
                    }

                    if (gameover.SelectedIndex == 2)
                    {
                        ressource.selection.Play();
                        this.Exit();
                    }

                }

            }
            #endregion

            #region screen_menu_principal

            if (activeScreen == menu)
            {
                if (checkKey(Keys.Enter))
                {
                    if (menu.SelectedIndex == 0)
                    {
                        ressource.selection.Play();
                        activeScreen.hide();
                        activeScreen = menudujeu;
                        activeScreen.Show();
                    }

                    else if (menu.SelectedIndex == 1)
                    {

                    }

                    else if (menu.SelectedIndex == 2)
                    {
                        ressource.selection.Play();
                        activeScreen.hide();
                        activeScreen = edm;
                        activeScreen.Show();
                    }

                    else if (menu.SelectedIndex == 3)
                    {
                        ressource.selection.Play();
                        activeScreen.hide();
                        activeScreen = option;
                        activeScreen.Show();
                    }

                    else if (menu.SelectedIndex == 4)
                    {
                        ressource.selection.Play();
                        this.Exit();
                    }
                }
            }

            #endregion

            #region menu_1_Joueur

            else if (activeScreen == menudujeu)
            {
                if (checkKey(Keys.Enter))
                {

                    if (menudujeu.SelectedIndex == 0)
                    {
                        main = new gamemain(this, spriteBatch, activeScreen);
                        Components.Add(main);
                        main.hide();

                        ressource.selection.Play();
                        activeScreen.hide();
                        activeScreen = main;
                        activeScreen.Show();
                    }

                    else
                        if (menudujeu.SelectedIndex == 1)
                        {

                        }

                        else
                            if (menudujeu.SelectedIndex == 2)
                            {
                                ressource.selection.Play();
                                activeScreen.hide();
                                activeScreen = menu;
                                activeScreen.Show();
                            }
                }
            }

            #endregion

            #region screen_action
            else if (activeScreen == main)
            {
                if (checkKey(Keys.Escape))
                {
                    activeScreen.hide();
                    activeScreen = pause;
                    activeScreen.Show();
                }
            }
            #endregion

            #region screen_pause
            else
                if (activeScreen == pause)
                {
                    if (checkKey(Keys.Enter))
                    {

                        if (pause.SelectedIndex == 0)
                        {

                        }

                        else
                            if (pause.SelectedIndex == 1)
                            {

                            }
                            else
                                if (pause.SelectedIndex == 2)
                                {

                                }
                                else
                                    if (pause.SelectedIndex == 3)
                                    {
                                        ressource.selection.Play();
                                        activeScreen.hide();
                                        activeScreen = menu;
                                        activeScreen.Show();
                                    }
                    }

                    if (checkKey(Keys.Escape))
                    {
                        activeScreen.hide();
                        activeScreen = main;
                        activeScreen.Show();
                    }
                }
            #endregion

            #region screen_option
                else
                    if (activeScreen == option)
                    {
                        if (checkKey(Keys.Enter))
                        {
                            if (option.SelectedIndex == 0)
                            {
                                ressource.selection.Play();

                                if (ecran == false)
                                {
                                    graphics.ToggleFullScreen();
                                    graphics.PreferredBackBufferHeight = 1920;
                                    graphics.PreferredBackBufferWidth = 1080;

                                    ecran = true;
                                }
                            }

                            if (option.SelectedIndex == 1)
                            {
                                ressource.selection.Play();

                                if (ecran == true)
                                {
                                    graphics.ToggleFullScreen();
                                    graphics.PreferredBackBufferHeight = 1920;
                                    graphics.PreferredBackBufferWidth = 1080;
                                    ecran = false;
                                }
                            }

                            if (option.SelectedIndex == 2)
                            {
                                ressource.selection.Play();
                                MediaPlayer.IsMuted = false;
                            }

                            if (option.SelectedIndex == 3)
                            {
                                ressource.selection.Play();
                                MediaPlayer.IsMuted = true;
                            }

                            if (option.SelectedIndex == 4)
                            {
                                ressource.selection.Play();
                                activeScreen.hide();
                                activeScreen = menu;
                                activeScreen.Show();
                            }
                        }
                    }
                #endregion

            #region screen_EDM

            if (activeScreen == edm)
            {
                if (checkKey(Keys.Escape))
                {
                    activeScreen.hide();
                    activeScreen = pause;
                    activeScreen.Show();
                }
            }
            #endregion

            base.Update(gameTime);

            oldKeyboard = keyboard;
        }