public void RemoveLetterButton(LetterButton letterButton) { if (ContainsLetterButton(letterButton)) { LetterSlot slot = GetSlotContainingLetterButton(letterButton); slot.ClearSlot(); } }
//Add a tile to the first empty slot public void AddLetterButtonToFirstEmptySlot(LetterButton letterButton) { LetterSlot emptySlot = GetFirstEmptySlot(); if (emptySlot != null) { emptySlot.AddToSlot(letterButton); } }
//Looping over array to find element. V.inefficient. IndexOf works with Android? //Remove tile from a specific slot public void RemoveTileFromSlot(LetterButton letterButton, LetterSlot letterSlot) { if (ContainsLetterButton(letterButton) && ContainsSlot(letterSlot)) { if (letterSlot.LetterButton == letterButton) { letterSlot.ClearSlot(); } } }
//Add a tile to a specific slot //Checks if slot is in rack, that slot is empty then adds tile public void AddTileToSlot(LetterButton letterButton, LetterSlot letterSlot) { if (ContainsSlot(letterSlot)) { if (!letterSlot.IsOccupied) { letterSlot.AddToSlot(letterButton); } } }
//Check if slot is in this rack private bool ContainsSlot(LetterSlot slotToFind) { foreach (LetterSlot slot in slots) { if (slot == slotToFind) { return(true); } } return(false); }
public void OnClick() { LetterSlot letterSlot = transform.parent.GetComponent <LetterSlot>(); if (letterSlot != null) { Debug.Log("Letter Slot => " + letterSlot.name); LetterRack letterRack = letterSlot.LetterRack; if (letterRack != null) { Debug.Log("Letter Rack => " + letterRack.name); letterRack.LetterButtonTapped(this); } } }
//Returns null if there is no tile in the slot public LetterButton GetLetterButtonInSlot(LetterSlot slot) { return(slot.LetterButton); }