Пример #1
0
        // returns figure group
        public static int DrawMap(bool[,] map)
        {
            int         thismapwidth  = map.GetUpperBound(0) + 1;
            int         thismapheight = map.GetUpperBound(1) + 1;
            IAICallback aicallback    = CSAI.GetInstance().aicallback;
            int         multiplier    = (aicallback.GetMapWidth() / thismapwidth) * 8;

            int figuregroup = 0;

            for (int y = 0; y < thismapheight; y++)
            {
                for (int x = 0; x < thismapwidth; x++)
                {
                    double elevation = aicallback.GetElevation(x * multiplier, y * multiplier) + 10;
                    if (x < (thismapwidth - 1) &&
                        map[x, y] != map[x + 1, y])
                    {
                        figuregroup = aicallback.CreateLineFigure(new Float3((x + 1) * multiplier, elevation, y * multiplier),
                                                                  new Float3((x + 1) * multiplier, elevation, (y + 1) * multiplier), 10, false, 200, figuregroup);
                    }
                    if (y < (thismapheight - 1) &&
                        map[x, y] != map[x, y + 1])
                    {
                        figuregroup = aicallback.CreateLineFigure(new Float3(x * multiplier, elevation, (y + 1) * multiplier),
                                                                  new Float3((x + 1) * multiplier, elevation, (y + 1) * multiplier), 10, false, 200, figuregroup);
                    }
                }
            }
            return(figuregroup);
        }
Пример #2
0
        public static int DrawRectangle(Float3 pos, int width, int height, int groupnumber)
        {
            IAICallback aicallback = CSAI.GetInstance().aicallback;
            double      elevation  = aicallback.GetElevation(pos.x, pos.z) + 10;

            groupnumber = aicallback.CreateLineFigure(pos + new Float3(0, elevation, 0),
                                                      pos + new Float3(width, elevation, 0), 10, false, 200, groupnumber);
            groupnumber = aicallback.CreateLineFigure(pos + new Float3(width, elevation, 0),
                                                      pos + new Float3(width, elevation, height), 10, false, 200, groupnumber);
            groupnumber = aicallback.CreateLineFigure(pos + new Float3(width, elevation, height),
                                                      pos + new Float3(0, elevation, height), 10, false, 200, groupnumber);
            groupnumber = aicallback.CreateLineFigure(pos + new Float3(0, elevation, height),
                                                      pos + new Float3(0, elevation, 0), 10, false, 200, groupnumber);

            return(groupnumber);
        }
Пример #3
0
        public static void DrawCircle(Float3 pos, double radius)
        {
            IAICallback aicallback = CSAI.GetInstance().aicallback;
            Float3      lastpos    = null;

            for (int angle = 0; angle <= 360; angle += 10)
            {
                int    x       = (int)((double)radius * Math.Cos((double)angle * Math.PI / 180));
                int    y       = (int)((double)radius * Math.Sin((double)angle * Math.PI / 180));
                Float3 thispos = new Float3(x, 0, y) + pos;
                if (lastpos != null)
                {
                    aicallback.CreateLineFigure(thispos, lastpos, 10, false, 200, 0);
                }
                lastpos = thispos;
            }
        }