//创建一般操作按钮 void createNoGroupBtn(Vector2 minpos, Vector2 maxpos, string name, Operation.SChandle handle) { CustomView.SCButton btn = new CustomView.SCButton(5, name, parentDialogBtn.transform, delegate() { gameObject.GetComponent <AudioSource>().Play(); //教学模式中判断本操作是否是当前要求的操作并对要求操作做更新 if (isTeacher) { gameObject.GetComponent <SCTeacher>().isAccord(handle); } //查询这个操作是否在次序表中有,如果有则去状态转换表查看是否需要状态转换 int nextstate = handle.stateChange(currentState); //如果转换结果没有则说明本操作错误,将操作及其正确与否进行存储 if (nextstate != 0) { stateGetAndShow(nextstate); //将此正确操作存储 operationList.Add(handle.h_name + ":√"); } else { //将此错误操作存储 operationList.Add(handle.h_name + ":×"); } }, btnImagetwo, minpos, maxpos, new Vector2(0, 0), new Vector2(0, 0)// new Vector2(0, 0.92f), new Vector2(0.166f, 1.0f) ); CustomView.SCText text = new CustomView.SCText(5, "text", btn._btn.transform, handle.h_name, textFont, FontStyle.Normal, new Color(0, 0, 0, 1), TextAnchor.MiddleCenter, new Vector2(0, 0), new Vector2(1, 1), new Vector2(0, 0), new Vector2(0, 0)); currentDialogBtnArry.Add(btn._btn); }
//创建组操作按钮 void createBtn(Vector2 minpos, Vector2 maxpos, string name, Operation.SCGroup group) { CustomView.SCButton btn = new CustomView.SCButton(5, name, parentGamobject.transform, delegate() { string gstr = group.g_name; //显示对话框 produceDialog.GetComponent <Devdog.InventorySystem.UIWindow>().Show(); gameObject.GetComponent <AudioSource>().Play(); foreach (GameObject it in currentDialogBtnArry) { Destroy(it); } //清空对话框中现存的按钮 currentDialogBtnArry.Clear(); currentDrugArry.Clear(); if (group.g_name == "注射" || group.g_name == "静点") { getDrug(group.g_ID, group.g_name); } else { getOperation(group.g_ID); } }, btnImage, minpos, maxpos, new Vector2(0, 0), new Vector2(0, 0)// new Vector2(0, 0.92f), new Vector2(0.166f, 1.0f) ); CustomView.SCText text = new CustomView.SCText(5, "text", btn._btn.transform, group.g_name, textFont, FontStyle.Normal, new Color(0, 0, 0, 1), TextAnchor.MiddleCenter, new Vector2(0, 0), new Vector2(1, 1), new Vector2(0, 0), new Vector2(0, 0)); }
//获取药物并将药物填写在对话框中 void getDrug(string groupId, string groupName) { DbAccess db = new DbAccess("data source = " + Application.dataPath + "/ModelData/NDtreatmentnew.db"); string sqlstr = "select * from NT_drug"; SqliteDataReader result = db.ExecuteQuery(sqlstr); float i = 0.03f, j = 0.93f; int k = 0; while (result.Read()) { string tempid = result.GetString(result.GetOrdinal("NC_id")); string tempname = result.GetString(result.GetOrdinal("NC_name")); string tempclass = result.GetString(result.GetOrdinal("NC_class")); string tempconcentration = result.GetString(result.GetOrdinal("NC_concentration")); string tempdose = result.GetString(result.GetOrdinal("NC_dose")); Operation.Drugs temp = new Operation.Drugs(tempid, tempname, tempclass, tempconcentration, tempdose); if (k < 3) { createDrugBtn(new Vector2(i, j - 0.05f), new Vector2(i + 0.27f, j), "btnDialog", temp); i = i + 0.3f; k++; } else { k = 0; i = 0.03f; j = j - 0.05f; createDrugBtn(new Vector2(i, j - 0.05f), new Vector2(i + 0.27f, j), "btnDialog", temp); i = i + 0.3f; k++; } } result.Close(); db.CloseSqlConnection(); CustomView.SCButton sumitbtn = new CustomView.SCButton(5, "submit", parentDialogBtn.transform.parent, delegate() { onSubmitBtn(groupId, groupName); }, btnImage, new Vector2(0.0f, 0.9f), new Vector2(0.93f, 1.0f), new Vector2(0, 0), new Vector2(0, 0)// new Vector2(0, 0.92f), new Vector2(0.166f, 1.0f) ); CustomView.SCText text = new CustomView.SCText(5, "text", sumitbtn._btn.transform, "提交", textFont, FontStyle.Normal, new Color(0, 0, 0, 1), TextAnchor.MiddleCenter, new Vector2(0, 0), new Vector2(1, 1), new Vector2(0, 0), new Vector2(0, 0)); currentDialogBtnArry.Add(sumitbtn._btn); }
void AssessmentList() { if (endListView.Count != 0) { foreach (CustomView.SCText it in endListView) { Destroy(it._text); } endListView.Clear(); } float i = 0.98f; foreach (string it in operationList) { string text = it; CustomView.SCText temp = new CustomView.SCText(6, "text", gameObjectEndTextParent.transform, text, textFont, FontStyle.Normal, new Color(0, 0, 0, 1), TextAnchor.MiddleCenter, new Vector2(0.05f, i - 0.08f), new Vector2(0.98f, i), new Vector2(0, 0), new Vector2(0, 0)); endListView.Add(temp); i = i - 0.08f; } }
//将当前状态的值显示在View中 void showCurrentState() { if (currentStateViewArry.Count != 0) { foreach (CustomView.SCText it in currentStateViewArry) { Destroy(it._text); } currentStateViewArry.Clear(); } float i = 0.98f; foreach (KeyValuePair <string, string> kvp in currentState.stateMap) { string text = kvp.Key + ":" + kvp.Value; CustomView.SCText temp = new CustomView.SCText(5, "text", showTextParent.transform, text, textFont, FontStyle.Normal, new Color(0, 0, 0, 1), TextAnchor.MiddleCenter, new Vector2(0.05f, i - 0.08f), new Vector2(0.98f, i), new Vector2(0, 0), new Vector2(0, 0)); currentStateViewArry.Add(temp); i = i - 0.08f; } }