void Update() { if (canv.GetUpdateFlock()) { SetFlockingValues(); } for (int a = boids.Count - 1; a >= 0; --a) { Boid b = boids[a]; Vector3 velocity = b.velocity; velocity += alignment.GetAlignment(boids, a); velocity += cohesion.GetCohesion(boids, a); velocity += separation.GetSeparation(boids, a); velocity += waypoint.GoToNextWaypoint(boids, a); velocity += eatFood.GetEatFood(boids, a); velocity += flee.GetFlee(boids, a); velocity.Normalize(); b.velocity = velocity; b.lookat = b.position + velocity; } for (int i = boids.Count - 1; i >= 0; --i) { if (!boids[i].enemy) { boids[i].transform.position += boids[i].velocity * Time.deltaTime * speed; } } }
/// <summary> /// Renders the element. /// </summary> /// <param name="pdfStyling">The PDF styling.</param> /// <param name="section">The section.</param> /// <exception cref="System.NotImplementedException">The format: X is not implemented for generating Etiquettes.</exception> public void Render(IPdfStyling pdfStyling, Section section) { if (pdfStyling.PageFormat == PageFormat.A4 && pdfStyling.Orientation == Orientation.Portrait) { int cells = (int)(21 / _width.Centimeter); int maxRows = (int)(29.7 / _height.Centimeter); int rows = (int)Math.Ceiling((double)_textLines.Count() / cells); int rowIndex = 0; // For absolute positioning int textLineIndex = 1; for (int r = 0; r < rows; r++) { for (int c = 0; c < cells; c++) { TextFrame frame = section.AddTextFrame(); frame.Top = new Unit(rowIndex * _height); frame.Left = new Unit(c * _width); frame.Width = _width; frame.Height = _height; frame.RelativeVertical = RelativeVertical.Page; if (_margin != null && _margin.Length == 4) { frame.MarginTop = _margin[0]; frame.MarginRight = _margin[1]; frame.MarginBottom = _margin[2]; frame.MarginLeft = _margin[3]; } if (_borderColor.HasValue) { frame.LineFormat.Width = 0.5; frame.LineFormat.Color = _borderColor.Value; } if (_textLines.Count() >= textLineIndex) { IEnumerable <TextLine> textLines = _textLines.ElementAt(textLineIndex - 1); Paragraph paragraph; foreach (TextLine textLine in textLines) { paragraph = frame.AddParagraph(); paragraph.Format.Alignment = _alignment.GetAlignment(); // We add the space but not the text when it's null... if (textLine == null) { continue; } paragraph.AddFormattedText( text: textLine.Text, textFormat: textLine.IsBold ? TextFormat.Bold : TextFormat.NotBold); } } textLineIndex++; //TODO: Calculateable? } rowIndex++; // Add new page if maximum reached if (rows > maxRows && (r + 1) % maxRows == 0) { section.AddPageBreak(); rowIndex = 0; // Reset row to zero because new page's offset starts on top } } } else { throw new NotImplementedException("The format: " + pdfStyling.PageFormat + " is not implemented for generating Etiquettes."); } }