public int FindWeed(Weed curWeed) { foreach (var item in field.weeds) { if (curWeed.X == item.X && curWeed.Y == item.Y) { return(field.weeds.IndexOf(item)); } } return(-1); }
public void DigUpWeed(Weed curWeed) { var i = FindWeed(curWeed); if (i != -1) { if (player.CurrentPos.X == curWeed.X && player.CurrentPos.Y - 1 == curWeed.Y) { field.weeds[i].WeedState = WeedStates.Dead; field.field[field.weeds[i].X, field.weeds[i].Y] = FieldCellStates.Empty; player.Scores += 4; } } }
public void FreezeWeed(Weed curWeed) { var incidentWeeds = new List <Weed>(); for (var x = -1; x <= 1; x++) { for (var y = -1; y <= 1; y++) { if ((x == 0 || y == 0) && !(x == 0 && y == 0)) { incidentWeeds.Add(new Weed(curWeed.X + x, curWeed.Y + y)); } } } foreach (var weed in incidentWeeds) { var i = FindWeed(weed); if (i != -1) { field.weeds[i].WeedState = WeedStates.Freezed; } } }
public bool IsCellContainWeed(Weed cell) { return(weeds.Contains(cell)); }