/// <summary> /// 玩家对我们甜品操作进行拖拽处理的方法 /// </summary> #region /// <summary> /// 对甜品的操作方法 /// </summary> public void EnterSweet(GameSweet sweet) { if (gameOver == false) { enteredSweet = sweet; } }
//交换两甜品(添加不符合条件回退功能) private void ExchangeSweets(GameSweet sweet1, GameSweet sweet2) { if (sweet1.CanMove() && sweet2.CanMove()) { ////如果横向和纵向交换后都没有可消除的糖果,交换位置重新归位 if (MatchSweet(sweet1, sweet2.X, sweet2.Y) != null || MatchSweet(sweet2, sweet1.X, sweet1.Y) != null) { int TempX = sweet1.X; int TempY = sweet1.Y; sweet1.MoveComponent.Move(sweet2.X, sweet2.Y, fileTime); sweet2.MoveComponent.Move(TempX, TempY, fileTime); sweets[sweet1.X, sweet1.Y] = sweet2; sweets[sweet2.X, sweet2.Y] = sweet1; } else { //两个糖果先进行交换 int TempX = sweet1.X; int TempY = sweet1.Y; sweet1.MoveComponent.Move(sweet2.X, sweet2.Y, fileTime); sweet2.MoveComponent.Move(TempX, TempY, fileTime); StartCoroutine(ClearChangge(sweet2, sweet1)); } } }
public void PressSweet(GameSweet sweet) { if (gameOver == false) { pressedSweet = sweet; } }
/// <summary> /// 列匹配 /// </summary> /// <param name="sweet">糖果本身</param> /// <param name="type">糖果颜色</param> /// <returns>匹配结果</returns> public List <GameSweet> FindRowSameSweet(GameSweet sweet, int currentX, int currentY, ColorType type) { int y; List <GameSweet> list = new List <GameSweet>(); for (int i = 0; i <= 1; i++) { for (int yDistance = 1; yDistance < PlayerInfo.Instance.yRow; yDistance++) { if (i == 0) { y = currentY - yDistance; } else { y = currentY + yDistance; } if (y < 0 || y >= PlayerInfo.Instance.yRow) { break; } if (sweet.IsMatch() && _sweets[currentX, y].Color == type) { list.Add(_sweets[currentX, y]); } else { break; } } } return(list); }
/// <summary> /// 行匹配 /// </summary> /// <param name="sweet">糖果本身</param> /// <param name="type">糖果颜色</param> /// <returns>匹配结果</returns> public List <GameSweet> FindColumnSameSweet(GameSweet sweet, int currentX, int currentY, ColorType type) { int x; List <GameSweet> list = new List <GameSweet>(); for (int i = 0; i <= 1; i++) { for (int xDistance = 1; xDistance < PlayerInfo.Instance.xColumn; xDistance++) { if (i == 0) { x = currentX - xDistance; } else { x = currentX + xDistance; } if (x < 0 || x >= PlayerInfo.Instance.xColumn) { break; } if (sweet.IsMatch() && _sweets[x, currentY].Color == type) { list.Add(_sweets[x, currentY]); } else { break; } } } return(list); }
/// <summary> /// 选中糖果 /// </summary> /// <param name="sweet"></param> public void PressSweet(GameSweet sweet) { if (GameUI != null && GameUI.visible) { _pressSweet = sweet; } }
//清除全部完成匹配的甜品 private bool ClearAllMatchedSweet() { bool needRefill = false;//是否重新填充 //遍历场景是否存在可清除的甜品 for (int y = 0; y < yRow; y++) { for (int x = 0; x < xColumn; x++) { if (sweets[x, y].CanClear()) { List <GameSweet> matchList = MatchSweets(sweets[x, y], x, y); //用一个列表去接收匹配成功的返回来的甜品列表 if (matchList != null) { //如果不为空则遍历列表中的每一个甜品对象进行清除 SweetType specialSweetsType = SweetType.COUNT; //定义一个特殊类型的甜品 GameSweet randomSweet = matchList[Random.Range(0, matchList.Count)]; //随机一个匹配成功之后的糖果选定一个,即3个选一个 int specialSweetX = randomSweet.X; int specialSweetY = randomSweet.Y; if (matchList.Count == 4) { //随机出一个(生成)行消除或者列消除的特殊甜品 specialSweetsType = (SweetType)Random.Range((int)SweetType.ROW_CLEAR, (int)SweetType.COLUMN_CLEAR + 1); } else if (matchList.Count >= 5)//大于4就产生彩虹糖 { //随机出一个(生成)行消除或者列消除的特殊甜品 specialSweetsType = SweetType.RAINBOWCANDY; } for (int i = 0; i < matchList.Count; i++) { if (ClearSweet(matchList[i].X, matchList[i].Y)) { needRefill = true;//是否重新填充 } } if (specialSweetsType != SweetType.COUNT) { //有问题,需要填充,没有为true,还是昨晚想到的那个 //Destroy(sweets[specialSweetX, specialSweetY]); GameSweet newSweet = CreateNewSweet(specialSweetX, specialSweetY, specialSweetsType); //生成特殊甜品对象 if (specialSweetsType == SweetType.ROW_CLEAR || specialSweetsType == SweetType.COLUMN_CLEAR && matchList[0].CanColor() && newSweet.CanColor()) { newSweet.ColoredComponent.SetColor(matchList[0].ColoredComponent.Color); } if (specialSweetsType == SweetType.RAINBOWCANDY && newSweet.CanColor()) { newSweet.ColoredComponent.SetColor(ColorType.COLORS); } } } } } } return(needRefill); }
//交换甜品的方法 private void ExchangeSweets(GameSweet sweet1, GameSweet sweet2) { if (sweet1.CanMove() && sweet2.CanMove()) { sweets[sweet1.X, sweet1.Y] = sweet2; sweets[sweet2.X, sweet2.Y] = sweet1; //有返回的删除列表 if (MatchSweets(sweet1, sweet2.X, sweet2.Y) != null || MatchSweets(sweet2, sweet1.X, sweet1.Y) != null) { //先交换两个元素 int tempX = sweet1.X; int tempY = sweet1.Y; sweet1.MoveComponent.Move(sweet2.X, sweet2.Y, time); sweet2.MoveComponent.Move(tempX, tempY, time); //清除 ClearAllMatchSweet(); //填充 StartCoroutine(AllFill()); } else { //不做处理 sweets[sweet1.X, sweet1.Y] = sweet1; sweets[sweet2.X, sweet2.Y] = sweet2; } } }
/// <summary> /// 交换两个甜品的方法 /// </summary> public void ExchangeSweets(GameSweet sweet1, GameSweet sweet2) { if (sweet1.CanMove() && sweet2.CanMove()) { sweets[sweet1.X, sweet1.Y] = sweet2; sweets[sweet2.X, sweet2.Y] = sweet1; if (MatchSweets(sweet1, sweet2.X, sweet2.Y) != null || MatchSweets(sweet2, sweet1.X, sweet1.Y) != null) { int tempX = sweet1.X; int tempy = sweet1.Y; sweet1.MovedComponent.Move(sweet2.X, sweet2.Y, fillTime); sweet2.MovedComponent.Move(tempX, tempy, fillTime); ClearAllMatchedSweet(); StartCoroutine(AllFill()); pressedSweet = null; enteredSweet = null; } else { sweets[sweet1.X, sweet1.Y] = sweet1; sweets[sweet2.X, sweet2.Y] = sweet2; } } }
/// <summary> /// 清除规则里物品的方法 /// </summary> /// <returns></returns> private bool ClearAllMatchedSweet() { bool needRefill = false; //是否需要填充 for (int y = 0; y < yHang; y++) { for (int x = 0; x < xLie; x++) { if (sweets[x, y].CanClear()) //如果可以清除 { List <GameSweet> matchList = MatchSweets(sweets[x, y], x, y); if (matchList != null) //需要消除 { SweetsType specialSweetsType = SweetsType.COUNT; //定义一个枚举类型:COUNT——是否产生特殊甜品:默认是Count类型 GameSweet randomSweet = matchList[Random.Range(0, matchList.Count)]; //随机产生位置 int specialSweetX = randomSweet.X; int specialSweetY = randomSweet.Y; if (matchList.Count == 4) //消除的4个物品 { specialSweetsType = (SweetsType)Random.Range((int)SweetsType.HANG_CLEAR, (int)SweetsType.LIE_CLEAR + 1); //特殊类型赋值:取左不取右,所以+1 } else if (matchList.Count >= 5) { specialSweetsType = SweetsType.RAINBOWCANDY; } //5个 for (int i = 0; i < matchList.Count; i++) //遍历数组 { if (ClearSweet(matchList[i].X, matchList[i].Y)) { needRefill = true; //填充 } } if (specialSweetsType != SweetsType.COUNT) //有特殊类型 { Destroy(sweets[specialSweetX, specialSweetY]); //删除空白物品 GameSweet newSweet = CreateNewSweet(specialSweetX, specialSweetY, specialSweetsType); //生成特殊甜品 if (specialSweetsType == SweetsType.HANG_CLEAR || specialSweetsType == SweetsType.LIE_CLEAR && newSweet.CanColor() && matchList[0].CanColor()) //种类的确定 { newSweet.ColorComponet.SetColor(matchList[0].ColorComponet.Color); //给特殊物品,着色:第一个物品的颜色 } else if (specialSweetsType == SweetsType.RAINBOWCANDY && newSweet.CanColor()) //如果是彩虹堂 { newSweet.ColorComponet.SetColor(ColorSweet.ColorType.ANY); } } } } } } return(needRefill); }
private bool ClearAllMatchedSweet() { bool needRefill = false;//默认不需要重新填充 for (int y = 0; y < yRow; y++) { for (int x = 0; x < xColumn; x++) { if (sweets[x, y].CanClear()) { List <GameSweet> matchList = MatchSweets(sweets[x, y], x, y); if (matchList != null) { SweetsType specialSweetsType = SweetsType.COUNT;//决定是否产生特殊甜品 GameSweet randomSweet = matchList[Random.Range(0, matchList.Count)]; int specialSweetX = randomSweet.X; int specialSweetY = randomSweet.Y; //四个产生行列消除 if (matchList.Count == 4) { specialSweetsType = (SweetsType)Random.Range((int)SweetsType.ROW_CLEAR, (int)SweetsType.COLUMN_CLEAR); } //五个产生彩虹糖 else if (matchList.Count >= 5) { specialSweetsType = SweetsType.RAINBOWCANDY; } for (int i = 0; i < matchList.Count; i++) { if (ClearSweet(matchList[i].X, matchList[i].Y)) { needRefill = true; } } if (specialSweetsType != SweetsType.COUNT) { Destroy(sweets[specialSweetX, specialSweetY]); GameSweet newSweet = CreatNewSweet(specialSweetX, specialSweetY, specialSweetsType); if ((specialSweetsType == SweetsType.ROW_CLEAR || specialSweetsType == SweetsType.COLUMN_CLEAR) && newSweet.CanColor() && matchList[0].CanColor()) { newSweet.ColoredComponent.SetColor(matchList[0].ColoredComponent.Color); } //加上彩虹糖特殊类型的产生 else if (specialSweetsType == SweetsType.RAINBOWCANDY && newSweet.CanColor()) { newSweet.ColoredComponent.SetColor(ColorSweet.ColorType.ANY); } } } } } } return(needRefill); }
/// <summary> /// 匹配方法 /// </summary> /// <param name="sweet">当前选中甜品</param> /// <param name="newX">位置,x坐标</param> /// <param name="newY">位置,Y坐标</param> /// <returns></returns> public List <GameSweet> MatchSweets(GameSweet sweet, int newX, int newY) { if (sweet.CanColor()) { ColorSweet.ColorType color = sweet.ColoredComponent.Color; List <GameSweet> matchRowSweets = new List <GameSweet>(); List <GameSweet> matchLineSweets = new List <GameSweet>(); List <GameSweet> finishedMatchingSweets = new List <GameSweet>(); //行匹配 matchRowSweets.Add(sweet); //i=0代表往左,i=1代表往右 for (int i = 0; i <= 1; i++) { for (int xDistance = 0; xDistance < xColumn; xDistance++) { int x; if (i == 0) { x = newX - xDistance; } else { x = newX + xDistance; } if (x < 0 || x >= xColumn) { break; } if (sweets[x, newY].CanColor() && sweets[x, newY].ColoredComponent.Color == color) { matchRowSweets.Add(sweets[x, newY]); } else { break; } } } //检查一下当前行遍历列表中的元素数量是否大于3 if (matchRowSweets.Count >= 3) { for (int i = 0; i < matchRowSweets.Count; i++) { finishedMatchingSweets.Add(matchRowSweets[i]); } } if (finishedMatchingSweets.Count >= 3) { return(finishedMatchingSweets); } } return(null); }
/// <summary> /// 进入物品 /// </summary> public void EnterSweet(GameSweet sweet) { if (IsGameOver) { return; //如果游戏结束,直接跳出 } enterSweet = sweet; }
/// <summary> /// 按下物品 /// </summary> public void PressedSweet(GameSweet sweet) { if (IsGameOver) { return; //如果游戏结束,直接跳出 } pressedSweet = sweet; }
public void PressSweet(GameSweet sweet) { if (UIManager.gameTime == 0) { return; } pressedSweet = sweet; }
/// <summary> /// 玩家对我们甜品操作进行拖拽处理的方法 /// </summary> public void PressSweet(GameSweet sweet) { if (GameUI.Instance.gameover) { return; } clickSweet = sweet; }
public void PressSweet(GameSweet sweet) { if (gameOver) { return; } pressedSweet = sweet; }
public void EnterSweet(GameSweet sweet) { if (gameOver) { return; } enteredSweet = sweet; }
public void EnterSweet(GameSweet sweet) { if (UIManager.gameTime == 0) { return; } enteredSweet = sweet; }
/// <summary> /// 鼠标进入的甜品 /// </summary> /// <param name="sweet"></param> public void EnterSweet(GameSweet sweet) { if (GameUI.Instance.gameover) { return; } enterSweet = sweet; }
private bool ClearAllMatchedSweet()//清除所有块方法 { if (isGameOver) { return(false); } print("清除所有块方法"); bool needRefill = false; for (int y = 0; y < yRows; y++) { for (int x = 0; x < xColumns; x++) { if (sweetsarray[y, x].CanClear()) { List <GameSweet> matchlist = MatchSweets(sweetsarray[y, x], x, y); if (matchlist != null) { SweetsType specialSweetsType = SweetsType.COUNT;//特殊类甜品产生flag; GameSweet randomSweet = matchlist[Random.Range(0, matchlist.Count)]; int specialSweetX = randomSweet.X; int specialSweetY = randomSweet.Y; if (matchlist.Count == 4) { specialSweetsType = (SweetsType)Random.Range((int)SweetsType.ROW_CLEAR, (int)SweetsType.COLUMN_CLEAR); } //5个同样块消除时判定是行还是列 RainbowSweet产生条件 else if (matchlist.Count > 4) { specialSweetsType = SweetsType.RAINBOWCANDY; } for (int i = 0; i < matchlist.Count; i++)//---清除符合条件的所有块 { if (ClearSweet(matchlist[i].X, matchlist[i].Y)) { needRefill = true; } } if (specialSweetsType != SweetsType.COUNT) { Destroy(sweetsarray[specialSweetY, specialSweetX]); GameSweet newsweet = CreateSweet(specialSweetX, specialSweetY, specialSweetsType); if (newsweet.CanColor() && specialSweetsType == SweetsType.ROW_CLEAR || specialSweetsType == SweetsType.COLUMN_CLEAR) { newsweet.ColorComponent.SetColor(matchlist[0].ColorComponent.Color); } else if (specialSweetsType == SweetsType.RAINBOWCANDY && newsweet.CanColor()) { newsweet.ColorComponent.SetColor(ColorSweet.ColorEnum.ANYCOLORS); } } } } } } return(needRefill); }
//判断甜品是否相邻 private bool IsFriend(GameSweet sweet1, GameSweet sweet2) { //1.X相同 //2.Y相同 return(sweet1.X == sweet2.X && Mathf.Abs(sweet1.Y - sweet2.Y) == 1 || sweet1.Y == sweet2.Y && Mathf.Abs(sweet1.X - sweet2.X) == 1); }
private bool ClearMatchedSweet() { bool isNeedFill = false; for (int x = 0; x < xColumn; x++) { for (int y = 0; y < yRow; y++) { if (sweets[x, y].CanClear()) { List <GameSweet> matchList = MatchSweets(sweets[x, y], x, y); if (matchList != null) { SweetsType specialType = SweetsType.COUNT; GameSweet randomSweet = matchList[Random.Range(0, matchList.Count)]; int specialX = randomSweet.X; int specialY = randomSweet.Y; if (matchList.Count == 4) { specialType = (SweetsType)Random.Range((int)SweetsType.ROW_CLEAR, (int)SweetsType.COLUMN_CLEAR); } if (matchList.Count == 5) { specialType = SweetsType.RAINBOWCANDY; } for (int i = 0; i < matchList.Count; i++) { ClearSweet(matchList[i].X, matchList[i].Y); isNeedFill = true; } if (specialType != SweetsType.COUNT) { Destroy(sweets[specialX, specialY]); GameSweet gameSweet = CreateNewSweet(specialX, specialY, specialType); if ((gameSweet.Type == SweetsType.ROW_CLEAR || gameSweet.Type == SweetsType.COLUMN_CLEAR) && gameSweet.CanColor() && matchList[0].CanColor()) { gameSweet.ColorCommpont.SetColor(matchList[0].ColorCommpont.Color); } else if (gameSweet.Type == SweetsType.RAINBOWCANDY) { gameSweet.ColorCommpont.SetColor(ColorSweet.ColorType.ANY); } } } } } } return(isNeedFill); }
//清除完成匹配的元素 public bool ClearAllMatchSweet() { bool needReFill = false; for (int y = 0; y < yRow; y++) { for (int x = 0; x < xColumn; x++) { if (sweets[x, y].CanClear()) { // 返回的需要删除的元素列表 List <GameSweet> matchList = MatchSweets(sweets[x, y], x, y); if (matchList != null) { // Debug.Log("消除列表长度="+matchList.Count); SweetType specialSweetType = SweetType.COUNT; //在随机一个消除位置生成一个行消除或者列消除 GameSweet birthSpecialSweet = matchList[Random.Range(0, matchList.Count)]; int specialX = birthSpecialSweet.X; int specialY = birthSpecialSweet.Y; if (matchList.Count == 4) { // Debug.Log("开始产生特殊物品!!!!!!!!!!!!!!!"); //随机一个行消除或者列消除 specialSweetType = (SweetType)Random.Range((int)SweetType.ROW_CLEAR, (int)SweetType.RAINBOWCANDY); } for (int i = 0; i < matchList.Count; i++) { //if (matchList[i] == null) // continue; if (ClearSweet(matchList[i].X, matchList[i].Y)) { needReFill = true; } } if (specialSweetType != SweetType.COUNT) { //Debug.Log("开始产生特殊物品"); Destroy(sweets[specialX, specialY]); GameSweet newSweet = CreatNewSweet(specialX, specialY, specialSweetType); if (specialSweetType == SweetType.ROW_CLEAR || specialSweetType == SweetType.COLUMN_CLEAR && newSweet.CanMove() && matchList[0].CanColor()) { //newSweet.ColorComponent.SetColor(matchList[0].ColorComponent.Color); } else { } } } } } } return(needReFill); }
/// <summary> /// 清除全部完成匹配的甜品 /// </summary> /// <returns></returns> private bool ClearAllMatchedSweet() { bool needRefill = false; for (int y = 0; y < yRow; y++) { for (int x = 0; x < xCol; x++) { if (sweetArr[x, y].CanClear()) { List <GameSweet> matchList = MatchSweets(sweetArr[x, y], x, y); if (matchList != null) { //确认是否产生特殊甜品 SweetsType sweetsType = SweetsType.Count; //随机获取消除列表中的坐标 GameSweet randomSweet = matchList[Random.Range(0, matchList.Count)]; //消除4个生成行或列消除甜品 if (matchList.Count == 4) { sweetsType = (SweetsType)Random.Range((int)SweetsType.Row_Clear, (int)SweetsType.Column_Clear); } //消除5个生成彩虹糖 else if (matchList.Count >= 5) { sweetsType = SweetsType.RainbowCandy; } for (int i = 0; i < matchList.Count; i++) { if (ClearSweet(matchList[i].X, matchList[i].Y)) { needRefill = true; } } //创建行列消除特殊甜品 if (sweetsType != SweetsType.Count) { Destroy(sweetArr[randomSweet.X, randomSweet.Y]); GameSweet newSweet = CreateNewSweet(randomSweet.X, randomSweet.Y, sweetsType); if (sweetsType == SweetsType.Row_Clear || sweetsType == SweetsType.Column_Clear && newSweet.CanColor() && matchList[0].CanColor()) { newSweet.colorSweet.SetSprite(matchList[0].colorSweet.colorType); } else if (sweetsType == SweetsType.RainbowCandy & newSweet.CanColor()) { newSweet.colorSweet.SetSprite(ColorType.Any); } } } } } } return(needRefill); }
IEnumerator ClearChangge(GameSweet sweet1, GameSweet sweet2) { yield return(new WaitForSeconds(0.3f)); int TempX = sweet1.X; int TempY = sweet1.Y; sweet1.MoveComponent.Move(sweet2.X, sweet2.Y, fileTime); sweet2.MoveComponent.Move(TempX, TempY, fileTime); }
public GameSweet CreateSweet(int x, int y, SweetsType type) { print(x + "x,y" + y); GameSweet go = Instantiate(sweetPrefabDict[type], CorrectPosition(x, y), Quaternion.identity); go.transform.parent = transform; sweetsarray[y, x] = go; sweetsarray[y, x].Init(x, y, Instance, type); return(sweetsarray[y, x]); }
//鼠标操作交换位置时 public void ExChangeSweets(GameSweet sweetOnclick1, GameSweet sweetOnclick2) { if (sweetOnclick1.Equals(sweetOnclick2)) { return; } if (sweetOnclick1.CanMove() && sweetOnclick2.CanMove()) { sweetsarray[sweetOnclick1.Y, sweetOnclick1.X] = sweetOnclick2; sweetsarray[sweetOnclick2.Y, sweetOnclick2.X] = sweetOnclick1;//记录位子更新 if (MatchSweets(sweetOnclick1, sweetOnclick2.X, sweetOnclick2.Y) != null || MatchSweets(sweetOnclick2, sweetOnclick1.X, sweetOnclick1.Y) != null || sweetOnclick1.Type == SweetsType.RAINBOWCANDY || sweetOnclick2.Type == SweetsType.RAINBOWCANDY)//可以交换时 { sweetsarray[sweetOnclick1.Y, sweetOnclick1.X] = sweetOnclick2; sweetsarray[sweetOnclick2.Y, sweetOnclick2.X] = sweetOnclick1;//记录位子更新 int tempx = sweetOnclick1.X , tempy = sweetOnclick1.Y; sweetOnclick1.MoveComponent.Move(sweetOnclick2.X, sweetOnclick2.Y, fillTime); sweetOnclick2.MoveComponent.Move(tempx, tempy, fillTime); if (sweetOnclick1.Type == SweetsType.RAINBOWCANDY && sweetOnclick1.CanClear() && sweetOnclick2.CanClear()) { ClearColorSweet clearcolor = sweetOnclick1.GetComponent <ClearColorSweet>(); if (clearcolor != null) { clearcolor.ClearColor = sweetOnclick2.ColorComponent.Color; } ClearSweet(sweetOnclick1.X, sweetOnclick1.Y); } if (sweetOnclick2.Type == SweetsType.RAINBOWCANDY && sweetOnclick1.CanClear() && sweetOnclick2.CanClear()) { ClearColorSweet clearcolor = sweetOnclick2.GetComponent <ClearColorSweet>(); if (clearcolor != null) { clearcolor.ClearColor = sweetOnclick1.ColorComponent.Color; } ClearSweet(sweetOnclick2.X, sweetOnclick2.Y); } pressedSweet = null; enteredSweet = null; ClearAllMatchedSweet(); StartCoroutine(AllFill()); } else { sweetsarray[sweetOnclick1.Y, sweetOnclick1.X] = sweetOnclick1; sweetsarray[sweetOnclick2.Y, sweetOnclick2.X] = sweetOnclick2;//记录位子更新 } } }
//交换两个甜品的方法 private void ExchangeSweets(GameSweet sweet1, GameSweet sweet2) { if (sweet1.CanMove() && sweet2.CanMove()) { sweets[sweet1.X, sweet1.Y] = sweet2; sweets[sweet2.X, sweet2.Y] = sweet1; if (MatchSweets(sweet1, sweet2.X, sweet2.Y) != null || MatchSweets(sweet2, sweet1.X, sweet1.Y) != null || sweet1.Type == SweetsType.RAINBOWCANDY || sweet2.Type == SweetsType.RAINBOWCANDY) { int tempX = sweet1.X; int tempY = sweet1.Y; sweet1.MovedComponent.Move(sweet2.X, sweet2.Y, fillTime); sweet2.MovedComponent.Move(tempX, tempY, fillTime); if (sweet1.Type == SweetsType.RAINBOWCANDY && sweet1.CanClear() && sweet2.CanClear()) { ClearColorSweet clearColor = sweet1.GetComponent <ClearColorSweet>(); if (clearColor != null) { clearColor.ClearColor = sweet2.ColoredComponent.Color; } ClearSweet(sweet1.X, sweet1.Y); } if (sweet2.Type == SweetsType.RAINBOWCANDY && sweet2.CanClear() && sweet1.CanClear()) { ClearColorSweet clearColor = sweet2.GetComponent <ClearColorSweet>(); if (clearColor != null) { clearColor.ClearColor = sweet1.ColoredComponent.Color; } ClearSweet(sweet2.X, sweet2.Y); } ClearAllMatchedSweet(); StartCoroutine(AllFill()); pressedSweet = null; enteredSweet = null; } else { sweets[sweet1.X, sweet1.Y] = sweet1; sweets[sweet2.X, sweet2.Y] = sweet2; } } }
/// <summary> /// 目标糖果 /// </summary> /// <param name="sweet"></param> public void EnterSweet(GameSweet sweet) { if (GameUI != null && GameUI.visible) { _enterSweet = sweet; } if (IsFriend(_pressSweet, _enterSweet)) { ExchangeSweet(_pressSweet, _enterSweet); } }