/// <summary> /// 检测材质是否能反应 /// </summary> /// <param name="mn">材质</param> /// <returns>是否反应</returns> private bool MatterCheck(MatterName mn) { if (mn.rctCondition == thisMatter.rctCondition) { List <ChemistyMatter> input = new List <ChemistyMatter> //用于存储自己和反应物 { new ChemistyMatter { name = thisMatter.matterName, state = thisMatter.matterState }, new ChemistyMatter { name = mn.matterName, state = mn.matterState } }; List <ChemistyMatter> output; //用于接受返回的生成物 //匹配成功,更新反应列表 if (rctMng.CheckReaction(input, thisMatter.rctCondition, out output)) { ChemicalEqu equ = new ChemicalEqu { input = input, conditon = thisMatter.rctCondition, output = output }; //更新 cmtEqus.Add(equ); //ui.AddEqu(equ, this.transform); return(true); } else { return(false); } } return(false); }
private void OnTriggerStay2D(Collider2D collision) { MatterName mn = collision.gameObject.GetComponent <MatterName>(); if (mn) { Transform gtr = collision.gameObject.GetComponent <Transform>(); if ((mn.matterState == MatterState.gas || mn.matterState == MatterState.liquid)) { if (tr.position.x > gtr.position.x) { lb.enabled = false; rb.enabled = true; } else { rb.enabled = false; lb.enabled = true; } } else { if (tr.position.x > gtr.position.x) { rb.enabled = true; } else { lb.enabled = true; } } } }
private void OnCollisionEnter2D(Collision2D collision) { //加入碰撞列表,将材质加入列表 if (collision.gameObject.tag == "Matter") { objList.Add(collision.gameObject); MatterName mn = collision.gameObject.GetComponent <MatterName>(); objMatterList.Add(mn); objMatterList_old.Add(mn.rctCondition); MatterCheck(mn); } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Player")) { TextUI.GetInstance().ShowText("门上锁了,若有钥匙可按Q开门"); MatterName mn = collision.gameObject.GetComponent <MatterName>(); //Debug.Log(mn.matterName); if (mn.matterName == "C") { CanOpen = true; //Debug.Log("CanOpen"); } } }
//private void OnTriggerEnter2D(Collider2D collision) //{ // //加入碰撞列表,将材质加入列表 // if (collision.gameObject.tag == "Matter") // { // objList.Add(collision.gameObject); // MatterName mn = collision.gameObject.GetComponent<MatterName>(); // objMatterList.Add(mn); // objMatterList_old.Add(mn.rctCondition); // MatterCheck(mn); // } //} private void OnCollisionExit2D(Collision2D collision) { if (collision.gameObject.tag == "Matter") { //获取OBJ所在的序号 int objIndex = objList.LastIndexOf(collision.gameObject); MatterName mn = collision.gameObject.GetComponent <MatterName>(); //删除列表中的该OBJ要素 objMatterList_old.RemoveAt(objIndex); objMatterList.RemoveAt(objIndex); objList.RemoveAt(objIndex); //删除所有该OBJ参与的反应 cmtEqus.RemoveAll(x => x.input.Count >= 2 && x.input[1].name == mn.matterName); } }
private bool isAbnormalReacting; //是否正在反应 private void Start() { //初始化,获得各种组件 rctMng = reactionManager.GetComponent <ReactionManager>(); mctMng = createManager.GetComponent <MatterCreateManager>(); nowWaitFrame = waitFrame; //ui = equUI.GetComponent<ReactionEquUI>(); thisMatter = this.GetComponent <MatterName>(); thisCondition_old = thisMatter.rctCondition; //activeEquIndex = null; //includeEqu = null; //includeObj = null; objList = new List <GameObject>(); objMatterList = new List <MatterName>(); objMatterList_old = new List <ReactionCondition>(); cmtEqus = new List <ChemicalEqu>(); abnormalChecked = false; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.GetComponent <MatterName>()) { MatterName mn = collision.gameObject.GetComponent <MatterName>(); SpriteRenderer sr = collision.gameObject.GetComponentInChildren <SpriteRenderer>(); if (colorReagent.AcidList.Exists(x => x == mn.matterName)) { mn.dyeingColor = colorReagent.Acid; sr.color = colorReagent.AcidColor; } else if (colorReagent.AlkaliList.Exists(x => x == mn.matterName)) { mn.dyeingColor = colorReagent.Alkali; sr.color = colorReagent.AlkaliColor; if (mn.matterName == "Na2O2") { collision.SendMessage("Fade"); } } } }
private bool abnormalChecked; //非normal状态时是否检查过,提高效率 private void Start() { sprite = gameObject.transform.GetChild(2).gameObject; //初始化,获得各种组件 equUI = GameObject.Find("UI/ReactionEquUI").gameObject; rctMng = reactionManager.GetComponent <ReactionManager>(); mctMng = createManager.GetComponent <MatterCreateManager>(); ui = equUI.GetComponent <ReactionEquUI>(); thisMatter = this.GetComponent <MatterName>(); thisCondition_old = thisMatter.rctCondition; activeEquIndex = null; //includeEqu = null; //includeObj = null; objList = new List <GameObject>(); objMatterList = new List <MatterName>(); objMatterList_old = new List <ReactionCondition>(); cmtEqus = new List <ChemicalEqu>(); abnormalChecked = true; //nowWaitFrame = waitFrame; }
/// <summary> /// 检测材质是否能反应 /// </summary> /// <param name="mn">材质</param> /// <returns>是否反应</returns> private bool MatterCheck(MatterName mn) { activeEquIndex = 0; //Debug.Log("MKMP"); if (mn.rctCondition == thisMatter.rctCondition) { List <ChemistyMatter> input = new List <ChemistyMatter> //用于存储自己和反应物 { new ChemistyMatter { name = thisMatter.matterName, state = thisMatter.matterState }, new ChemistyMatter { name = mn.matterName, state = mn.matterState } }; List <ChemistyMatter> output; //用于接受返回的生成物 //匹配成功,更新反应列表 int index; //Debug.Log(input[0].name + input[1].name + thisMatter.rctCondition.ToString()); if (rctMng.CheckReaction(input, thisMatter.rctCondition, out output, out index)) { ChemicalEqu equ = new ChemicalEqu { input = input, conditon = thisMatter.rctCondition, output = output }; //更新 cmtEqus.Add(equ); ui.AddEqu(index, this.transform); return(true); } else { //Debug.Log("F"); return(false); } } return(false); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.GetComponent <MatterName>()) { MatterName mn = collision.gameObject.GetComponent <MatterName>(); if (mn.dyeingColor == GuardColor) { switch (GuardColor) { case DyeingColor.Red: TextUI.GetInstance().ShowText("守门人:原来是红色派系之人,这就让你过去"); break; case DyeingColor.Purple: TextUI.GetInstance().ShowText("守门人:原来是紫色派系之人,这就让你过去"); break; case DyeingColor.Blue: TextUI.GetInstance().ShowText("守门人:原来是蓝色派系之人,这就让你过去"); break; case DyeingColor.Yellow: TextUI.GetInstance().ShowText("守门人:原来是黄色派系之人,这就让你过去"); break; case DyeingColor.Green: TextUI.GetInstance().ShowText("守门人:原来是绿色派系之人,这就让你过去"); break; case DyeingColor.Normal: TextUI.GetInstance().ShowText("守门人:原来是正常色派系之人,这就让你过去"); break; } Amt.SetTrigger("Hide"); Invoke("Pass", 2.0f); } else { switch (GuardColor) { case DyeingColor.Red: TextUI.GetInstance().ShowText("守门人:我是红色派系守门人,向来只让同派系之人通过"); break; case DyeingColor.Purple: TextUI.GetInstance().ShowText("守门人:我是紫色派系守门人,向来只让同派系之人通过"); break; case DyeingColor.Blue: TextUI.GetInstance().ShowText("守门人:我是蓝色派系守门人,向来只让同派系之人通过"); break; case DyeingColor.Yellow: TextUI.GetInstance().ShowText("守门人:我是黄色派系守门人,向来只让同派系之人通过"); break; case DyeingColor.Green: TextUI.GetInstance().ShowText("守门人:我是绿色派系守门人,向来只让同派系之人通过"); break; case DyeingColor.Normal: TextUI.GetInstance().ShowText("守门人:我是中立派系守门人,向来可让各派系之人通过"); break; } } } }