Beispiel #1
0
        public static void Render(Nav.Cell cell, PointF trans, PaintEventArgs e, bool draw_connections, bool draw_id, bool render_move_cost_mult, bool render_threat)
        {
            if (cell.Disabled)
            {
                return;
            }

            DrawRectangle(e.Graphics, cell.Replacement ? REPLACEMENT_CELL_BORDER_PEN : CELL_BORDER_PEN, trans, cell.Min, cell.Max);

            Color cell_color = Color.White;

            if (cell.MovementCostMult < 1)
            {
                int move_cost_level = 255 - (int)Math.Min(GetProportional(cell.MovementCostMult, 0, 1, 20, 255), 255);
                cell_color = Color.FromArgb(255, move_cost_level, 255, move_cost_level);
            }
            else if (cell.MovementCostMult > 1 && render_move_cost_mult)
            {
                int move_cost_level = 255 - (int)Math.Min(GetProportional(cell.MovementCostMult, 1, 100, 20, 255), 255);
                cell_color = Color.FromArgb(255, move_cost_level, move_cost_level, move_cost_level);
            }
            else if (cell.Threat > 0 && render_threat)
            {
                int threat_level = 255 - (int)Math.Min(GetProportional(cell.MovementCostMult, 1, 100, 20, 255), 255);
                cell_color = Color.FromArgb(255, 255, threat_level, threat_level);
            }

            FillRectangle(e.Graphics, cell.Flags == MovementFlag.Fly ? Brushes.Gray : new SolidBrush(cell_color), trans, cell.Min, cell.Max);

            if (draw_connections)
            {
                foreach (Nav.Cell.Neighbour neighbour in cell.Neighbours)
                {
                    DrawLine(e.Graphics, CELL_CONNECTION_PEN, trans, cell.Center, neighbour.border_point);
                }
            }

            if (draw_id)
            {
                DrawString(e.Graphics, Brushes.Black, trans, cell.Min, cell.Id < 0 ? cell.GlobalId + "(G)" : cell.Id.ToString(), 2);
            }
        }