private Dictionary <int, int> GetNeedAttribute(JobConfig.JobElement jobElement) { Dictionary <int, int> dic = new Dictionary <int, int>(); if (jobElement != null) { if (jobElement.Need_Act > 0) { dic.Add(0, jobElement.Need_Act); } if (jobElement.Need_Sport > 0) { dic.Add(1, jobElement.Need_Sport); } if (jobElement.Need_Knowledge > 0) { dic.Add(2, jobElement.Need_Knowledge); } if (jobElement.Need_Deportment > 0) { dic.Add(3, jobElement.Need_Deportment); } } return(dic); }
public Transform getTeachJobFromJobID(int jobID) { for (int i = 0; i < JobUIGrid.transform.childCount; i++) { Transform item = JobUIGrid.transform.GetChild(i); UIButton workBtn = item.transform.Find("WorkBtn").GetComponent <UIButton>(); JobConfig.JobElement jobElement = (JobConfig.JobElement)workBtn.Data; if (jobElement != null && jobElement.JobID == jobID) { return(item); } } return(null); }
private void OnClickWorkBtn(GameObject obj) { UIButton btn = obj.transform.GetComponent <UIButton>(); JobConfig.JobElement jobElement = (JobConfig.JobElement)btn.Data; foreach (KeyValuePair <int, int> mPair in GetNeedAttribute(jobElement)) { if (GetPlayerAttributeNum(mPair.Key) < mPair.Value) { Globals.Instance.MGUIManager.ShowSimpleCenterTips(3003); return; } } JobNameLabel.text = jobElement.Job_Name; mTemporary_JobPiLaoNum = jobElement.Get_Fatigue; NetSender.Instance.C2GSJobRewardReq(jobElement.JobID); }
private void ShowSingleJobInfor(JobPlaceConfig.JobPlaceElement jobPlaceElement) { List <int> mSingleJobList = GetSinglePlaceJobList(jobPlaceElement.Job_Place_ID); HelpUtil.DelListInfo(JobUIGrid.transform); for (int i = 0; i < mSingleJobList.Count; i++) { GameObject jobItem = GameObject.Instantiate(JobItem) as GameObject; jobItem.transform.parent = JobUIGrid.transform; jobItem.transform.localScale = Vector3.one; jobItem.transform.localPosition = Vector3.zero; jobItem.name = "JobItem" + i; JobConfig.JobElement jobElement = jobConfig.GetSingleElement(mSingleJobList[i]); if (jobElement == null) { Debug.Log("mSingleJobList[i] = " + mSingleJobList[i] + "-- jobPlaceElement.Job_Place_ID = " + jobPlaceElement.Job_Place_ID); return; } UILabel jobNameLabel = jobItem.transform.Find("JobNameLabel").GetComponent <UILabel>(); UISprite needAttributeOne = jobItem.transform.Find("NeedAttributeOne").GetComponent <UISprite>(); UILabel numOneLabel = needAttributeOne.gameObject.transform.Find("NumOneLabel").GetComponent <UILabel>(); UISprite needAttributeTwo = jobItem.transform.Find("NeedAttributeTwo").GetComponent <UISprite>(); UILabel numTwoLabel = needAttributeTwo.gameObject.transform.Find("NumTwoLabel").GetComponent <UILabel>(); UISprite rewardOne = jobItem.transform.Find("RewardOne").GetComponent <UISprite>(); UILabel rewardNumOne = rewardOne.gameObject.transform.Find("RewardNumOne").GetComponent <UILabel>(); UISprite rewardTwo = jobItem.transform.Find("RewardTwo").GetComponent <UISprite>(); UILabel rewardNumTwo = rewardTwo.gameObject.transform.Find("RewardNumTwo").GetComponent <UILabel>(); jobNameLabel.text = jobElement.Job_Name; NGUITools.SetActive(needAttributeTwo.gameObject, false); int j = 0; foreach (KeyValuePair <int, int> mPair in GetNeedAttribute(jobElement)) { if (j == 0) { needAttributeOne.spriteName = NeedAttribute[mPair.Key]; // if(GetPlayerAttributeNum(mPair.Key) >= mPair.Value) // { // numOneLabel.text = "[21ce4a]"+mPair.Value.ToString()+"[-]"; // } // else // { // numOneLabel.text = "[be2131]"+mPair.Value.ToString()+"[-]"; // } numOneLabel.text = mPair.Value.ToString(); } else if (j == 1) { needAttributeTwo.spriteName = NeedAttribute[mPair.Key]; // if(GetPlayerAttributeNum(mPair.Key) >= mPair.Value) // { // numTwoLabel.text = "[21ce4a]"+mPair.Value.ToString()+"[-]"; // } // else // { // numTwoLabel.text = "[be2131]"+mPair.Value.ToString()+"[-]"; // } numTwoLabel.text = mPair.Value.ToString(); NGUITools.SetActive(needAttributeTwo.gameObject, true); } j++; } rewardNumOne.text = jobElement.Get_Money.ToString(); rewardNumTwo.text = jobElement.Get_Fans.ToString(); UIButton workBtn = jobItem.transform.Find("WorkBtn").GetComponent <UIButton>(); workBtn.Data = jobElement; UIEventListener.Get(workBtn.gameObject).onClick += OnClickWorkBtn; } JobUIGrid.sorting = UIGrid.Sorting.Custom; JobUIGrid.repositionNow = true; JobUIGrid.onReposition += RefreshGuide; NGUITools.SetActive(JobPlaceUIScrollView.gameObject, false); NGUITools.SetActive(JobInformation.gameObject, true); JobPlaceNameLabel.text = jobPlaceElement.Job_Place_Name; }