private void OnTriggerEnter(Collider collider) { if(collider.gameObject.tag=="Candy") { c = collider.gameObject.GetComponent<Candy>(); audio.Stop(); if(c.getRoofie()) { audio.PlayOneShot(candyEatingSound); if(playerLight.range < 10) playerLight.range = playerLight.range + 1.6f; if(playerLight.intensity < 1.7) playerLight.intensity = playerLight.intensity + 0.4f; } else { audio.PlayOneShot(roofieEatingSound); if(playerLight.range > 2) playerLight.range = playerLight.range - 1.6f; if(playerLight.intensity > 0.1) playerLight.intensity = playerLight.intensity - 0.38f; } } else if(collider.gameObject.tag=="Finish") { Application.LoadLevel(2); } else if(collider.gameObject.tag=="Enemy") { Application.LoadLevel(3); } Destroy(collider.gameObject); }
override protected void Awake() { base.Awake(); wizard = GameObject.Find("Wizard").GetComponent<Wizard>(); candy = GameObject.Find("Candy").GetComponent<Candy>(); eraserBrush = GameObject.Find("EraserBrush").GetComponent<Brush>(); }
public bool isNeighbor(Candy ca) { if (Neighbors.Contains (ca)) { return true; } return false; }
public void Select(Candy candy) { if (_selected == candy) return; SoundManager.Instance.Play (SoundType.Select); if (_selected) { var prevPosition = CandyToMatrixPosition (_selected); var position = CandyToMatrixPosition (candy); if (Adjacent (prevPosition, position)) { _selected.Select(false); _selected = null; StartCoroutine(Swap(prevPosition, position)); } else { _selected.Select(false); _selected = candy; _selected.Select(true); } } else { _selected = candy; _selected.Select (true); } }
public async Task <int> GetCandyCount(PokemonId id) { Candy candy = await GetCandyFamily(id).ConfigureAwait(false); if (candy != null) { return(candy.Candy_); } return(0); }
public void CandyTest_Constructor() { decimal price = 1.00M; string item = "Candy"; Candy testItem = new Candy(price, item); Assert.AreEqual(item, testItem.Name); Assert.AreEqual(price, testItem.Price); }
private IEnumerator FindMatchesAndCollapse(RaycastHit2D rayCast) { GameObject go = rayCast.collider.gameObject; candyArray.SwapCandiesGO(hitGO, go); Vector3 tempVector = hitGO.transform.position; hitGO.transform.position = rayCast.transform.position; go.transform.position = tempVector; yield return(new WaitForSeconds(1f)); var hitGOMatchesInfo = candyArray.GetMatches(hitGO); var goMatchesInfo = candyArray.GetMatches(go); IEnumerable <GameObject> totalMatches = hitGOMatchesInfo.GetMatchedCandy.Union(goMatchesInfo.GetMatchedCandy).Distinct(); int tempCount = totalMatches.Count(); if (tempCount >= GameVariables.MinimumMatches) { Vector3 _tempVector = hitGO.transform.position; hitGO.transform.position = go.transform.position; go.transform.localPosition = _tempVector; //yield return new WaitForSeconds(1f); candyArray.UndoSwap(); Candy hitGOCache = null; int timeRun = 1; while (totalMatches.Count() >= GameVariables.MinimumMatches) { foreach (var item in totalMatches) { candyArray.Remove(item); RemoveFromScene(item); } var column = totalMatches.Select(_go => _go.GetComponent <Candy>().column).Distinct(); var collapsedInfo = candyArray.Collapse(column); var newCandyInfo = CreateNewCandyinSpecificColumn(column); int maxDistance = Mathf.Max(collapsedInfo.MaxDistance, newCandyInfo.MaxDistance); MoveCandy(newCandyInfo.GetNewCandies(), maxDistance); MoveCandy(collapsedInfo.GetNewCandies(), maxDistance); //yield return new WaitForSeconds(1f * maxDistance); totalMatches = candyArray.GetMatches(collapsedInfo.GetNewCandies()).Union(candyArray.GetMatches(newCandyInfo.GetNewCandies())).Distinct(); timeRun++; } gameState = GameState.None; StartCheckForPotentialMatches(); } }
private Candy Spawn(CandyType type) { GameObject CandyObject = null; Candy Candy = null; switch (type) { case CandyType.Banana: CandyObject = _CandyPooler.SpawnObject(BANANA, Vector3.zero, Quaternion.identity); break; case CandyType.Grapes: CandyObject = _CandyPooler.SpawnObject(GRAPES, Vector3.zero, Quaternion.identity); break; case CandyType.Watermelon: CandyObject = _CandyPooler.SpawnObject(WATERMELON, Vector3.zero, Quaternion.identity); break; case CandyType.Cherry: CandyObject = _CandyPooler.SpawnObject(CHERRY, Vector3.zero, Quaternion.identity); break; case CandyType.Apple: CandyObject = _CandyPooler.SpawnObject(APPLE, Vector3.zero, Quaternion.identity); break; case CandyType.TriangleCandy: CandyObject = _CandyPooler.SpawnObject(TRIANGLE, Vector3.zero, Quaternion.identity); break; case CandyType.SquareCandy: CandyObject = _CandyPooler.SpawnObject(SQUARE, Vector3.zero, Quaternion.identity); break; case CandyType.PentagonCandy: CandyObject = _CandyPooler.SpawnObject(PENTAGON, Vector3.zero, Quaternion.identity); break; case CandyType.HexagonCandy: CandyObject = _CandyPooler.SpawnObject(HEXAGON, Vector3.zero, Quaternion.identity); break; case CandyType.Scatter: CandyObject = _CandyPooler.SpawnObject(SCATTER, Vector3.zero, Quaternion.identity); break; case CandyType.Jackpot: CandyObject = _CandyPooler.SpawnObject(JACKPOT, Vector3.zero, Quaternion.identity); break; } Candy = CandyObject.GetComponent <Candy>(); CandyObject.SetActive(false); return(Candy); }
public IActionResult Add(AddCandyDto newCandy) { var candy = new Candy { Name = newCandy.Name, Texture = newCandy.Texture }; _repo.AddCandy(newCandy); return(Ok()); }
public void AddItem() { IWeaverPath p = NewPath(); var candy = new Candy(); p.AddItem(candy); Assert.AreEqual(1, p.Length, "Incorrect Length."); Assert.AreEqual(candy, p.ItemAtIndex(0), "Incorrect item at index 0."); }
private void AddMathes(Candy candy) { if (candyMatches == null) { candyMatches = new ArrayList(); } if (candyMatches.IndexOf(candy) == -1) { candyMatches.Add(candy); } }
public void Delete(Candy candy) { var shoppingCartItems = _candyContext.ShoppingCartItem.Where(x => x.Candy.Id == candy.Id).ToList(); if (shoppingCartItems != null) { _candyContext.RemoveRange(shoppingCartItems); } _candyContext.Candy.Remove(candy); _candyContext.SaveChanges(); }
public void EatMessage_Candy_Test() { //arrange VendingMachineItem testItem = new Candy("Snickers"); //act string eatMessage = testItem.EatMessage; //assert Assert.AreEqual("Munch Munch, Yum!", eatMessage); }
private void Setup() { var android = new ElecDevice(3, 3.00f, "Android(on sale)", "Mini-USB"); var winPhone = new ElecDevice(3, 4.00f, "Windows Phone(on sale)", "Micro-USB"); var chips = new Snack(3, 1.50f, "Sun Chips", 150); var dots = new Candy(3, 0.75f, "Dots", 100); Products.AddRange(new IPurchasable[] { android, winPhone, chips, dots }); }
private void RefillBoard() { int[,] refillMatrix = new int[m_horizontalSize, m_verticalSize]; int[] candiesToSpawn = new int[m_horizontalSize]; for (int i = 0; i < m_horizontalSize; i++) { for (int j = 0; j < m_verticalSize; j++) { if (m_board[i, j] == null) { int lowerPosition = j; int k = 1; while (j + k < m_verticalSize && m_board[i, j + k] == null) { k++; } for (int l = j + k; l < m_verticalSize; l++) { refillMatrix[i, l] -= k; } candiesToSpawn[i] += k; j += k - 1; } } } for (int i = 0; i < m_horizontalSize; i++) { for (int j = 0; j < m_verticalSize; j++) { if (refillMatrix[i, j] < 0 && m_board[i, j]) { m_board[i, j].MoveDown(new Vector2Int(i, j + refillMatrix[i, j]), refillMatrix[i, j] * m_distanceUnits); m_board[i, j + refillMatrix[i, j]] = m_board[i, j]; } } for (int j = 0; j < candiesToSpawn[i]; j++) { Candy prefabToInstantiate = m_candyPrefabsDictonary.Values.ToList()[Random.Range(0, m_candyPrefabsDictonary.Count())][RandomCandyTypeIndex()]; Candy candy = InstatiateCandyAtPosition(prefabToInstantiate, m_startSpawnPosition + new Vector2(i * m_distanceUnits, (m_verticalSize + j) * m_distanceUnits)); int verticalIndex = m_verticalSize - candiesToSpawn[i] + j; candy.SetUp(); m_board[i, verticalIndex] = candy; candy.MoveDown(new Vector2Int(i, verticalIndex), -(candiesToSpawn[i]) * m_distanceUnits); } } }
private Candy AddCandy(int rowIndex, int columnIndex) { Candy c = Instantiate(candy) as Candy; c.transform.parent = this.transform; c.columnIndex = columnIndex; c.rowIndex = rowIndex; c.UpdatePosition(); c.game = this; return(c); }
public void Setup() { candyA = new Candy("Hershey", 2.99m, "Sweet", "Blue"); Dictionary <string, Candy> products = new Dictionary <string, Candy>() { { candyA.name, candyA }, }; transactions = new TransactionManager(products); }
//根据特殊糖果记录列表添加特殊糖果 void addSpecial(List <SCandy> speciallist) { for (int index = 0; index < speciallist.Count; index++) { SCandy temp_struct = speciallist[index]; Vector3 vpos = new Vector3(BVector.x + temp_struct.mCol * xOff, BVector.y + temp_struct.mRow * yOff, 0f); Candy item = NewCandy(temp_struct.mCol, temp_struct.mRow, vpos, temp_struct.mType, temp_struct.mIndex); setCandy(item); } }
public override bool isMatch(int x, int y, Candy c, Candy r) { if (c != null) { if ((c.type == CandyType.StripH) || (c.type == CandyType.StripV) || ((c.type == CandyType.Big))) { return(base.isMatch(x, y, c, r)); } } return(false); }
//重复使用已有的游戏对象 private Candy reuseCandy(_TYPE pType, int pIndex) { Candy result = null; result = RecycleList.Find((x) => (x.mType == pType && x.mIndex == pIndex)); if (null != result) { RecycleList.Remove(result); } return(result); }
public static void SwapRowCol(Candy c1, Candy c2) { int temp = c1.Row; c1.Row = c2.Row; c2.Row = temp; temp = c1.Col; c1.Col = c2.Col; c2.Col = temp; }
public IActionResult Create(Candy candy) { if (!ModelState.IsValid) { return(View(candy)); } _candyService.Create(candy); return(RedirectToAction("List")); }
public static ArrayList GetCandyList() { var result = new ArrayList(); for (int i = 0; i < CandyNames.Count(); i++) { Candy candy = Candy.LoadFromFile(CandyNames[i]); result.Add(candy); // сохраняем все конфеты в списке, чтобы потом было удобнее работать } return(result); }
public static void SwapRowColumn(Candy c1, Candy c2) { int temp = c1.Row; c1.Row = c2.Row; c2.Row = temp; temp = c1.Column; c1.Column = c2.Column; c2.Column = temp; }
// void ControllEventCallback(object sender, ActionController.ControllEventArgs e) { Candy item0 = e.srcCandy; Candy item1 = e.destCandy; // setCandy(item0); setCandy(item1); // switch (e.mType) { case 0: { isExchange = true; //设置交换状态为真 isReadyToCheck = true; //打开检测开关 // this.onReadyCallback(new GameControllerEventArgs(_STATUS.BUSY, _OPERATIONS.EXCHANGE)); //通知不可以交换位置 // break; } case 1: { // addToDestroyList(item0); // addToDestroyList(item1); // Candy temp_item = (!item0.isSpecial) ? item0 : item1; // List <Candy> item_list = findCandysOfType(temp_item); // addToDestroyList(item_list); // StartCoroutine(this.waitAndRemoveColorful()); break; } case 2: { break; } case 3: { setCandy(item0); setCandy(item1); break; } default: break; } }
private Candy AddCandy(int colIndex, int rowIndex) { Object o = Instantiate(candy); Candy c = o as Candy; c.transform.parent = game.transform; c.ColunmIndex = colIndex; c.RowIndex = rowIndex; c.UpdatePosition(); c.game = this; return(c); }
public void firstTestMethod() { //action var swetnesses = new List <Sweetness>(); var sweetness1 = new Candy("Alyonka", 100, 20, 50, 70, "yes"); var sweetness2 = new Candy("Alyo", 100, 50, 50, 90, "yes"); var newlist = new List <Sweetness>(); newlist.Add(sweetness1); newlist.Add(sweetness2); Assert.AreNotSame(swetnesses, newlist); }
internal static void AddNewCandy(CandyStorage db, string newCandyName, string newCandyFlavor, string newCandyManufacturer, int newCandyQuantity, int userId) { for (int i = 0; i < newCandyQuantity; i++) { var newCandy = new Candy(newCandyName, newCandyFlavor, DateTime.Now, newCandyManufacturer, userId); var savedCandy = db.SaveNewCandy(newCandy); } Console.WriteLine($"You now you own {newCandyQuantity} piece(s) of {newCandyName} candy!"); Console.WriteLine("Press the 'Enter' key to continue."); Console.ReadLine(); }
public void secondTestMethod() { //action Gift g = new Gift(); Candy c = new Candy(); c = g.TheHaviestCandy(); var candy1 = new Candy("Alyonka", 100, 20, 50, 70, "yes"); Assert.AreNotEqual(candy1, c); }
private Candy AddCandy(int rIndex, int cIndex) { go = Instantiate(candyPrefab) as GameObject; candy = go.GetComponent <Candy>(); candy.transform.parent = this.transform; candy.cIndex = cIndex; candy.rIndex = rIndex; candy.UpdatePosition();//更新位置 return(candy); }
public void Testingsound() { Item testCandy = new Candy("dumdum", 0.05m); Item testGum = new Gum("gumgum", 0.05m); Item testDrink = new Drink("pepsi", 0.05m); Item testChip = new Chip("walkers", 0.05m); Assert.AreEqual("Munch munch, yum!", testCandy.GetSound()); Assert.AreEqual("Crunch crunch, yum!", testChip.GetSound()); Assert.AreEqual("Glug glug, yum!", testDrink.GetSound()); Assert.AreEqual("Chew chew, yum!", testGum.GetSound()); }
public static void SwapCandy(Candy a, Candy b) { int temp = a.Row; a.Row = b.Row; b.Row = temp; int tmp = a.Column; a.Column = b.Column; b.Column = tmp; }
//Add: Add a new candy to the candy table, and add a new entry to user candies table public Candy Add(int userId, Candy candyToAdd) { var sql = @"insert into Candies(CandyName, Manufacturer, FlavorCategory) output inserted.* values(@CandyName, @Manufacturer, @FlavorCategory);"; using (var db = new SqlConnection(connectionString)) { var result = db.QueryFirstOrDefault <Candy>(sql, candyToAdd); return(result); } }
public void moveNegCand(Candy candyToMove, Vector3 toPos, Vector3 fromPos) { Vector3 center = (fromPos + toPos) * 0.5f; center = new Vector3(0, 0, -.01f); Vector3 riseRelCenter = fromPos - toPos; Vector3 setRelCenter = toPos - center; float fracComplete = (Time.time - startTime) / swapRate; candyToMove.transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, fracComplete); candyToMove.transform.position += center; }
public void constructMatchList(string color, Candy ca, int XCoord, int YCoord, ref List<Candy> MatchList) { if (ca == null) { return; } else if (ca.color != color) { return; } else if(MatchList.Contains(ca)) { return; } else{ MatchList.Add(ca); if (XCoord == ca.XCoord || YCoord == ca.YCoord) { foreach(Candy c in ca.Neighbors){ constructMatchList(color, ca, XCoord, YCoord, ref MatchList); } } } }
private void DestroyCandy(Candy item) { if (null != item) { item.gameObject.SetActive(false); AddToRecycleList(item); } }
//设置糖果在数组中的位置 Candy setCandy(Candy item) { ArrayList temp = ShowList[item.mCol] as ArrayList; Candy temp_object = temp[item.mRow] as Candy; // temp[item.mRow] = item; // return temp_object; }
// public void ExchangeEventCallback(object sender,Candy.ExchangeEventArgs e) { Candy item = sender as Candy; //交换位置判断 if(isReadyToExchange){ if (null != exchangeItem ){ if(item != exchangeItem && item.mIndex!=exchangeItem.mIndex){ //列判断是否可以交换位置 if (Mathf.Approximately (item.mPos.y, exchangeItem.mPos.y)) { if (Mathf.Approximately (item.mPos.x + xOff, exchangeItem.mPos.x) || Mathf.Approximately (item.mPos.x - xOff, exchangeItem.mPos.x)) { exchangeList.Clear();//清空交换列表 // exchange_pos(exchangeItem,item);//交换位置 // exchangeList.Add (item); exchangeList.Add (exchangeItem); // isReadyToExchange = false; if(item.isSpecial && exchangeItem.isSpecial){//两个特殊糖果交换 this.onExchange(new ControllEventArgs(exchangeItem,item,2)); }else if(item.isSpecial || exchangeItem.isSpecial){//其中一个是特殊糖果 //任意一个是彩色糖果则触发彩色糖果特效 if(item.mType == GameController._TYPE.COLORFUL || exchangeItem.mType == GameController._TYPE.COLORFUL){ //SendMessage("apply_trigger_special_corlorful_candy",exchangeList); this.onExchange(new ControllEventArgs(exchangeItem,item,1)); } else{ //SendMessage("apply_adjust_postion",exchangeList);//请求更新在数组中的位置 this.onExchange(new ControllEventArgs(exchangeItem,item,0)); } }else{//普通糖果则请求更新在数组中的位置 //SendMessage("apply_adjust_postion",exchangeList);//请求更新在数组中的位置 this.onExchange(new ControllEventArgs(exchangeItem,item,0)); } // exchangeItem = null; } else { exchangeItem.setChosen(false); exchangeItem = item; exchangeItem.setChosen(true); } } else if (Mathf.Approximately(item.mPos.x, exchangeItem.mPos.x)) {//行判断是否可以交换位置 if (Mathf.Approximately(item.mPos.y + yOff, exchangeItem.mPos.y) || Mathf.Approximately(item.mPos.y - yOff, exchangeItem.mPos.y)) { exchangeList.Clear();//清空交换列表 // exchange_pos(exchangeItem, item);//交换位置 // exchangeList.Add(item); exchangeList.Add(exchangeItem); // isReadyToExchange = false; // //如果是彩色糖果则请求触发彩色特殊糖果的效果 if (item.isSpecial && exchangeItem.isSpecial) {//两个特殊糖果交换 this.onExchange(new ControllEventArgs(exchangeItem, item, 2)); } else if (item.isSpecial || exchangeItem.isSpecial) { if (item.mType == GameController._TYPE.COLORFUL || exchangeItem.mType == GameController._TYPE.COLORFUL) { this.onExchange(new ControllEventArgs(exchangeItem, item, 1)); } else { this.onExchange(new ControllEventArgs(exchangeItem, item, 0)); } } else {//普通糖果则请求更新在数组中的位置 this.onExchange(new ControllEventArgs(exchangeItem, item, 0));//请求更新在数组中的位置 } // exchangeItem = null; } else { exchangeItem.setChosen(false); exchangeItem = item; exchangeItem.setChosen(true); } } else { exchangeItem.setChosen(false); exchangeItem = item; exchangeItem.setChosen(true); } }else{ exchangeItem.setChosen(false); exchangeItem = item; item.setChosen (true); } } else { item.setChosen (true); exchangeItem = item; } } }
//添加到匹配列表 private int AddToMatchList(Candy item) { item.setDark(true); if (!MatchList.Contains(item)) { MatchList.Add(item); } return MatchList.Count; }
// Update is called once per frame void Update() { if (isMatched) { for (int i = 0; i < candies.Count; i++) { if (candies [i].isMatched) { candies [i].createCandy (); candies [i].transform.position = new Vector3 ( candies [i].transform.position.x, candies [i].transform.position.y + 6, candies [i].transform.position.z); score = score + 100; } } isMatched = false; } else if (isSwapping) { moveCand (cand1, cand1End, cand1Start); moveCand (cand2, cand2End, cand2Start); if (Vector3.Distance (cand1.transform.position, cand1End) < 0.1f || Vector3.Distance (cand2.transform.position, cand2End) < 0.1f) { cand1.transform.position = cand1End; cand2.transform.position = cand2End; lastCandy = null; isSwapping = false; togglePhysics (false); if (!swapBack) { cand1.toggleSelector (); cand2.toggleSelector (); checkMatch (); } /*else { swapBack = false; } */ } } else if (!determineBoardState ()) { for (int i = 0; i < candies.Count; i++) { checkForNearbyMatches (candies [i]); } } }
public void moveNegCand(Candy candyToMove, Vector3 toPos, Vector3 fromPos) { Vector3 center = (fromPos + toPos) * 0.5f; center = new Vector3 (0, 0, -.01f); Vector3 riseRelCenter = fromPos - toPos; Vector3 setRelCenter = toPos - center; float fracComplete = (Time.time - startTime) / swapRate; candyToMove.transform.position = Vector3.Slerp (riseRelCenter, setRelCenter, fracComplete); candyToMove.transform.position += center; }
//获取同一行的糖果 List<Candy> getSameRow(Candy item) { List<Candy> temp_list = new List<Candy>(); for (int col = 0; col < this.ShowList.Count; col++) { Candy temp_item = getCandy(col, item.mRow); if (null != temp_item) temp_list.Add(temp_item); } return temp_list; }
void Awake() { _placeHolders = new Vector3[_rows][]; for (int i = 0; i < _rows; ++i) _placeHolders [i] = new Vector3[_columns]; _candies = new Candy[_rows][]; for (int i = 0; i < _rows; ++i) _candies [i] = new Candy[_columns]; }
//从当前游戏对象列表中移除游戏物体 private void removeCandy(Candy item) { ArrayList temp = ShowList[item.mCol] as ArrayList; temp.Remove(item); }
bool validMove(Candy candy, int row, int column) { if (column >= 2 && candy.Type == _candies [row] [column - 1].Type && candy.Type == _candies [row] [column - 2].Type) return true; if (column + 2 < _columns && candy.Type == _candies [row] [column + 1].Type && candy.Type == _candies [row] [column + 2].Type) return true; if (column + 1 < _columns && column >= 1 && candy.Type == _candies [row] [column - 1].Type && candy.Type == _candies [row] [column + 1].Type) return true; if (row >= 2 && candy.Type == _candies [row - 1] [column].Type && candy.Type == _candies [row - 2] [column].Type) return true; if (row + 2 < _columns && candy.Type == _candies [row + 1] [column].Type && candy.Type == _candies [row + 2] [column].Type) return true; if (row + 1 < _columns && row >= 1 && candy.Type == _candies [row - 1] [column].Type && candy.Type == _candies [row + 1] [column].Type) return true; return false; }
private List<Candy> GetVerticalMatches(Candy candy) { var candyPosition = CandyToMatrixPosition(candy); int top = candyPosition.first - 1; while (top >= 0 && _candies[top][candyPosition.second].Type == candy.Type) --top; ++top; int bottom = candyPosition.first + 1; while (bottom < _rows && _candies[bottom][candyPosition.second].Type == candy.Type) ++bottom; --bottom; var candies = new List<Candy> (); if (bottom - top + 1 >= 3) { for (int i = top; i <= bottom; ++i) { candies.Add(_candies[i][candyPosition.second]); } } return candies; }
void Awake() { gameManager = GameObject.Find ("GameManager").GetComponent<CandyWizardGameManager>(); candy= GameObject.Find ("Candy").GetComponent<Candy>(); animator = GetComponentInChildren<Animator2D>(); }
public void AddNeighbor(Candy ca) { //if(!Neighbors.Contains(ca)) Neighbors.Add (ca); }
public void swapCandy(Candy currentCand) { if (lastCandy == null) { lastCandy = currentCand; } else if (lastCandy == currentCand) { lastCandy= null; } else{ if(lastCandy.isNeighbor(currentCand)){ cand1Start= lastCandy.transform.position; cand1End= currentCand.transform.position; cand2Start= currentCand.transform.position; cand2End= lastCandy.transform.position; togglePhysics(true); startTime= Time.time; cand1= lastCandy; cand2= currentCand; isSwapping= true; } else { lastCandy.toggleSelector(); lastCandy= currentCand; } } }
//获取同一列的糖果 List<Candy> getSameCol(Candy item) { ArrayList temp_arraylist = ShowList[item.mCol] as ArrayList; List<Candy> temp_list = new List<Candy>(); for (int row = 0; row < temp_arraylist.Count; row++) { Candy temp_item = temp_arraylist[row] as Candy; temp_list.Add(temp_item); } return temp_list; }
public void checkForNearbyMatches(Candy c) { List<Candy> candList = new List<Candy> (); constructMatchList (c.color, c, c.XCoord, c.YCoord, ref candList); fixCandList (c, candList); }
public void RemoveNeighbor(Candy ca) { Neighbors.Remove (ca); }
public void fixCandList(Candy ca, List<Candy> listToFix) { List<Candy> rows = new List<Candy> (); List<Candy> cols = new List<Candy> (); for (int i=0; i<listToFix.Count; i++) { if(ca.XCoord == listToFix[i].XCoord) { rows.Add(listToFix[i]); } if(ca.YCoord == listToFix[i].YCoord) { cols.Add(listToFix[i]); } } if (rows.Count >= amountToMatch) { isMatched= true; for(int i=0; i<rows.Count; i++) { rows[i].isMatched= true; } } if (cols.Count >= amountToMatch) { isMatched= true; for(int i=0; i<cols.Count; i++) { cols[i].isMatched= true; } } }
//获取某一糖果周围8个糖果 private List<Candy> getRound8(Candy item) { List<Candy> result = new List<Candy>(); // Candy top_item = getCandy(item.mCol, item.mRow + 1); if (null != top_item) result.Add(top_item); // Candy bottom_item = getCandy(item.mCol, item.mRow - 1); if (null != bottom_item) result.Add(bottom_item); // Candy left_item = getCandy(item.mCol - 1, item.mRow); if (null != left_item) result.Add(left_item); // Candy right_item = getCandy(item.mCol + 1, item.mRow); if (null != right_item) result.Add(right_item); // Candy left_top_item = getCandy(item.mCol - 1, item.mRow + 1); if (null != left_top_item) result.Add(left_top_item); // Candy left_bottom_item = getCandy(item.mCol - 1, item.mRow - 1); if (null != left_bottom_item) result.Add(left_bottom_item); // Candy right_top_item = getCandy(item.mCol + 1, item.mRow + 1); if (null != right_top_item) result.Add(right_top_item); // Candy right_bottom_item = getCandy(item.mCol + 1, item.mRow - 1); if (null != right_bottom_item) result.Add(right_bottom_item); return result; }
// private int AddToRecycleList(Candy item) { if (!RecycleList.Contains(item)) { RecycleList.Add(item); } return RecycleList.Count; }
void createBomba() { Bomba bomba = new Bomba(); if(RXRandom.Range(0, 100) > 60) { Candy candy = new Candy(); bomba.SetGetCandy = candy; candy.SetSpeed = bomba.GetSpeed; candy.x = bomba.x; candy.y = bomba.y; mBombaNode.AddChild(candy); } mBombaNode.AddChild(bomba); mBombaList.Add(bomba); }
//添加到消除列表 private int addToDestroyList(Candy item) { item.setDark(true); if (!DestroyList.Contains(item)) { DestroyList.Add(item); } return DestroyList.Count; }
//获取某一类型的所有糖果 private List<Candy> findCandysOfType(Candy pitem) { List<Candy> result = new List<Candy>(); for (int col = 0; col < this.mCol; col++) { for (int row = 0; row < this.mRow; row++) { Candy item = getCandy(col, row); if (null != item && !item.isSpecial && item.mIndex == pitem.mIndex) { result.Add(item); } } } return result; }
private List<Candy> GetHorizontalMatches(Candy candy) { var candyPosition = CandyToMatrixPosition(candy); int left = candyPosition.second - 1; while (left >= 0 && _candies[candyPosition.first][left].Type == candy.Type) --left; ++left; int right = candyPosition.second + 1; while (right < _columns && _candies[candyPosition.first][right].Type == candy.Type) ++right; --right; var candies = new List<Candy> (); if (right - left + 1 >= 3) { for (int j = left; j <= right; ++j) { candies.Add(_candies[candyPosition.first][j]); } } return candies; }
private Pair<int, int> CandyToMatrixPosition(Candy candy) { string[] strings = candy.gameObject.name.Split('_'); return new Pair<int, int>(int.Parse(strings[0]), int.Parse(strings[1])); }