public void OnChangePos(ModifyMonsterCell cell) { if (m_curSelMonster == cell) { return; } cell.SetSelected(false); m_curSelMonster.SetSelected(true); string strName = m_curSelMonster.name; m_curSelMonster.name = cell.name; cell.name = strName; MonsterTeam team = Core.Data.playerManager.RTData.curTeam; int cellPos = team.GetMonsterPos(cell.m_monster.pid); int curSelPos = team.GetMonsterPos(m_curSelMonster.m_monster.pid); team.removeMember(curSelPos); team.removeMember(cellPos); team.setMember(cell.m_monster, curSelPos); team.setMember(m_curSelMonster.m_monster, cellPos); m_grid.Reposition(); SendChangePosMsg(cell.m_monster.pid, m_curSelMonster.m_monster.pid); }
private ModifyMonsterCell CreateMonsterCell(Monster data) { Object prefab = PrefabLoader.loadFromPack("ZQ/ModifyMonsterCell"); if (prefab != null) { GameObject obj = Instantiate(prefab) as GameObject; obj.transform.parent = m_grid.transform; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; obj.transform.localEulerAngles = Vector3.zero; ModifyMonsterCell cell = obj.GetComponent <ModifyMonsterCell>(); cell.InitUI(data); return(cell); } return(null); }
public void InitUI() { if (m_nCurTeamID != Core.Data.playerManager.RTData.curTeamId) { while (m_grid.transform.childCount > 0) { Transform tf = m_grid.transform.GetChild(0); tf.parent = null; Destroy(tf.gameObject); } m_nCurTeamID = Core.Data.playerManager.RTData.curTeamId; int count = 0; MonsterTeam team = Core.Data.playerManager.RTData.curTeam; for (int i = 0; i < team.capacity; i++) { Monster monster = team.getMember(i); if (monster != null) { ModifyMonsterCell cell = CreateMonsterCell(monster); if (count == 0) { cell.SetSelected(true); m_curSelMonster = cell; } else { cell.SetSelected(false); } cell.name = (i + 11).ToString(); count++; } } m_grid.Reposition(); } }
public void ChangeMonsterPos(ModifyMonsterCell cell) { m_modifyMonsterUI.OnChangePos(cell); }