/// <summary> /// 初始化背景格子 /// </summary> void FlushLetterCell() { if (transform.childCount < (m_nRowNum * m_nColNum)) { for (int i = transform.childCount; i < (m_nRowNum * m_nColNum); i++) { GameObject cell = Instantiate(m_Cell); cell.transform.SetParent(transform); cell.name = "letter_" + i; cell.transform.localPosition = Vector3.zero; cell.transform.localScale = Vector3.one; m_LetterIndexDict[i] = cell; } } for (int i = 0; i < transform.childCount; i++) { transform.GetChild(i).gameObject.SetActive(i < (m_nRowNum * m_nColNum)); BaseLetter letter = transform.GetChild(i).GetComponent <BaseLetter>(); letter.SetData(i, GetLetterStr(i), GetRowCol(i)); SetLetterBrothers(letter); } //展示效果 if (m_ShowEffect) { for (int i = 0; i < m_nColNum * m_nRowNum; i++) { int curRow = i / m_nColNum; int curCol = i % m_nColNum; transform.GetChild(i).GetComponent <Image>().color = ((curRow + curCol) % 2 == 0) ? Color.gray : Color.clear; } } }
/// <summary> /// 设置字母的周围 /// </summary> /// <param name="letter"></param> void SetLetterBrothers(BaseLetter letter) { int letterIndex = letter.m_LetterIndex; //左 if (letter.m_IndexPos.field2 != 0) { letter.m_LeftLetter = GetBaseLetter(letterIndex - 1); } //右 if (letter.m_IndexPos.field2 != m_nColNum - 1) { letter.m_RightLetter = GetBaseLetter(letterIndex + 1); } //上 if (letter.m_IndexPos.field1 != 0) { letter.m_TopLetter = GetBaseLetter(letterIndex - m_nColNum); } //下 if (letter.m_IndexPos.field1 != m_nRowNum - 1) { letter.m_BottomLetter = GetBaseLetter(letterIndex + m_nColNum); } }
public void Test1() { var letters = new BaseLetter[] { new Letter() { Title = "simple letter" }, new SecureLetter() { Title = "secure letter" } }; foreach (var letter in letters) { letter.Send(); // отправляем письма } }