// 顯示武器範圍
    private void ShowWeaponRange( SelectFunctionMode _Mode )
    {
        // Debug.Log( "ShowWeaponRange()" ) ;
        UnitWeaponSystem weaponSys = this.gameObject.GetComponent<UnitWeaponSystem>() ;
        if( null == weaponSys )
            return ;

        switch( _Mode )
        {
        case SelectFunctionMode.WeaponPhaser :
            weaponSys.ActiveWeaponRangeObject( "Weapon_Phaser" ) ;
            break ;
        case SelectFunctionMode.WeaponTorpedo :
            weaponSys.ActiveWeaponRangeObject( "Weapon_PhotonTorpedo" ) ;
            break ;
        case SelectFunctionMode.FunctionTrakorBeam :
            weaponSys.ActiveWeaponRangeObject( "Weapon_TrackorBeam" ) ;
            break ;
        case SelectFunctionMode.SpecialModeMultipleAttack :
            // Debug.Log( "SelectFunctionMode.SpecialModeMultipleAttack()" ) ;
            weaponSys.ActiveWeaponRangeObject( "Weapon_Phaser" ) ;
            weaponSys.ActiveWeaponRangeObject( "Weapon_PhotonTorpedo" ) ;
            break ;
        }
    }
    // 上下切換一格的功能 set to m_SelectModeNow
    private void SwitchControlModeByOneStep( bool _positive )
    {
        int step = ( true == _positive ) ? 1 : -1 ;

        if( false == _positive &&
            m_SelectModeNow == SelectFunctionMode.None )
            m_SelectModeNow = SelectFunctionMode.FunctionTrakorBeam ;
        else if( true == _positive &&
                 m_SelectModeNow == SelectFunctionMode.FunctionTrakorBeam )
            m_SelectModeNow = SelectFunctionMode.None ;
        else
            m_SelectModeNow = (SelectFunctionMode) ( (int) m_SelectModeNow + step ) ;
    }
 // 隱藏 所有 control panel active 除了指定的模式之外
 private void HideAllControlPanel( SelectFunctionMode _Exculde = SelectFunctionMode.None )
 {
     int ExculdeIndex = ((int)_Exculde - (int)SelectFunctionMode.WeaponPhaser) ;
     for( int i = 0 ; i < 3 ; ++i )
     {
         SelectFunctionMode index = (SelectFunctionMode)( i + (int)(SelectFunctionMode.WeaponPhaser) ) ;
         if( _Exculde != SelectFunctionMode.None &&
             i != ExculdeIndex )
         {
             ShowGUITexture.Show( m_ControlPanelsActive[ index ].Obj , false , false , false ) ;
         }
     }
 }
    // 顯示指定控制面版
    private void ShowControlPanel( SelectFunctionMode _mode )
    {
        int index = ((int)_mode - (int)SelectFunctionMode.WeaponPhaser) ;

        if( index >= 0 && index < 3 )
        {
            ShowGUITexture.Show( m_ControlPanelsActive[ _mode ].Obj , true , false , false ) ;
            ControlPanelActive controlPanel = m_ControlPanelsActive[ _mode ].Obj.GetComponent<ControlPanelActive>() ;
            if( null != controlPanel )
                controlPanel.m_CloseActive.Active() ;

        }
    }
 private bool CheckControlPanelsUnActive( SelectFunctionMode _Mode )
 {
     UnitData unitData = this.gameObject.GetComponent<UnitData>() ;
     string keyword = ConstName.FindWeaponKeyword( _Mode ) ;
     List<string> componentVec = unitData.GetAllComponentNameVecWithKeyword( keyword ) ;
     return ( componentVec.Count > 0 ) ;
 }
    /**
     * @brief Switch control mode to _Mode
     *
     * -# Check tutorial for active control panel.
     * -# If _Mode is not none , hide all control panel except _Mode
     * -# Show only the control panel.
     * -# Show weapon range object
     * -# Do not move ship.
     * -# Set m_SelectModeNow ( and mouse cursor will display correctly. )
     */
    public void SwitchControlMode( SelectFunctionMode _Mode )
    {
        // Check tutorial for active control panel.
        this.ConfirmTutorialActiveControlPanel() ;

        if( m_SelectModeNow == _Mode )
            return ;

        if( _Mode == SelectFunctionMode.SpecialModeMultipleAttack )
        {

        }
        else if( _Mode == SelectFunctionMode.None )
        {
            this.HideAllControlPanel() ;
        }
        else
        {
            this.HideAllControlPanel( _Mode ) ;
            this.ShowControlPanel( _Mode ) ;

        }

        // show weapon range
        ShowWeaponRange( _Mode ) ;

        m_ClickOnNoMoveFuncThisFrame = true ;
        // Debug.Log( _Mode ) ;
        m_SelectModeNow = _Mode ;
    }
Ejemplo n.º 7
0
    // 使用字串來取得GUI功能面板的功能
    public static string FindWeaponKeyword( SelectFunctionMode _Mode )
    {
        string ret = "" ;
        switch( _Mode )
        {
        case SelectFunctionMode.WeaponPhaser :
            ret = "Weapon_Phaser" ;
            break ;
        case SelectFunctionMode.WeaponTorpedo :
            ret = "Weapon_PhotonTorpedo" ;
            break ;
        case SelectFunctionMode.FunctionTrakorBeam :
            ret = "Weapon_TrackorBeam" ;
            break ;
        }

        return ret ;
    }
    // 上下切換一格的功能 set to m_SelectModeNow
    private void SwitchControlModeByOneStep_SpecialMode( bool _positive )
    {
        int step = ( true == _positive ) ? 1 : -1 ;

        switch( m_SelectModeNow )
        {
        case SelectFunctionMode.None :
            if( false == _positive )// negative
                m_SelectModeNow = SelectFunctionMode.FunctionTrakorBeam ;
            else
                m_SelectModeNow = SelectFunctionMode.SpecialModeMultipleAttack ;
            break ;
        case SelectFunctionMode.SpecialModeMultipleAttack :
            if( false == _positive )// negative
                m_SelectModeNow = SelectFunctionMode.None ;
            else
                m_SelectModeNow = SelectFunctionMode.FunctionTrakorBeam ;
            break ;
        case SelectFunctionMode.FunctionTrakorBeam :
            if( false == _positive )// negative
                m_SelectModeNow = SelectFunctionMode.SpecialModeMultipleAttack ;
            else
                m_SelectModeNow = SelectFunctionMode.None ;
            break ;
        }
    }
    // 顯示指定控制面版
    private void ShowControlPanel( SelectFunctionMode _mode )
    {
        int index = ((int)_mode - (int)SelectFunctionMode.None) ;

        if( index >= 0 && index < m_ControlPanelsActive.Count )
        {
            ShowGUITexture.Show( m_ControlPanelsActive[ _mode ].Obj , true , false , false ) ;

        }
    }