void move(CubeMark NeedNum) {//移动脚本 //实现移动 if (NeedNum.Ismove == false) { GameObject t = Greed.Greedys(NeedNum); GameObject Moveto = t;//通过移动位置判断脚本得到移动位置 if (Moveto.GetComponent <CubeMark>().Isbulled == false && Moveto && NeedNum.Issm) { NeedNum.Issm.transform.DOMove((Moveto.transform.position - NeedNum.gameObject.transform.position), 0.2f).SetEase(Ease.Linear).SetRelative(); if (NeedNum.IsbigMO) { NeedNum.IsbigMO.transform.DOMove((Moveto.transform.position - NeedNum.gameObject.transform.position), 0.2f).SetEase(Ease.Linear).SetRelative(); }//小兵以及英雄单位的移动实现 SetCube(Moveto.GetComponent <CubeMark>(), NeedNum);//移动后各自地板属性变换 GetNull(NeedNum);//原地板归零 } else { Moveto = NeedNum.gameObject; //不移动 } Needscontrol.Remove(NeedNum); //移除原已存在对象 Needscontrol.Add(Moveto.GetComponent <CubeMark>()); //添加移动后的对象 AttackJudge(Moveto.GetComponent <CubeMark>()); //攻击选择 } }
public void GetZero() { for (int i = 0; i < CubeFloods.Length; i++) { CubeMark ss = CubeFloods[i].GetComponent <CubeMark>(); ss.Ismove = false; ss.Isatrack = false;//所有地板重置 } }
public void TanXin() { Enamycard.Clear(); //清空原卡牌 Transform Ec = GameObject.Find("EnamysCards").transform; //获取卡牌父对象 int Count = Ec.childCount; //卡牌数量 Transform[] zz = new Transform[Count]; //新建数组储存卡牌 for (int k = 0; k < Count; k++) { zz[k] = Ec.GetChild(k);//子对象卡牌传入 } for (int i = 0; i < Count; i++) { Transform max = zz[i]; for (int j = i; j < Count; j++) { if (max.GetComponent <EnamyCardAttribute>().EnamyLife < zz[j].GetComponent <EnamyCardAttribute>().EnamyLife) { max = zz[j]; zz[j] = zz[i]; zz[i] = max; //卡牌排序(倒序) } } Enamycard.Add(max.gameObject);//添加入对象脚本 } CubeMark TheStartCube = EnamyStart.GetComponent <CubeMark>(); for (int i = 0; i < Enamycard.Count; i++) {//在开始位置新建对象 if (Enamycard[i].GetComponent <EnamyCardAttribute>().Ishero == false && TheStartCube.Isbulled == false) { GameObject Ena = GameObject.Instantiate(Enamycard[i].GetComponent <EnamyCardAttribute>().EnamyXb, new Vector3(EnamyStart.transform.position.x, EnamyStart.transform.position.y + 1, EnamyStart.transform.position.z), Quaternion.Euler(new Vector3(0, 180, 0))); TheStartCube.Issm = Ena; //为地板作标记 TheStartCube.IssmMo = true; TheStartCube.Isbulled = true; TheStartCube.IsMyplayers = 2; TheStartCube.Thelifes += Enamycard[i].GetComponent <EnamyCardAttribute>().EnamyLife; TheStartCube.Theattacks += Enamycard[i].GetComponent <EnamyCardAttribute>().EnamyAttack; Destroy(Enamycard[i].gameObject); Enamycard.Remove(Enamycard[i]); MoveJudge();//移动判断 } //else if (TheStartCube.IssmMo == true && item.GetComponent<EnamyCardAttribute>().Ishero == true&&TheStartCube.IsbigMO==false) //{ // GameObject Enah = GameObject.Instantiate(item.GetComponent<EnamyCardAttribute>().EnamyHero, new Vector3(EnamyStart.transform.position.x, EnamyStart.transform.position.y + 1, EnamyStart.transform.position.z), Quaternion.Euler(new Vector3(0,180,0))); // TheStartCube.IsbigMO = Enah; // TheStartCube.IsbiMO = true; // TheStartCube.Thelifes += item.GetComponent<EnamyCardAttribute>().EnamyLife; // TheStartCube.Theattacks += item.GetComponent<EnamyCardAttribute>().EnamyAttack; //} else { } } }
void SetCube(CubeMark s1, CubeMark s2) {//地板属性交换 s1.IsbigMO = s2.IsbigMO; s1.Issm = s2.Issm; s1.Thelifes = s2.Thelifes; s1.Theattacks = s2.Theattacks; s1.Isbulled = s2.Isbulled; s1.Ismove = true; s1.Isatrack = s2.Isatrack; s1.IsMyplayers = s2.IsMyplayers; s1.IsbiMO = s2.IsbiMO; s1.IssmMo = s2.IssmMo; }
void GetNull(CubeMark ss) {//地板属性归零 ss.Issm = null; ss.IsbigMO = null; ss.Isbulled = false; ss.Ismove = false; ss.IssmMo = false; ss.IsbiMO = false; ss.Isatrack = false; ss.Theattacks = 0; ss.IsMyplayers = 0; ss.Thelifes = 0; }
CubeMark cubeMark; //声明标记脚本 private void Update() { if (!EventSystem.current.IsPointerOverGameObject()) { //点击不为UI if (Input.GetMouseButtonDown(0)) { //按下按钮 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; //射线的创建 bool ss = Physics.Raycast(ray, out hit, 1000, LayerMask.GetMask("bg")); //是否碰撞bg层 if (ss) { cubeMark = hit.collider.gameObject.GetComponent <CubeMark>(); //获得点击地板的标记脚本 if (cubeMark.IsMyplayers == 1 && cubeMark.Isbulled == true && cubeMark.Isatrack == false && cubeMark.IsMyplayers == 1) { //判断是否建造了东西 Cubess[0] = hit.collider.gameObject; Cubess[1] = null; } else if (Cubess[0] && !Cubess[1] && cubeMark.IsMyplayers == 2) { Cubess[1] = hit.collider.gameObject;//点击到第一个有物体的地板后储存第二次点击的地板 float hs = Vector3.Distance(Cubess[0].transform.position, Cubess[1].transform.position); if (hs <= 18) { CubeMark Fir = Cubess[0].GetComponent <CubeMark>(); //地板1标记脚本 CubeMark Sec = Cubess[1].GetComponent <CubeMark>(); //地板2标记脚本 Sec.Thelifes -= Fir.Theattacks; Fir.Thelifes -= (Sec.Theattacks * 0.8f); //攻击(数值变化) Fir.Isatrack = true; } } else if (Cubess[0] && Cubess[1]) { Cubess[1] = null; Cubess[0] = null;//点击其他位置则所有数组置空 } if (i > 1) { i = 0; } } } } }
GameObject BackMove(CubeMark ss) { GameObject tt = CouldMove[0]; for (int i = 0; i < CouldMove.Count - 1; i++) { if (CouldMove[i].GetComponent <CubeMark>().IsMyplayers != 2) { if (CouldMove[i].transform.position == EnamyStart.transform.position) { return(CouldMove[i]);//若回防时可移动位置为敌方关键点则返回该可移动位置 } if (Vector3.Distance(CouldMove[i].transform.position, EnamyStart.transform.position) > Vector3.Distance(CouldMove[i + 1].transform.position, EnamyStart.transform.position)) { tt = CouldMove[i + 1];//离敌方关键点最近的可移动位置 } } } return(tt); //返回离敌方关键点最近的可移动位置 }
void AttackJudge(CubeMark ss) { CubeMark Theena = null; for (int i = 0; i < ss.Ontrigglesobj.Count; i++) { if (ss.Ontrigglesobj[i].GetComponent <CubeMark>().IsMyplayers == 1) { if (Theena == null) { Theena = ss.Ontrigglesobj[i].GetComponent <CubeMark>(); } if (Theena.Thelifes > ss.Ontrigglesobj[i].GetComponent <CubeMark>().Thelifes) { Theena = ss.Ontrigglesobj[i].GetComponent <CubeMark>();//找到对方生命值最低的单位 } } } for (int i = 0; i < Enamycard.Count; i++) { if (ss.IsMyplayers == 2 && ss.IssmMo == true && Enamycard[i].GetComponent <EnamyCardAttribute>().Ishero == true && ss.IsbigMO == false) { GameObject Enah = GameObject.Instantiate(Enamycard[i].GetComponent <EnamyCardAttribute>().EnamyHero, new Vector3(ss.transform.position.x, ss.transform.position.y + 2, ss.transform.position.z), Quaternion.Euler(new Vector3(0, 180, 0))); ss.IsbigMO = Enah;//英雄对象的创建并于对应地板赋值 ss.IsbiMO = true; ss.Thelifes += Enamycard[i].GetComponent <EnamyCardAttribute>().EnamyLife; ss.Theattacks += Enamycard[i].GetComponent <EnamyCardAttribute>().EnamyAttack; Destroy(Enamycard[i].gameObject); Enamycard.Remove(Enamycard[i]); } } if (Theena && ss.Isatrack == false) { Attack(Theena, ss);//攻击方法 } else { return; } }
GameObject EndMove(CubeMark ss) { if (CouldMove.Count >= 1) { GameObject tt = CouldMove[0]; for (int i = 1; i < CouldMove.Count - 1; i++) { if (CouldMove[i].transform.position == Starts.transform.position) { return(CouldMove[i]);//若我方关键点在该单位可移动位置上则返回该可移动位置 } else if (CouldMove[i + 1] && Vector3.Distance(CouldMove[i].transform.position, Starts.transform.position) > Vector3.Distance(CouldMove[i + 1].transform.position, Starts.transform.position)) { tt = CouldMove[i + 1];//距离我方关键点最近的一个可移动位置 } } return(tt);//返回距离我方关键点最近的一个可移动位置 } else { return(ss.gameObject); } }
private void Update() { if (!EventSystem.current.IsPointerOverGameObject()) { //点击的不为UI if (Input.GetMouseButtonDown(0)) { //按下按钮 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; //射线的创建 bool ss = Physics.Raycast(ray, out hit, 1000, LayerMask.GetMask("bg")); //是否碰撞bg层 if (ss) { cubeMark = hit.collider.gameObject.GetComponent <CubeMark>(); //获得点击地板的标记脚本 if (cubeMark.Isbulled == true && cubeMark.Ismove == false && cubeMark.IsMyplayers != 2) { //判断是否建造了东西 Cubess[0] = hit.collider.gameObject; Cubess[1] = null; //若点击地板上有物体则数组Cubess[1]置空 Themovesbig = Cubess[0].gameObject.GetComponent <CubeMark>().IsbigMO; //判断是否为英雄物体 Themovessml = Cubess[0].gameObject.GetComponent <CubeMark>().Issm; //判断是否为小兵物体 } else if (!isattacking.Cubess[1] && cubeMark.IsMyplayers == 0 && Cubess[0] && !Cubess[1] && cubeMark.Ismove == false) { Cubess[1] = hit.collider.gameObject;//点击到第一个有物体的地板后储存第二次点击的地板 float hs = Vector3.Distance(Cubess[0].transform.position, Cubess[1].transform.position); if (hs <= 18) { Mic.kaishi();//播放声音 if (Themovesbig && Cubess[0].gameObject.GetComponent <CubeMark>().IsbiMO == true) { Themovesbig.transform.DOMove((Cubess[1].transform.position - Cubess[0].transform.position), 0.2f).SetEase(Ease.Linear).SetRelative(); } Themovessml.transform.DOMove((Cubess[1].transform.position - Cubess[0].transform.position), 0.2f).SetEase(Ease.Linear).SetRelative(); CubeMark Fir = Cubess[0].GetComponent <CubeMark>(); //地板1标记脚本 CubeMark Sec = Cubess[1].GetComponent <CubeMark>(); //地板2标记脚本 Sec.Isbulled = true; Sec.Isatrack = Fir.Isatrack; Sec.Theattacks = Fir.Theattacks; Sec.Thelifes = Fir.Thelifes; if (Themovesbig) { Sec.IsbiMO = true; Sec.IsbigMO = Themovesbig; }//地板2添加数值 Sec.Issm = Themovessml; Sec.IssmMo = true; Sec.Ismove = true; Sec.IsMyplayers = 1;//标记地板2 Fir.Isbulled = false; Fir.Isatrack = false; Fir.Ismove = false; Fir.IsbiMO = false; Fir.IssmMo = false; Fir.IsbigMO = null; Fir.Issm = null; Fir.Theattacks = 0; Fir.Thelifes = 0; Fir.IsMyplayers = 0;//将地板1的标记置空 } //判断地板1上的元素并向地板2移动 } else if (Cubess[0] && Cubess[1]) { Cubess[1] = null; Cubess[0] = null;//点击其他位置则所有数组置空 } if (i > 1) { i = 0; } } } } }
public void ColorMapAdd(SingleCube cube, CubeMark mark) { EditColorMap.Add (cube, mark); if (CheakEditColorFinished ()) { print ("颜色编辑完成!!!!!!!!"); } }
public GameObject Greedys(CubeMark ss) { CouldMove.Clear(); for (int i = 0; i < ss.Ontrigglesobj.Count; i++) { if (ss.Ontrigglesobj[i].GetComponent <CubeMark>().Isbulled == false) { CouldMove.Add(ss.Ontrigglesobj[i]); } } if (ss == EnamyStart.GetComponent <CubeMark>()) { for (int i = 0; i < ss.Ontrigglesobj.Count; i++) { if (ss.Ontrigglesobj[i].GetComponent <CubeMark>().IsMyplayers == 0) { return(ss.Ontrigglesobj[i]);//若该对象在敌方关键位置,则移动出来 } } } else { for (int q = 0; q < EnamyStart.GetComponent <CubeMark>().Ontrigglesobj.Count; q++) { for (int p = 0; p < EnamyStart.GetComponent <CubeMark>().Ontrigglesobj[q].GetComponent <CubeMark>().Ontrigglesobj.Count; p++) { if (EnamyStart.GetComponent <CubeMark>().Ontrigglesobj[q].GetComponent <CubeMark>().IsMyplayers == 1) { return(BackMove(ss));//若我方进入敌方危险范围则敌方回防 } else if (EnamyStart.GetComponent <CubeMark>().Ontrigglesobj[q].GetComponent <CubeMark>().Ontrigglesobj[p].GetComponent <CubeMark>().IsMyplayers == 1) { return(BackMove(ss));//若我方进入敌方危险范围则敌方回防 } } } Could = null; for (int j = 0; j < CouldMove.Count; j++) { if (Vector3.Distance(ss.transform.position, Starts.transform.position) <= 30) { return(EndMove(ss));//若离我方关键点小于三个地板则向我方关键点移动 } if (ss.Ontrigglesobj[j].GetComponent <CubeMark>().Isbulled == false) { for (int k = 0; k < ss.Ontrigglesobj[j].GetComponent <CubeMark>().Ontrigglesobj.Count; k++) { if (ss.Ontrigglesobj[j].GetComponent <CubeMark>().Ontrigglesobj[k].GetComponent <CubeMark>().IsMyplayers == 1) { Could = ss.Ontrigglesobj[j].GetComponent <CubeMark>().Ontrigglesobj[k]; if (ss.Thelifes > Could.GetComponent <CubeMark>().Thelifes&& Could.GetComponent <CubeMark>().Thelifes != 0) { return(ss.Ontrigglesobj[j]);//能移动位置攻击范围生命大于我方则返回该位置 } } else { if (Could != null) { for (int i = 0; i < ss.Ontrigglesobj[j].GetComponent <CubeMark>().Ontrigglesobj.Count; i++) { if (!ss.Ontrigglesobj[j].GetComponent <CubeMark>().Ontrigglesobj[i].GetComponent <CubeMark>().Isbulled) { Empty = true; } else { Empty = false; } } if (Empty) { return(ss.Ontrigglesobj[j]);//判断可移动位置的攻击范围是否有我方单位,没有则移动到该位置 } } else { return(EndMove(ss)); } } } } else { return(EndMove(ss)); } } } return(EndMove(ss)); }
void Attack(CubeMark Ena, CubeMark Mys) { Ena.Thelifes -= Mys.Theattacks; Mys.Thelifes -= (Ena.Theattacks * 0.8f);//攻击(数值变化) Mys.Isatrack = true; }
public void OnEndDrag(PointerEventData eventData) { if (transform.position.y > 7) {//判断是否在卡牌外 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; bool ss = Physics.Raycast(ray, out hit, 1000, LayerMask.GetMask("bg")); //射线创建及得到碰撞地板 CubeMark TheStartCube = StartCube.GetComponent <CubeMark>(); //获得标记脚本 if (ss) { HitCube = hit.collider.gameObject.GetComponent <CubeMark>(); } if ((TheStartCube.Isbulled == false || TheStartCube.IsbiMO == false || TheStartCube.IssmMo == false) && GamesChoose.Powers > 0) { //判断是否可以创建 if (IsSmModel == true && TheStartCube.IssmMo != true && GamesChoose.Powers > this.Cost) { //小兵创建 Mic.kaishi(); Destroy(this.gameObject); //卡片销毁(创建完成后) GamesChoose.Powers -= Cost; Xb = GameObject.Instantiate(Themodel, new Vector3(StartCube.transform.position.x, StartCube.transform.position.y + 1, StartCube.transform.position.z), Quaternion.identity); TheStartCube.Issm = Xb; TheStartCube.IssmMo = true; TheStartCube.Isbulled = true; TheStartCube.IsMyplayers = 1; TheStartCube.Thelifes += 4000; TheStartCube.Theattacks += 500;//地板属性添加 this.transform.DOScale(new Vector3(-1f, -1f, 1f), 0.1f).SetEase(Ease.Linear).SetRelative().OnComplete(() => { }); } else if (HitCube.IsMyplayers == 1 && IsSmModel != true && HitCube.IsbiMO == false && HitCube.IssmMo == true && GamesChoose.Powers > this.Cost) { //英雄单位创建 Mic.kaishi(); Destroy(this.gameObject); //卡片销毁(创建完成后) GamesChoose.Powers -= Cost; Hero = GameObject.Instantiate(Themodel, new Vector3(hit.collider.gameObject.transform.position.x, hit.collider.gameObject.transform.position.y + 2, hit.collider.gameObject.transform.position.z), Quaternion.identity); HitCube.IsbigMO = Hero; HitCube.IsbiMO = true; HitCube.Thelifes += 2000; HitCube.Theattacks += 1000; //攻击数值结算 HitCube.IsMyplayers = 1; /////////////////////////////////////暂时标记///////////////// this.transform.DOScale(new Vector3(-1f, -1f, 1f), 0.2f).SetEase(Ease.Linear).SetRelative().OnComplete(() => { }); } else if (EventSystem.current.IsPointerOverGameObject()) { transform.SetParent(OldParent.transform);//卡牌返回 } } else { transform.SetParent(OldParent.transform);//卡牌返回 } } else { transform.SetParent(OldParent.transform);//未创建则返回 } }
// TODO: 根据设定的颜色来标识当前cube private CubeMark GetCubeMark() { CubeMark mark = CubeMark.None; if (cubestyle == CubeStyle.Corner) { if (cubecolor.ContainsValue(MagicColor.White) && cubecolor.ContainsValue(MagicColor.Red) && cubecolor.ContainsValue(MagicColor.Blue)) { mark = CubeMark.WRB; } else if (cubecolor.ContainsValue(MagicColor.White) && cubecolor.ContainsValue(MagicColor.Red) && cubecolor.ContainsValue(MagicColor.Green)) { mark = CubeMark.WRG; } else if (cubecolor.ContainsValue(MagicColor.White) && cubecolor.ContainsValue(MagicColor.Orange) && cubecolor.ContainsValue(MagicColor.Green)) { mark = CubeMark.WOG; } else if (cubecolor.ContainsValue(MagicColor.White) && cubecolor.ContainsValue(MagicColor.Orange) && cubecolor.ContainsValue(MagicColor.Blue)) { mark = CubeMark.WBO; } else if (cubecolor.ContainsValue(MagicColor.Yellow) && cubecolor.ContainsValue(MagicColor.Orange) && cubecolor.ContainsValue(MagicColor.Blue)) { mark = CubeMark.YBO; } else if (cubecolor.ContainsValue(MagicColor.Yellow) && cubecolor.ContainsValue(MagicColor.Orange) && cubecolor.ContainsValue(MagicColor.Green)) { mark = CubeMark.YOG; } else if (cubecolor.ContainsValue(MagicColor.Yellow) && cubecolor.ContainsValue(MagicColor.Red) && cubecolor.ContainsValue(MagicColor.Green)) { mark = CubeMark.YRG; } else if (cubecolor.ContainsValue(MagicColor.Yellow) && cubecolor.ContainsValue(MagicColor.Red) && cubecolor.ContainsValue(MagicColor.Blue)) { mark = CubeMark.YRB; } } if (cubestyle == CubeStyle.Edge) { if (cubecolor.ContainsValue(MagicColor.White) && cubecolor.ContainsValue(MagicColor.Red)) { mark = CubeMark.WR; } else if (cubecolor.ContainsValue(MagicColor.White) && cubecolor.ContainsValue(MagicColor.Orange)) { mark = CubeMark.WO; } else if (cubecolor.ContainsValue(MagicColor.White) && cubecolor.ContainsValue(MagicColor.Green)) { mark = CubeMark.WG; } else if (cubecolor.ContainsValue(MagicColor.White) && cubecolor.ContainsValue(MagicColor.Blue)) { mark = CubeMark.WB; } else if (cubecolor.ContainsValue(MagicColor.Yellow) && cubecolor.ContainsValue(MagicColor.Orange)) { mark = CubeMark.YO; } else if (cubecolor.ContainsValue(MagicColor.Yellow) && cubecolor.ContainsValue(MagicColor.Red)) { mark = CubeMark.YR; } else if (cubecolor.ContainsValue(MagicColor.Yellow) && cubecolor.ContainsValue(MagicColor.Blue)) { mark = CubeMark.YB; } else if (cubecolor.ContainsValue(MagicColor.Yellow) && cubecolor.ContainsValue(MagicColor.Green)) { mark = CubeMark.YG; } else if (cubecolor.ContainsValue(MagicColor.Red) && cubecolor.ContainsValue(MagicColor.Blue)) { mark = CubeMark.BR; } else if (cubecolor.ContainsValue(MagicColor.Red) && cubecolor.ContainsValue(MagicColor.Green)) { mark = CubeMark.GR; } else if (cubecolor.ContainsValue(MagicColor.Green) && cubecolor.ContainsValue(MagicColor.Orange)) { mark = CubeMark.GO; } else if (cubecolor.ContainsValue(MagicColor.Blue) && cubecolor.ContainsValue(MagicColor.Orange)) { mark = CubeMark.BO; } } return(mark); }
// public void InitColor () // { // SingleBoxPiece[] mypieces = GetComponentsInChildren <SingleBoxPiece> (); // cubecolor.Clear (); // foreach (SingleBoxPiece p in mypieces) { // p.GetComponent <MeshRenderer> ().material.color = Color.gray; // cubecolor.Add (p.gameObject, MagicColor.None); // } // } public void SetColor(GameObject p) { if (operater == null) { operater = FindObjectOfType <MyMagicCube> (); } MagicColor curcolor = operater.Color; // print (operater.EditColorStore [curcolor]); if (curcolor != MagicColor.None && operater.EditColorStore [curcolor] > 7) { //print ("此颜色已经编辑完成" + curcolor + operater.EditColorStore [curcolor]); return; } if (cubecolor.ContainsKey(p) && cubecolor [p] == curcolor) { //print ("颜色相同"); return; } bool cansetcolor = true; if (editcolorfinished) { operater.ColorMapDelete(this); } MagicColor orignalcolor = MagicColor.None; // 如果字典里面有当前的物体,则为替换颜色,如果没有,则为添加颜色 if (cubecolor.ContainsKey(p)) { orignalcolor = cubecolor [p]; // 这些只是为了防止同一个块上出现两个相同的颜色和对面的颜色 foreach (GameObject g in cubecolor.Keys) { if (g != p) { if (!cubecolor [g].Equals(MagicColor.None)) { if (cubecolor [g] == curcolor) { cansetcolor = false; //print ("此块已经有相同颜色,请勿重复编辑"); break; } int index = (int)curcolor; if (index >= 3 && (int)cubecolor [g] == index - 3) { cansetcolor = false; //print ("颜色不匹配"); break; } else if (index < 3 && (int)cubecolor [g] == index + 3) { cansetcolor = false; //print ("颜色不匹配"); break; } } } } } else { cubecolor.Add(p, curcolor); //print ("添加新颜色"); } // 这里先假设将颜色附上去,如果不合适再去掉 if (cansetcolor) { cubecolor [p] = curcolor; } else { return; } // TODO: 判断是否完成当前cube的颜色设定,如果完成则保存到字典中,如果没有则等待完成 if ((cubestyle == CubeStyle.Edge && cubecolor.Count == 2) || (cubestyle == CubeStyle.Corner && cubecolor.Count == 3)) { editcolorfinished = true; } else { editcolorfinished = false; } if (editcolorfinished) { // foreach (GameObject g in cubecolor.Keys) { // editcolorfinished = true; // if (g.GetComponent <CubeFace> ().mycolor == MagicColor.None) { // editcolorfinished = false; // } // } if (cubecolor.ContainsValue(MagicColor.None)) { editcolorfinished = false; } } if (editcolorfinished) { //print ("当前块的颜色已经设置完成"); // TODO: 根据设定的颜色来标识当前cube,判断是否有重复 CubeMark mark = GetCubeMark(); if (operater.EditColorMap.ContainsValue(mark) && mark != CubeMark.None) { // print ("已经有这样的颜色块啦,请不要编辑错误了哦" + mark); cubecolor [p] = orignalcolor; } else { // print ("颜色编辑成功" + mark); operater.ColorDelete(orignalcolor); operater.ColorAdd(); operater.ColorMapAdd(this, mark); p.GetComponent <MeshRenderer> ().material.color = MyMapPrefab.ColorMap [curcolor]; } } else { // print ("当前块的颜色尚未设置完成"); operater.ColorDelete(orignalcolor); operater.ColorAdd(); p.GetComponent <MeshRenderer> ().material.color = MyMapPrefab.ColorMap [curcolor]; } }