public Slot MoveTarget(Slot Origin, Movement mov) { Slot Target = null; switch (mov) { case Movement.Up: // se bater na parede de cima if (Origin.Row == 0) { Target = Slots[Slots.GetLength(0) - 1, Origin.Column]; } else { Target = Slots[Origin.Row - 1, Origin.Column]; //movimenta } break; case Movement.Down: //se bater na parede de baixo if (Origin.Row == Slots.GetLength(0) - 1) { Target = Slots[0, Origin.Column]; } else { Target = Slots[Origin.Row + 1, Origin.Column]; } break; case Movement.Left: //se bater na parede da esquerda if (Origin.Column == 0) { Target = Slots[Origin.Row, Slots.GetLength(1) - 1]; } else { Target = Slots[Origin.Row, Origin.Column - 1]; //movimenta } break; case Movement.Right: //se bater na parede da direita if (Origin.Column == Slots.GetLength(1) - 1) { Target = Slots[Origin.Row, 0]; } else { Target = Slots[Origin.Row, Origin.Column + 1]; } break; } return(Target); }
public int[] NewPosition() { int[] pos = new int[2]; Random r = new Random(); do { pos[0] = r.Next(0, Slots.GetLength(0)); pos[1] = r.Next(0, Slots.GetLength(1)); } while (Slots[pos[0], pos[1]].ID != null || Slots[pos[0], pos[1]].IsFruit == true); return(pos); }
public bool IsThereFruit() { for (int l = 0; l < Slots.GetLength(0); l++) { for (int c = 0; c < Slots.GetLength(1); c++) { if (Slots[l, c].IsFruit) { return(true); } } } return(false); }
public IList <Slot> GetSlotsByID(string id) { List <Slot> ImageSnake = new List <Slot>(); for (int l = 0; l < Slots.GetLength(0); l++) { for (int c = 0; c < Slots.GetLength(1); c++) { if (Slots[l, c].ID == id) { ImageSnake.Add(Slots[l, c]); } } } return(ImageSnake); }
public Slot GetSlotByID(string id) { Slot aux = null; for (int l = 0; l < Slots.GetLength(0); l++) { for (int c = 0; c < Slots.GetLength(1); c++) { if (Slots[l, c].ID == id) { aux = Slots[l, c]; } } } return(aux); }