//下一轮开会投票 public void NextVote() { CheckVoteStatus(); SkillConfirmButton.SetActive(false); for (int i = 0; i < VoteStrs.Count; i++) { if (VoteStrs[i].Active == true) { TempStrs.Add(VoteStrs[i].Str); StrInfos.Remove(VoteStrs[i].TargetStr);//在待激活面板中删除对应战略 } Destroy(VoteStrs[i].TargetStr.gameObject); Destroy(VoteStrs[i].gameObject); } VoteStrs.Clear(); if (VoteSeqNum == 3) { VoteSeqNum = 0; } else { VoteSeqNum += 1; if (VoteSeqNum == 3) { VoteSeqNum += 1; } } if (VoteSeqNum < 5) { StartVote(); } else { for (int i = 0; i < TempStrs.Count; i++) { StrategyInfo NewStr = Instantiate(ActivePrefab, ActiveStrsContent); NewStr.SC = this; NewStr.Str = TempStrs[i]; NewStr.UpdateUI(); NewStr.Str.Effect(GC); ActiveStrs.Add(NewStr); } MeetingButton.interactable = false; TempStrs.Clear(); TimeLeft = 384; if (CultureTimeLeft == -1) { CultureTimeLeft = 1152; } UpdateUI(); VotePanel.gameObject.SetActive(false); } }
//确定选出的战略 void CheckVoteStatus() { List <StrategyInfo> TempStrInfos = new List <StrategyInfo>(); for (int i = 0; i < VoteStrs.Count; i++) { VoteStrs[i].Active = false;//先重置状态 VoteStrs[i].ActiveMarker.SetActive(false); } for (int i = 0; i < StrLimitNum[VoteSeqNum]; i++) { if (VoteStrs.Count > 0) { StrategyInfo TStr = VoteStrs[0]; for (int j = 0; j < VoteStrs.Count; j++) { //相等的话取靠前的 if (TStr.VoteNum < VoteStrs[j].VoteNum) { TStr = VoteStrs[j]; } if (j == VoteStrs.Count - 1 && TStr.VoteNum != 0) { TempStrInfos.Add(TStr); TStr.Active = true; TStr.ActiveMarker.SetActive(true); VoteStrs.Remove(TStr); //暂时移除被选中的战略,防止下一轮循环被拿来比较 } } } else { break; } } for (int i = 0; i < TempStrInfos.Count; i++) { VoteStrs.Add(TempStrInfos[i]);//重新将被选中的战略放回 } }
void StartVote() { if (canChangeCulture == true) { VoteSeqNum = 3; canChangeCulture = false; CultureTimeLeft = -1; } if (StrLimitNum[VoteSeqNum] > 0) { int typenum = 0; for (int i = 0; i < StrInfos.Count; i++) { if (VoteSeqNum == (int)StrInfos[i].Str.Type) { //还要写一些选择相关的功能 StrategyInfo newStr = Instantiate(VotePrefab, VoteContent); newStr.SC = this; newStr.Str = StrInfos[i].Str; newStr.TargetStr = StrInfos[i]; newStr.VoteNum = Random.Range(1, GC.CurrentEmployees.Count + 1);//+1代表CEO也会投票,同时避免(1,0)的情况 newStr.UpdateUI(); VoteStrs.Add(newStr); typenum += 1; } } if (typenum == 0) { NextVote(); } else { CheckVoteStatus(); } } else { NextVote(); } }
public void SkillConfirm() { bool SkillActive = false;//各种技能需要选择的战略不一样,确定选择了对应战略再发动技能 //因为开会不暂停所以此处要再检测一遍体力 if (MeetingSkillNum == 1 && GC.Stamina >= 10) { if (VoteSelectStrs[0].Active == true) { SkillActive = true; GC.Stamina -= 10; List <StrategyInfo> TempInfos = new List <StrategyInfo>(); for (int i = 0; i < VoteStrs.Count; i++) { if (VoteStrs[i].Active == false) { TempInfos.Add(VoteStrs[i]); } } if (TempInfos.Count <= 3) { for (int i = 0; i < TempInfos.Count; i++) { VoteStrs.Remove(TempInfos[i]); Destroy(TempInfos[i].gameObject); } } else { for (int i = 0; i < 3; i++) { int DesNum = Random.Range(0, TempInfos.Count); VoteStrs.Remove(TempInfos[DesNum]); Destroy(TempInfos[DesNum].gameObject); } } VoteSelectStrs[0].VoteNum = 0; VoteSelectStrs[0].UpdateUI(); CheckVoteStatus(); } } else if (MeetingSkillNum == 2 && GC.Stamina >= 10) { bool allCheck = true; for (int i = 0; i < VoteSelectStrs.Count; i++) { if (VoteSelectStrs[i].Active == true) { allCheck = false; break; } } if (allCheck == true) { SkillActive = true; GC.Stamina -= 10; for (int i = 0; i < VoteSelectStrs.Count; i++) { VoteStrs.Remove(VoteSelectStrs[i]); Destroy(VoteSelectStrs[i]); } CheckVoteStatus(); } } else if (MeetingSkillNum == 4 && GC.Stamina >= 20) { if (VoteSelectStrs.Count == 1) { SkillActive = true; GC.Stamina -= 20; VoteSelectStrs[0].VoteNum += (int)(VoteSelectStrs[0].VoteNum * 0.5f); VoteSelectStrs[0].UpdateUI(); CheckVoteStatus(); } } else if (MeetingSkillNum == 5 && GC.Stamina >= 30) { if ((VoteSelectStrs[0].Active == true && VoteSelectStrs[1].Active == false) || (VoteSelectStrs[0].Active == false && VoteSelectStrs[1].Active == true)) { SkillActive = true; GC.Stamina -= 30; int num1 = VoteSelectStrs[0].VoteNum, num2 = VoteSelectStrs[1].VoteNum; VoteSelectStrs[0].VoteNum = num2; VoteSelectStrs[1].VoteNum = num1; VoteSelectStrs[0].UpdateUI(); VoteSelectStrs[1].UpdateUI(); CheckVoteStatus(); } } if (SkillActive == true) { for (int i = 0; i < VoteStrs.Count; i++) { VoteStrs[i].StrSelectToggle.interactable = false; VoteStrs[i].StrSelectToggle.isOn = false; } VoteSelectStrs.Clear(); SkillConfirmButton.gameObject.SetActive(false); } }