private IEnumerator RunStateScenario(Deck deckWithBiddingCards) { Debug.Log("RunStateScenario"); //select random player to start NetworkPlayer[] shuffledPlayerList = GameCircle .GamePlayers .ToArray(); //shuffledPlayerList.Shift(UnityEngine.Random.Range(0, 3)); shuffledPlayerList.Shift(1); FirstMovePlayer = shuffledPlayerList[0]; // All players should peek their bid or pass. yield return(StartCoroutine(MainBidding(shuffledPlayerList))); if (shuffledPlayerList.All(player => !player.SelectedBiddingSuit.HasValue || //was selected BidSuit.SNIP player.SelectedBiddingSuit == BidSuit.PASS)) //all players selected pass { Debug.Log("all players selected pass"); //first player takes bidding cards and gets rid of extra cards yield return(StartCoroutine(FirstPlayerGetRidOfTwoExtraCards(FirstMovePlayer, deckWithBiddingCards.GetCards(2).ToArray()))); //bidding timeout if (FirstMovePlayer.TwoExtraCardsSelectedByFirstPlayer == null) { foreach (var player in shuffledPlayerList) { player.SelectedBiddingSuit = BidSuit.PASS; } GameCircle.RoundComplete(shuffledPlayerList); yield break; } //after that he must choose bid again var availableChoices = EnumExtender.GetAllVariants <BidSuit>().Except(new[] { BidSuit.SNIP }).ToArray(); yield return(StartCoroutine(MakeBidding(FirstMovePlayer, availableChoices))); if (FirstMovePlayer.SelectedBiddingSuit == BidSuit.PASS) { foreach (var player in shuffledPlayerList.Except(FirstMovePlayer)) { player.SelectedBiddingSuit = BidSuit.PASS; } //if he selected pass again //he looses game GameCircle.RoundComplete(shuffledPlayerList); yield break; } } WonBiddingPlayer = shuffledPlayerList.OrderBy(player => player.SelectedBiddingSuit).Last(); WonBiddingPlayer.IsBiddingWinner = true; GameCircle.BiddingCompleted(shuffledPlayerList[0], WonBiddingPlayer, WonBiddingPlayer.SelectedBiddingSuit.Value); }
private void Initialize() { Panel = new PanelManager { RightButtons = new List <PanelButtonManager> { new PanelButtonManager { OnButtonAction = o => Save(), Icon = PackIconModernKind.Save, Text = "Save" } } }; Types = EnumExtender.GetAllDescriptions(typeof(SpecialDisciplineKind)); }
private void Initialize() { Panel = new PanelManager { RightButtons = new List <PanelButtonManager> { new PanelButtonManager { OnButtonAction = o => Save(), Icon = PackIconModernKind.Save, Text = "Save" } } }; Qualifications = EnumExtender.GetAllDescriptions(typeof(Qualification)); StudyForms = EnumExtender.GetAllDescriptions(typeof(StudyForm)); }
private void Initialize() { Panel = new PanelManager { RightButtons = new List <PanelButtonManager> { new PanelButtonManager { OnButtonAction = o => Save(), Icon = PackIconModernKind.Save, Text = "Save" } } }; Degrees = EnumExtender.GetAllDescriptions(typeof(AcademicDegree)); Ranks = EnumExtender.GetAllDescriptions(typeof(AcademicRank)); Positions = EnumExtender.GetAllDescriptions(typeof(WorkingPosition)); }
public EmployeesManager() { Panel = new PanelManager { LeftButtons = new List <PanelButtonManager> { new PanelButtonManager { OnButtonAction = o => Add(), Icon = PackIconModernKind.Add, Text = "Add" }, new PanelButtonManager { OnButtonAction = o => Edit(), Icon = PackIconModernKind.Edit, Text = "Edit" }, new PanelButtonManager { OnButtonAction = o => Delete(), Icon = PackIconModernKind.Delete, Text = "Delete" } } }; Degrees = EnumExtender.GetAllDescriptions(typeof(AcademicDegree)); Ranks = EnumExtender.GetAllDescriptions(typeof(AcademicRank)); Positions = EnumExtender.GetAllDescriptions(typeof(WorkingPosition)); }
private static IEnumerable <T> GetValues <T>() { return(EnumExtender.GetEnumValues <T>()); }
public void RunTaskMonitor(List <string> fileNames, params object[] optionalParams) { if (TaskCollection == null) { TaskCollection = new ObservableCollection <TaskItem <bool> >(); } fileNames.ForEach(x => { TaskItem <bool> t = new TaskItem <bool> { TaskId = new Random().Next(), TaskName = System.IO.Path.GetFileName(x), TaskProgressRatio = 0, FileType = EnumExtender.GetEnum <FileTypeEnum>(System.IO.Path.GetExtension(x)), FilePath = x, TaskStatus = TaskStatusEnum.Ready, }; if (new FileInfo(x).Length > 104857600) { t.TaskStatus = TaskStatusEnum.Error; t.TaskMessage = "文件大小超过100M,暂不支持"; } else if (new FileInfo(x).Length >= 1048576) { t.FileLength = System.Math.Ceiling(new FileInfo(x).Length / 1048576.0) + "MB"; } else if (new FileInfo(x).Length == 0) { t.TaskStatus = TaskStatusEnum.Error; t.TaskMessage = "禁止上传0KB文件"; } else { t.FileLength = System.Math.Ceiling(new FileInfo(x).Length / 1024.0) + "KB"; } TaskCollection.Add(t); }); if (!isRun) { TraversalTaskListNew(TaskCollection); } //progressingTasks = InitTaskInstance(TaskCollection); //await StartMutiTask(progressingTasks); //await Task.WhenAll(progressingTasks.Take(MaxTaskQuantity)); //await TasksExecutorByMaxTask(TaskCollection, MaxTaskQuantity); //TaskCollection = new ObservableCollection<TaskItem<bool>> //{ // new TaskItem<bool> // { // TaskId = new Random().Next(), // TaskName = "WCF服务编程中文版.pdf", // TaskProgressRatio = 0, // FileType = FileTypeEnum.PDF, // FilePath = @"F:\bak\WCF服务编程中文版.pdf", // TaskStatus = TaskStatusEnum.Ready, // }, // new TaskItem<bool> // { // TaskId = new Random().Next(), // TaskName = "811d754fa7e44a339bdcc856e54bd7a8.png", // FilePath = @"F:\bak\811d754fa7e44a339bdcc856e54bd7a8.png", // TaskProgressRatio = 0, // FileType = FileTypeEnum.PNG, // TaskStatus = TaskStatusEnum.Ready, // }, // new TaskItem<bool> // { // TaskId = new Random().Next(), // TaskName = "811d754fa7e44a339bdcc856e54bd7a8.png", // FilePath = @"F:\bak\811d754fa7e44a339bdcc856e54bd7a8.png", // TaskProgressRatio = 0, // FileType = FileTypeEnum.PNG, // TaskStatus = TaskStatusEnum.Ready, // }, // new TaskItem<bool> // { // TaskId = new Random().Next(), // TaskName = "811d754fa7e44a339bdcc856e54bd7a8.png", // FilePath = @"F:\bak\811d754fa7e44a339bdcc856e54bd7a8.png", // TaskProgressRatio = 0, // FileType = FileTypeEnum.PNG, // TaskStatus = TaskStatusEnum.Ready, // }, // new TaskItem<bool> // { // TaskId = new Random().Next(), // TaskName = "811d754fa7e44a339bdcc856e54bd7a8.png", // FilePath = @"F:\bak\811d754fa7e44a339bdcc856e54bd7a8.png", // TaskProgressRatio = 0, // FileType = FileTypeEnum.PNG, // TaskStatus = TaskStatusEnum.Ready, // }, // new TaskItem<bool> // { // TaskId = new Random().Next(), // TaskName = "811d754fa7e44a339bdcc856e54bd7a8.png", // FilePath = @"F:\bak\811d754fa7e44a339bdcc856e54bd7a8.png", // TaskProgressRatio = 0, // FileType = FileTypeEnum.PNG, // TaskStatus = TaskStatusEnum.Ready, // }, // new TaskItem<bool> // { // TaskId = new Random().Next(), // TaskName = "811d754fa7e44a339bdcc856e54bd7a8.png", // FilePath = @"F:\bak\811d754fa7e44a339bdcc856e54bd7a8.png", // TaskProgressRatio = 0, // FileType = FileTypeEnum.PNG, // TaskStatus = TaskStatusEnum.Ready, // }, // new TaskItem<bool> // { // TaskId = new Random().Next(), // TaskName = "WCF服务编程中文版.pdf", // FilePath = @"F:\bak\WCF服务编程中文版.pdf", // TaskProgressRatio = 0, // FileType = FileTypeEnum.PNG, // TaskStatus = TaskStatusEnum.Ready, // }, // new TaskItem<bool> // { // TaskId = new Random().Next(), // TaskName = "811d754fa7e44a339bdcc856e54bd7a8.png", // FilePath = @"F:\bak\811d754fa7e44a339bdcc856e54bd7a8.png", // TaskProgressRatio = 0, // FileType = FileTypeEnum.PNG, // TaskStatus = TaskStatusEnum.Ready, // }, // new TaskItem<bool> // { // TaskId = new Random().Next(), // TaskName = "811d754fa7e44a339bdcc856e54bd7a8.png", // FilePath = @"F:\bak\811d754fa7e44a339bdcc856e54bd7a8.png", // TaskProgressRatio = 0, // FileType = FileTypeEnum.PNG, // TaskStatus = TaskStatusEnum.Ready, // }, //}; //info = new { url = @"http://172.18.19.101:8888/testimony/api/v1/files"}; }
/// <summary> /// Variants of complete: /// 1. one of players selected bid and 2 other selected PASS /// 2. all selected PASS. /// </summary> /// <param name="shuffledPlayerList"></param> /// <returns></returns> private IEnumerator MainBidding(NetworkPlayer[] shuffledPlayerList) { BidSuit previousBiggestSuit = BidSuit.PASS; //nobody made any bid by default while (true) { foreach (NetworkPlayer player in shuffledPlayerList) { Debug.Log("MainBidding. " + player.gameObject.ToString(), player); //previous player selected max available bit if (previousBiggestSuit == BidSuit.SNIP) { //player.SelectedBiddingSuit = BidSuit.PASS; //all next player passes continue; } if (player.SelectedBiddingSuit != null && player.SelectedBiddingSuit == previousBiggestSuit) { //that player, who selected biggest bid in previous iteration, //just waits until other players make bigger bid in this continue; } var allVariants = EnumExtender.GetAllVariants <BidSuit>(); //it's forbiden to take SPADE before you have 2 extra cards (in second bidding) BidSuit[] forbiddenChoices = { BidSuit.SPADE }; if (previousBiggestSuit != BidSuit.PASS) { //next bid must be bigger than previous forbiddenChoices = allVariants .Where(suit => suit <= previousBiggestSuit && suit != BidSuit.PASS) .ToArray(); } var availableChoices = allVariants.Except(forbiddenChoices).ToArray(); yield return(StartCoroutine(MakeBidding(player, availableChoices))); if (player.SelectedBiddingSuit.Value > previousBiggestSuit) //player made bigger bid { previousBiggestSuit = player.SelectedBiddingSuit.Value; } } if (IsTwoPassBids(shuffledPlayerList)) { break; //2 or more player selected PASS } if (previousBiggestSuit == BidSuit.SNIP) //selected max possible bid { ////all player pass to that one who selected SNIP //foreach (NetworkPlayer player in shuffledPlayerList) // if (player.SelectedBiddingSuit != BidSuit.SNIP) // player.SelectedBiddingSuit = BidSuit.PASS; break; } } }