/// <summary> /// /// </summary> /// <returns></returns> public Boldi CreateBoldi() { Boldi res = CreatePiece <Boldi>(); m_Boldies.Add(res); res.SetParent(m_BoldiRoot); return(res); }
/// <summary> /// /// </summary> /// <param name="teamId"></param> /// <returns></returns> public Boldi GetBoldi(int teamId) { Boldi res = GetBoldi(); // prepare boldi res.TeamId = teamId; res.SetActive(true); return(res); }
/// <summary> /// /// </summary> /// <param name="boldi"></param> public void OnHit(Boldi boldi) { if (TeamId != boldi.TeamId) { if (m_BoldiCount > 0) { // kill defender Boldies SetBoldiCount(m_BoldiCount - 1); } else { int formerTeamId = TeamId; // change owner TeamId = boldi.TeamId; m_Gameboard.OnHomeChangedOwner(this, formerTeamId); // check team death if (formerTeamId != Gameboard.c_NeutralTeamId) { IHome[] homes = m_Gameboard.GetHomes(formerTeamId, true); if (homes == null || homes.Length == 0) { m_Gameboard.OnHomelessTeam(formerTeamId); } } } } else { // grow current boldi count, it is mine SetBoldiCount(m_BoldiCount + 1); } // recycle the Boldi for further use m_Gameboard.Pool.ReturnBoldi(boldi); }
/// <summary> /// /// </summary> /// <param name="boldi"></param> public void ReturnBoldi(Boldi boldi) { boldi.SetActive(false); m_Boldies.Push(boldi); }