本文整理汇总了C#中Grid.isMatchColor方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.isMatchColor方法的具体用法?C# Grid.isMatchColor怎么用?C# Grid.isMatchColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grid
的用法示例。
在下文中一共展示了Grid.isMatchColor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ColoringBombTrigger
public void ColoringBombTrigger(Grid bombGrid,Grid triggerGrid)
{
if (bombGrid == null || triggerGrid == null)
{
return;
}
CellColor targetColor;
List<Grid> mostColorList;
if (bombGrid.isMatchColor(triggerGrid))
{
mostColorList = FindMostOtherColor(triggerGrid);
}else
{
mostColorList = FindColorGrids(triggerGrid);
}
TintGrids(bombGrid,mostColorList);
bombGrid.DestroyCell(Constants.CELL_ELIM_TIME,true,null);
// List<Grid>
}
示例2: TryElim
bool TryElim(Grid g,out List<Grid> finalList,out BombType curBombType)
{
finalList = new List<Grid>();
curBombType = BombType.None;
List<Grid> leftList = new List<Grid>();
CheckSameColorAndAdd(g,0,-1,leftList);
List<Grid> rightList = new List<Grid>();
CheckSameColorAndAdd(g,0,1,rightList);
List<Grid> upList = new List<Grid>();
CheckSameColorAndAdd(g,1,0,upList);
List<Grid> downList = new List<Grid>();
CheckSameColorAndAdd(g,-1,0,downList);
int horCount = leftList.Count + rightList.Count + 1;
int verCount = upList.Count + downList.Count + 1;
var leftUpGrid = mainGrids [g.Row + 1, g.Col - 1];
bool isMatchLeftUp = g.isMatchColor(leftUpGrid);
var upRightGrid = mainGrids [g.Row + 1, g.Col + 1];
bool isMatchUpRight = g.isMatchColor(upRightGrid);
var rightDownGrid = mainGrids [g.Row - 1, g.Col + 1];
bool isMatchRightDown = g.isMatchColor(rightDownGrid);
var downLeftGrid = mainGrids [g.Row - 1, g.Col - 1];
bool isMatchDownLeft = g.isMatchColor(downLeftGrid);
//striped candy
// List<Grid> finalList = new List<Grid>();
if (verCount >= 5 && horCount >= 2) {
//Coloring candy
Debug.Log("Coloring candy");
finalList.AddRange (upList);
finalList.AddRange (downList);
finalList.AddRange (rightList);
finalList.AddRange (leftList);
curBombType = BombType.Coloring;
// ElimGridListAndGenBomb (finalList, g,BombType.Coloring);
} else if (horCount >= 5 && verCount >= 2) {
//Coloring candy
Debug.Log("Coloring candy");
finalList.AddRange (upList);
finalList.AddRange (downList);
finalList.AddRange (rightList);
finalList.AddRange (leftList);
// ElimGridListAndGenBomb (finalList, g,BombType.Coloring);
curBombType = BombType.Coloring;
} else if (verCount >= 5 && horCount == 1) {
//color candy
Debug.Log("Color candy");
finalList.AddRange (upList);
finalList.AddRange (downList);
finalList.AddRange (rightList);
finalList.AddRange (leftList);
// ElimGridListAndGenBomb (finalList, g,BombType.Color);
curBombType = BombType.Color;
} else if (horCount >= 5 && verCount == 1) {
//color candy
Debug.Log("Color candy");
finalList.AddRange (upList);
finalList.AddRange (downList);
finalList.AddRange (rightList);
finalList.AddRange (leftList);
curBombType = BombType.Color;
} else if (leftList.Count > 0 && upList.Count > 0 && isMatchLeftUp) {
//fish candy
Debug.Log("fish1 candy");
finalList.AddRange (upList);
finalList.AddRange (downList);
finalList.AddRange (rightList);
finalList.AddRange (leftList);
finalList.Add (leftUpGrid);
curBombType = BombType.Fish;
} else if (upList.Count > 0 && rightList.Count > 0 && isMatchUpRight) {
//fish candy
Debug.Log("fish2 candy");
finalList.AddRange (upList);
finalList.AddRange (downList);
finalList.AddRange (rightList);
finalList.AddRange (leftList);
finalList.Add (upRightGrid);
curBombType = BombType.Fish;
} else if (rightList.Count > 0 && downList.Count > 0 && isMatchRightDown) {
//fish candy
Debug.Log("fish3 candy");
finalList.AddRange (upList);
finalList.AddRange (downList);
finalList.AddRange (rightList);
finalList.AddRange (leftList);
finalList.Add (rightDownGrid);
curBombType = BombType.Fish;
//.........这里部分代码省略.........
示例3: CheckSameColorAndAdd
void CheckSameColorAndAdd(Grid g,int offRow,int offCol,List<Grid> curList)
{
int curRow = g.Row;
int curCol = g.Col;
while (true) {
int nextRow = curRow + offRow;
int nextCol = curCol + offCol;
// Debug.Log ("nextRow "+ nextRow + "nextCol " +nextCol);
if(!IsInBorder(nextRow,nextCol))
{
return;
}
Grid nextGrid = mainGrids[nextRow,nextCol];
curRow = nextRow;
curCol = nextCol;
if(g.isMatchColor(nextGrid) && g.Cell && nextGrid.Cell.cellBombType != BombType.Coloring)
{
curList.Add(nextGrid);
}else
{
return;
}
}
}
示例4: CheckMatch
void CheckMatch(Grid l ,Grid r)
{
if (BombManager.instance.MatchBomb(l,r))
{
mainGrids.DropCell (Constants.FORM_TIME + 0.1f);
mainGrids.DropNewCells (Constants.FORM_TIME + 0.1f);
return;
}
if (l.isMatchColor (r)) {
//same color no need check ,just back
PlayBackAction();
} else {
List<Grid> leftList;
BombType leftBombType;
bool leftElim = TryElim(l,out leftList, out leftBombType) ;
if (leftElim) {
ElimGridListAndGenBomb (leftList, l,leftBombType);
}
List<Grid> rightList;
BombType rightBombType;
bool rightElim = TryElim(r,out rightList,out rightBombType);
if (rightElim) {
ElimGridListAndGenBomb (rightList, r,rightBombType);
}
bool isElimAble = leftElim || rightElim;
if(isElimAble)
{
mainGrids.DropCell (Constants.FORM_TIME + 0.1f);
mainGrids.DropNewCells (Constants.FORM_TIME + 0.1f);
}else
{
PlayBackAction();
}
}
}