public void SetItem(int i, Item item) { Action <Point2D> itemTakeHandler = (p) => ItemTake.Raise(i, p); Action <Point2D> itemTransferHandler = (p) => ItemTransfer.Raise(i, p); Action <Point2D> itemActHandler = (p) => ItemAct.Raise(i, p); Action <KeyModifiers> itemInteractHandler = (mods) => ItemInteract.Raise(i); if (items[i] != null) { items[i].Take -= itemTakeHandler; items[i].Transfer -= itemTransferHandler; items[i].Act -= itemActHandler; items[i].Interact -= itemInteractHandler; items[i].Remove(); items[i].Dispose(); } if (item != null) { items[i] = new ItemWidget(this, null); items[i].Item = item; items[i].Move(slotPositions[i].X, slotPositions[i].Y); items[i].Take += itemTakeHandler; items[i].Transfer += itemTransferHandler; items[i].Act += itemActHandler; items[i].Interact += itemInteractHandler; } }
public void ResolveNextText() { DelNullOrNoteRow(); string[] rowText = allStr[rowIndex].Split('|'); string scriptType = rowText[0]; if (scriptType == "0") { //图片操作 //ImageAct act = new ImageAct(rowText); //act.DoAct(); AnimationAct act = new AnimationAct(rowText); act.DoAct(); } else if (scriptType == "1") { //对话操作 TalkAct act = new TalkAct(rowText); act.DoAct(); } else if (scriptType == "2") { //物品判断操作 ItemAct act = new ItemAct(rowText); Debug.Log("物品操作"); act.DoAct(); } else if (scriptType == "3") { //剧本跳转 BranchAct act = new BranchAct(rowText); act.DoAct(); } else if (scriptType == "4") { //演出操作 ShowAct act = new ShowAct(rowText); act.DoAct(); } }
public void ResolveNextText() { while (rowIndex < allStr.Length) { DelNullOrNoteRow(); string[] rowText = allStr[rowIndex].Split('|'); string scriptType = rowText[0]; //动画操作 if (scriptType == "0") { AnimationAct act = new AnimationAct(rowText); bool isAniExists = false; bool isNameRight = false; bool isNumberRight = true; //检查行数 if (rowText.Length != 5 && rowText.Length != 3) { isNumberRight = false; Debug.Log("行参数数量错误,错误数量为:" + rowText.Length + "行内容为:" + allStr[rowIndex]); } Assert.AreEqual(true, isNumberRight); //动画退出事件的检查 if (rowText.Length == 3) { Assert.AreEqual(1, int.Parse(rowText[2].Trim())); rowIndex++; continue; } //一般动画事件的检查(进入,更换) //检查角色名 foreach (string name in roleNameList) { if (name == rowText[1].Trim()) { isNameRight = true; } } if (!isNameRight) { Debug.Log("角色名称错误,行内容为:" + allStr[rowIndex]); } Assert.AreEqual(true, isNameRight); //检查动画名 foreach (string aniname in roleAniDic[rowText[1].Trim()]) { if (aniname == rowText[3].Trim()) { isAniExists = true; } } if (!isAniExists) { Debug.Log("动画名称错误,行内容为:" + allStr[rowIndex]); } Assert.AreEqual(true, isAniExists); } //对话操作 if (scriptType == "1") { TalkAct act = new TalkAct(rowText); bool isNumberRight = true; bool isNameRight = false; bool isTextRight = false; if (rowText.Length != 4) { isNumberRight = false; Debug.Log("行参数数量错误,错误数量为:" + rowText.Length + "行内容为:" + allStr[rowIndex]); } foreach (string name in roleNameList) { if (name == act.name || act.name.Contains(",")) { isNameRight = true; } } if (act.text[0] == '\"' && act.text[act.text.Length - 1] == '\"') { isTextRight = true; } Assert.AreEqual(true, isNumberRight); if (!isNameRight) { Debug.Log("角色名称错误,行内容为:" + allStr[rowIndex]); } Assert.AreEqual(true, isNameRight); if (!isTextRight) { Debug.Log("符号错误,行内容为:" + allStr[rowIndex]); } Assert.AreEqual(true, isTextRight); } //物品判断操作 if (scriptType == "2") { ItemAct act = new ItemAct(rowText); bool isNumberRight = true; if (rowText.Length < 5) { isNumberRight = false; Debug.Log("行参数数量错误,错误数量为:" + rowText.Length + "行内容为:" + allStr[rowIndex]); } Assert.AreEqual(true, isNumberRight); } //剧本跳转 if (scriptType == "3") { BranchAct act = new BranchAct(rowText); bool isNumberRight = true; if (rowText.Length < 5) { isNumberRight = false; Debug.Log("行参数数量错误,错误数量为:" + rowText.Length + "行内容为:" + allStr[rowIndex]); } Assert.AreEqual(true, isNumberRight); } rowIndex++; } }