static void Main(string[] args) { bool isFinish = false; do { switch (Menu.ActionMenu()) { case Actions.Add: switch (Menu.AddMenu()) { case Services.Models.Band: ModelCreator.CreateAndSaveBand(); break; case Services.Models.Music: do { try { var musicsBand = SelectInformation.SelectBandByIndex(Menu.BandSelectMenu()); ModelCreator.CreateAndSaveMusic(musicsBand.Id); break; } catch (ArgumentOutOfRangeException) { Console.WriteLine("Добвление новой группы:"); ModelCreator.CreateAndSaveBand(); } catch (IndexOutOfRangeException) { Console.WriteLine("Такая группа уже существует"); } } while (true); break; default: Console.WriteLine("Нет такого объекта"); break; } break; case Actions.View: switch (Menu.WhatShow()) { case Services.Models.Band: Menu.ShowAllBands(); break; case Services.Models.Music: switch (Menu.MusicShowChoseMenu()) { case Constants.SHOW_ALL: Menu.ShowAllMusics(); break; case Constants.SHOW_BY_NAME: Band musicBand = new Band(); string musicName = SetInformation.SetMusicName(); var music = SelectInformation.SelectMusicsByName(musicName, musicBand); Menu.ShowMusics(new List <Music>() { music }); break; case Constants.SHOW_BY_BAND: var bands = SelectInformation.SelectAllBand(); var band = bands[Menu.BandSelectMenu()]; var selectedMusics = SelectInformation.SelectMusicsByBandName(band.Name); Menu.ShowMusics(selectedMusics); break; case Constants.SHOW_BY_RATING: switch (Menu.ChoseSortTypeMenu()) { case SortType.Ascending: var sortedMusicAscending = SortingService.SortMusicAscendingRating(SelectInformation.SelectAllMusic()); Menu.ShowMusics(sortedMusicAscending); break; case SortType.Descending: var sortedMusicDescending = SortingService.SortMusicDescendingRating(SelectInformation.SelectAllMusic()); Menu.ShowMusics(sortedMusicDescending); break; default: Console.WriteLine("Нет такого типа сортировки"); break; } break; default: Console.WriteLine("Выберите из предложенных вариантов"); break; } break; default: Console.WriteLine("Нет такого объекта"); break; } break; case Actions.Exit: isFinish = true; break; default: Console.WriteLine("Нет такого действия"); break; } } while (!isFinish); }
// retrieve selection information from selection system. private bool RetrieveSelectionInfo( UnitSelectionSystem _SelectSys , out SelectInformation _SelectionInfo ) { _SelectionInfo = _SelectSys.GetPrimarySelectInfo() ; if( null == _SelectionInfo || false == _SelectionInfo.isValid ) return false ; return true ; }
/* # 在函式 TryFireWeapon() 中,呼叫武器系統 依照關鍵字 取得 可以發射的武器部件 # 在函式 TryFireWeapon() 中,呼叫武器系統 傳入 武器部件名稱 目標船艦名稱 發射武器 # 失敗時發出警告聲 # 失敗時顯示武器範圍 */ private bool TryFireWeapon( UnitWeaponSystem _WeaponSys , string _WeaponKeyword , SelectInformation _SelectionInfo ) { // find correct weapon string TargetComponentObjectName = ConstName.CreateComponent3DObjectName( _SelectionInfo.TargetUnitName , _SelectionInfo.m_TargetComponentName ) ; string mainCause = "" ; string weaponComponentName = _WeaponSys.FindAbleWeaponComponent( _WeaponKeyword , TargetComponentObjectName , ref mainCause ) ; bool ret = false ; // Debug.Log( "ActiveTrackorBeam3() weaponComponentName=" + weaponComponentName ) ; if( false == ( ret = _WeaponSys.ActiveWeapon( weaponComponentName , _SelectionInfo.GetTargetUnit() , _SelectionInfo.m_TargetComponentName ) ) ) { // fire weapon fail : beep if( null != m_Audio_WeaponFailBeep ) { // show weapon range ShowWeaponRange( _WeaponKeyword ) ; this.gameObject.audio.PlayOneShot( m_Audio_WeaponFailBeep ) ; MessageQueueManager manager = GlobalSingleton.GetMessageQueueManager() ; if( null != manager ) manager.AddMessage( mainCause ) ; } } return ret ; }
private void FireWeaponInMultipleAttackMode() { // Debug.Log( "FireWeaponInMultipleAttackMode" ) ; UnitData unitData = this.gameObject.GetComponent<UnitData>() ; UnitSensorSystem sensorSys = this.gameObject.GetComponent<UnitSensorSystem>() ; UnitWeaponSystem weaponSys = this.gameObject.GetComponent<UnitWeaponSystem>() ; UnitSelectionSystem selectSys = this.gameObject.GetComponent<UnitSelectionSystem>() ; SelectInformation preSelectInfo = new SelectInformation( selectSys.GetPrimarySelectInfo() ) ; // Debug.Log( "preSelectInfo" + preSelectInfo.TargetUnitName ) ; if( null == unitData || null == sensorSys || null == weaponSys || null == selectSys ) return; Dictionary<string , SelectInformation> fireList = new Dictionary<string, SelectInformation>() ; if( true == TryFireWeaponInMultiAttackMode( unitData , sensorSys , weaponSys , selectSys , ref fireList ) ) { // Debug.Log( "true == TryFireWeaponInMultiAttackMode" ) ; foreach( string weaponComponentName in fireList.Keys ) { weaponSys.ActiveWeapon( weaponComponentName , fireList[ weaponComponentName ].GetTargetUnit() , ConstName.UnitDataComponentUnitIntagraty ) ; } } else { Debug.Log( "false == TryFireWeaponInMultiAttackMode" ) ; // no weapon can fight. } if( null != preSelectInfo ) { selectSys.SetPrimarySelectInfo( preSelectInfo ) ; // Debug.Log( "preSelectInfo" + preSelectInfo.TargetUnitName ) ; } }
public void SetPrimarySelectInfo( SelectInformation _Set ) { if( true == m_Selections.ContainsKey( m_PrimarySelectionKey ) ) { m_Selections[m_PrimarySelectionKey] = _Set ; } }
public SelectInformation( SelectInformation _src ) { isValid = _src.isValid ; clickActiveTime = _src.clickActiveTime ; screenPosition = _src.screenPosition ; m_TargetComponentName = _src.m_TargetComponentName ; m_TargetUnit = new NamedObject( _src.m_TargetUnit ) ; }
/* * This function will update screen position and valid of this selection GUI object * 更新選擇框的位置 */ private bool UpdateScreenPositionOfThisGUISelectionObject( ref GameObject _GUISelectionObj , ref SelectInformation _Info ) { // update the screen position of this GUI Object if( 0 == _Info.TargetUnitName.Length ) { Debug.Log( "Target has no name" ) ; return false ; } string targetUnitName = _Info.TargetUnitName ; GameObject targetObj = GameObject.Find( targetUnitName ) ; if( null == targetObj ) { // the object is destroyed. force this selection is close. _Info.isValid = false ; return false ; } UnitData unitData = targetObj.GetComponent<UnitData>() ; if( null != unitData && false == unitData.IsAlive() ) { // the object is not alive. force this selection is close. _Info.isValid = false ; return false ; } // find screen position Vector3 worldPos = targetObj.transform.position ; Vector3 screenPos = Camera.mainCamera.WorldToViewportPoint( worldPos ) ; if( screenPos.x > 1 || screenPos.x < 0 || screenPos.y > 1 || screenPos.y < 0 ) { // out of viewport _Info.isValid = false ; return false ; } _Info.screenPosition.Set( screenPos.x , screenPos.y , 0.0f ) ; _GUISelectionObj.transform.position = _Info.screenPosition ; return true ; }
static void Main(string[] args) { bool isFinish = false; do { switch (Menu.ActionMenu()) { case Actions.Add: switch (Menu.AddMenu()) { case Services.Models.Band: SaveModelsInDataBase.SaveBand(ModelCreator.CreateBand()); break; case Services.Models.Music: do { try { SaveModelsInDataBase.SaveMusic(ModelCreator.CreateMusic(SelectInformation.SelectBandByIndex(Menu.BandSelectMenu()))); break; } catch (IndexOutOfRangeException) { Console.WriteLine("Такая группа уже существует"); } } while (true); break; default: Console.WriteLine("Нет такого объекта"); break; } break; case Actions.View: break; case Actions.Exit: isFinish = true; break; default: Console.WriteLine("Нет такого действия"); break; } } while (!isFinish); }