コード例 #1
0
    void Handle_InputKey(int control, HpyInputKey key, bool down)
    {
        #region keydown

        if (down && key == HpyInputKey.BS_Up)
        {
            SelectPrev();
            //StartCoroutine("_Coro_SelectPrev");
        }
        else if (down && key == HpyInputKey.BS_Down)
        {
            SelectNext();
            //StartCoroutine("_Coro_SelectNext");
        }
        else if (down && key == HpyInputKey.BS_Left)
        {
            if (mCurCursorIdx == (int)Option.Difficult)//���׶�
            {
                Ctrl_GameDifficul.StartChange(false);
            }
            else if (mCurCursorIdx == (int)Option.CoinTicketRatio)//��Ʊ����
            {
                if (mCurrentCoinTicketRotioSelect == null)
                {
                    mCurrentCoinTicketRotioSelect = Ctrl_CoinTicketRatio_Coin;
                    mCurrentCoinTicketRotioSelect.GetComponent <Ef_RendererFlash>().StartFlash();
                }
                else
                {
                    mCurrentCoinTicketRotioSelect.GetComponent <Ef_RendererFlash>().StopFlash();
                    mCurrentCoinTicketRotioSelect.StartChangeNumViewing(-1);
                }
                mIsMainMenuMovable = false;//���˵������ƶ�
            }
            else if (mCurCursorIdx == (int)Option._OutBountyType)
            {
                Ctrl_OutBountyType.StartChange(false);
            }
            else if (mCurCursorIdx == (int)Option._GunLayoutType)
            {
                Ctrl_GunLayouType.StartChange(false);
            }
            //else if (mCurCursorIdx == 4)
            //    Ctrl_IsBulletCross.StartChange(false);
            else if (mCurCursorIdx == (int)Option.ScoreChange)
            {
                Ctrl_ScoreChangeVal.StartChangeNumViewing((int cur) => { return(-GetChangeValL(cur)); });
            }
            //else if (mCurCursorIdx == 6)
            //    Ctrl_MinScore.StartChangeNumViewing((int cur) => { return -GetChangeValL(cur); });
            else if (mCurCursorIdx == (int)Option.MaxGunScore)
            {
                Ctrl_MaxScore.StartChangeNumViewing((int cur) => { return(-GetChangeValL(cur)); });
            }
            else if (mCurCursorIdx == (int)Option.LaguageSelect)
            {
                Ctrl_Language.StartChange(false);
            }
        }

        else if (down && key == HpyInputKey.BS_Right)
        {
            if (mCurCursorIdx == (int)Option.Difficult)//���׶�
            {
                Ctrl_GameDifficul.StartChange(true);
            }
            else if (mCurCursorIdx == (int)Option.CoinTicketRatio)//��Ʊ����
            {
                if (mCurrentCoinTicketRotioSelect == null)
                {
                    mCurrentCoinTicketRotioSelect = Ctrl_CoinTicketRatio_Coin;
                    mCurrentCoinTicketRotioSelect.GetComponent <Ef_RendererFlash>().StartFlash();
                }
                else
                {
                    mCurrentCoinTicketRotioSelect.GetComponent <Ef_RendererFlash>().StopFlash();
                    mCurrentCoinTicketRotioSelect.StartChangeNumViewing(1);
                }
                mIsMainMenuMovable = false;//���˵������ƶ�
            }
            else if (mCurCursorIdx == (int)Option._OutBountyType)
            {
                Ctrl_OutBountyType.StartChange(true);
            }
            else if (mCurCursorIdx == (int)Option._GunLayoutType)
            {
                Ctrl_GunLayouType.StartChange(true);
            }
            //else if (mCurCursorIdx == 4)
            //    Ctrl_IsBulletCross.StartChange(true);
            else if (mCurCursorIdx == (int)Option.ScoreChange)
            {
                Ctrl_ScoreChangeVal.StartChangeNumViewing(GetChangeValR);
            }
            //else if (mCurCursorIdx == 6)
            //    Ctrl_MinScore.StartChangeNumViewing(GetChangeValR);
            else if (mCurCursorIdx == (int)Option.MaxGunScore)
            {
                Ctrl_MaxScore.StartChangeNumViewing(GetChangeValR);
            }
            else if (mCurCursorIdx == (int)Option.LaguageSelect)
            {
                Ctrl_Language.StartChange(true);
            }
        }

        else if (down && key == HpyInputKey.BS_Confirm)
        {
            //��Ч-��̨
            if (GameMain.Singleton.SoundMgr.snd_bkBtn != null)
            {
                GameMain.Singleton.SoundMgr.PlayOneShot(GameMain.Singleton.SoundMgr.snd_bkBtn);
            }

            if (mCurCursorIdx == (int)Option.CoinTicketRatio)//��Ʊ����
            {
                if (mCurrentCoinTicketRotioSelect == null)
                {
                    mCurrentCoinTicketRotioSelect = Ctrl_CoinTicketRatio_Coin;
                    mCurrentCoinTicketRotioSelect.GetComponent <Ef_RendererFlash>().StartFlash();
                    mIsMainMenuMovable = false;
                }
                else
                {
                    mCurrentCoinTicketRotioSelect.GetComponent <Ef_RendererFlash>().StopFlash();
                    mCurrentCoinTicketRotioSelect = null;
                    mIsMainMenuMovable            = true;
                }
            }
            else if (mCurCursorIdx == (int)Option.RecoverSetting)//�ָ�Ĭ��ֵ
            {
                Ctrl_GameDifficul.ViewIdx              = (int)BackStageSetting.Def_GameDifficult;
                Ctrl_CoinTicketRatio_Coin.NumViewing   = BackStageSetting.Def_CoinTicketRatio_Coin;
                Ctrl_CoinTicketRatio_Ticket.NumViewing = BackStageSetting.Def_CoinTicketRatio_Ticket;
                //Ctrl_IsBulletCross.ViewIdx = BackStageSetting.Def_IsBulletCrossWhenScreenNet ? 1 : 0;
                Ctrl_ScoreChangeVal.NumViewing = BackStageSetting.Def_ScoreChangeValue;
                Ctrl_MaxScore.NumViewing       = BackStageSetting.Def_ScoreMax;

                //Ctrl_MinScore.NumViewing = BackStageSetting.Def_ScoreMin;
                Ctrl_OutBountyType.ViewIdx = (int)BackStageSetting.Def_OutBountyType;
                Ctrl_GunLayouType.ViewIdx  = (int)BackStageSetting.Def_GunLayoutType;
                Ctrl_Language.ViewIdx      = (int)BackStageSetting.Def_LanguageUsing;
            }
            else if (mCurCursorIdx == (int)Option.SaveSetting)//�����˳�
            {
                //���� �Ѷ� �� ��Ʊ �����Ƿ��иı�,�еĻ�����Ҫ������0 ,�����˳�
                bool needCodePrint = false;
                //����
                BackStageSetting bsSetting = GameMain.Singleton.BSSetting;
                if ((int)mEnterVal_GameDifficult != Ctrl_GameDifficul.ViewIdx)
                {
                    bsSetting.GameDifficult_.Val = (GameDifficult)Ctrl_GameDifficul.ViewIdx;
                    needCodePrint = true;
                }
                if (mEnterVal_CoinTicketRatio_Coin != Ctrl_CoinTicketRatio_Coin.NumViewing)
                {
                    bsSetting.CoinTicketRatio_Coin.Val = Ctrl_CoinTicketRatio_Coin.NumViewing;
                    needCodePrint = true;
                }
                if (mEnterVal_CoinTicketRatio_Ticket != Ctrl_CoinTicketRatio_Ticket.NumViewing)
                {
                    bsSetting.CoinTicketRatio_Ticket.Val = Ctrl_CoinTicketRatio_Ticket.NumViewing;
                    needCodePrint = true;
                }

                //if ((mEnterVal_IsBulletCross?1:0) != Ctrl_IsBulletCross.ViewIdx)
                //{
                //    bsSetting.IsBulletCrossWhenScreenNet.Val = Ctrl_IsBulletCross.ViewIdx == 1 ? true : false;
                //}

                if (mEnterVal_ScoreChangeValue != Ctrl_ScoreChangeVal.NumViewing)
                {
                    bsSetting.ScoreChangeValue.Val = Ctrl_ScoreChangeVal.NumViewing;
                    bsSetting.ScoreMin.Val         = Ctrl_ScoreChangeVal.NumViewing;
                }

                if (mEnterVal_Scoremax != Ctrl_MaxScore.NumViewing)
                {
                    bsSetting.ScoreMax.Val = Ctrl_MaxScore.NumViewing;
                }

                //if (mEnterVal_Scoremin != Ctrl_MinScore.NumViewing)
                //{
                //    bsSetting.ScoreMin.Val = Ctrl_MinScore.NumViewing;
                //}

                if ((int)mEnterVal_OutBountyType != Ctrl_OutBountyType.ViewIdx)
                {
                    bsSetting.OutBountyType_.Val = (OutBountyType)Ctrl_OutBountyType.ViewIdx;
                }

                if ((int)mEnterVal_GunLayoutType != Ctrl_GunLayouType.ViewIdx)
                {
                    bsSetting.GunLayoutType_.Val = (GunLayoutType)Ctrl_GunLayouType.ViewIdx;
                }

                if ((int)mEnterVal_Language != Ctrl_Language.ViewIdx)
                {
                    bsSetting.LaguageUsing.Val = (Language)Ctrl_Language.ViewIdx;
                    if (GameMain.EvtLanguageChange != null)
                    {
                        GameMain.EvtLanguageChange(bsSetting.LaguageUsing.Val);
                    }
                }
                if (needCodePrint)
                {
                    gameObject.SetActiveRecursively(false);
                    GameMain.Singleton.BSSetting.CodePrintCurrentAction.SetImmdiately(false);//��0״̬
                    GameMain.Singleton.BSSetting.IsCodePrintClearAllData.SetImmdiately(true);
                    //BackstageMain.Singleton.WndCodePrint.gameObject.SetActiveRecursively(true);
                    BackstageMain.Singleton.WndCodePrint.Enter();
                }
                else
                {
                    BackToMainMenu();
                }
            }
            else if (mCurCursorIdx == (int)Option.Quit)//�������˳�
            {
                //��Ч-��̨
                if (GameMain.Singleton.SoundMgr.snd_bkBtn != null)
                {
                    GameMain.Singleton.SoundMgr.PlayOneShot(GameMain.Singleton.SoundMgr.snd_bkBtn);
                }

                BackToMainMenu();
            }
        }

        #endregion

        #region keyup
        if (!down && key == HpyInputKey.BS_Up)
        {
            //StopCoroutine("_Coro_SelectPrev");
        }
        else if (!down && key == HpyInputKey.BS_Down)
        {
            //StopCoroutine("_Coro_SelectNext");
        }
        else if (!down && key == HpyInputKey.BS_Left)
        {
            if (mCurCursorIdx == (int)Option.Difficult)
            {
                Ctrl_GameDifficul.StopChange();
            }
            if (mCurCursorIdx == (int)Option.CoinTicketRatio)
            {
                if (mCurrentCoinTicketRotioSelect != null)
                {
                    mCurrentCoinTicketRotioSelect.StopChangeNumViewing();
                    mCurrentCoinTicketRotioSelect.GetComponent <Ef_RendererFlash>().StartFlash();
                }
            }
            else if (mCurCursorIdx == (int)Option._OutBountyType)
            {
                Ctrl_OutBountyType.StopChange();
            }
            else if (mCurCursorIdx == (int)Option._GunLayoutType)
            {
                Ctrl_GunLayouType.StopChange();
            }
            //else if (mCurCursorIdx == 4)
            //     Ctrl_IsBulletCross.StopChange();
            else if (mCurCursorIdx == (int)Option.ScoreChange)
            {
                Ctrl_ScoreChangeVal.StopChangeNumViewing();
            }
            //else if (mCurCursorIdx == 6)
            //    Ctrl_MinScore.StopChangeNumViewing();
            else if (mCurCursorIdx == (int)Option.MaxGunScore)
            {
                Ctrl_MaxScore.StopChangeNumViewing();
            }
            else if (mCurCursorIdx == (int)Option.LaguageSelect)
            {
                Ctrl_Language.StopChange();
            }
        }
        else if (!down && key == HpyInputKey.BS_Right)
        {
            if (mCurCursorIdx == (int)Option.Difficult)
            {
                Ctrl_GameDifficul.StopChange();
            }
            if (mCurCursorIdx == (int)Option.CoinTicketRatio)
            {
                if (mCurrentCoinTicketRotioSelect != null)
                {
                    mCurrentCoinTicketRotioSelect.StopChangeNumViewing();
                    mCurrentCoinTicketRotioSelect.GetComponent <Ef_RendererFlash>().StartFlash();
                }
            }
            else if (mCurCursorIdx == (int)Option._OutBountyType)
            {
                Ctrl_OutBountyType.StopChange();
            }
            else if (mCurCursorIdx == (int)Option._GunLayoutType)
            {
                Ctrl_GunLayouType.StopChange();
            }
            //else if (mCurCursorIdx == 4)
            //    Ctrl_IsBulletCross.StopChange();
            else if (mCurCursorIdx == (int)Option.ScoreChange)
            {
                Ctrl_ScoreChangeVal.StopChangeNumViewing();
            }
            //else if (mCurCursorIdx == 6)
            //    Ctrl_MinScore.StopChangeNumViewing();
            else if (mCurCursorIdx == (int)Option.MaxGunScore)
            {
                Ctrl_MaxScore.StopChangeNumViewing();
            }
            else if (mCurCursorIdx == (int)Option.LaguageSelect)
            {
                Ctrl_Language.StopChange();
            }
        }
        #endregion
    }