public void CreatePacket(Packet.Data data) { creationPeriod = (packetWidth * 1.5f) / Packet.maxSpeed; if (busy) { return; } nextTimeToCreate = Time.time + creationPeriod; GameObject pgo = null; if (packetPool.Count == 0) { pgo = Instantiate(packetPrefab); InitPacketGameObject(pgo); } else { pgo = packetPool[packetPool.Count - 1]; packetPool.RemoveAt(packetPool.Count - 1); pgo.SetActive(true); } var p = pgo.GetComponent <Packet>(); p.data = data; ReInitPacket(p); bool pushingBlock = showedPackets.Count >= anchoredPacketPositions.Count; bool lastBlock = showedPackets.Count >= anchoredPacketPositions.Count - 1; if (pushingBlock) { var fp = showedPackets[0]; OnPacketDeath?.Invoke(fp, Packet.DeathCause.Drop); fp.onFire = true; Debug.Assert(!fp.onTheMove); showedPackets.RemoveAt(0); //TODO add fp to onFirePackets list fp.MoveTo(exitPos, UtilizePacket); PlacePackets(); } p.MoveTo(anchoredPacketPositions[showedPackets.Count]); showedPackets.Add(p); }
public int ClearPackets(string bodyContent) { int c = 0; for (int i = 0; i < showedPackets.Count; i++) { if (showedPackets[i].data.body == bodyContent) { OnPacketDeath?.Invoke(showedPackets[i], Packet.DeathCause.Clear); ClearPacket(showedPackets[i]); showedPackets.RemoveAt(i--); c++; } } PlacePackets(); //TODO check onFIre packet return(c); }