コード例 #1
0
ファイル: Game.cs プロジェクト: alekseyIsakin/LabGame
        public void LoadMap(int curMap)
        {
            Factory.ClearUnits();
            Bitmap bmp = Maps[curMap];

            for (int y = 0; y < bmp.Height; y++)
            {
                Factory.SetHiddenWall(new PointF(-1, y));
                Factory.SetHiddenWall(new PointF(bmp.Height, y));
            }
            for (int x = 0; x < bmp.Width; x++)
            {
                Factory.SetHiddenWall(new PointF(x, -1));
                Factory.SetHiddenWall(new PointF(x, bmp.Width));
            }

            actor = new Actor();
            Factory.RegistrNewUnit(actor);

            for (int y = 0; y < bmp.Height; y++)
            {
                for (int x = 0; x < bmp.Width; x++)
                {
                    string cell    = bmp.GetPixel(x, y).Name;
                    PointF CellPos = new PointF(x, y);

                    if (x == 0 && y == 0)
                    {
                        cell = bmp.GetPixel(0, 1).Name;
                    }

                    switch (cell)
                    {
                    case "ff000000":
                        Factory.SetWall(CellPos);
                        break;

                    case "ffff0000":
                        StartPos = CellPos;
                        break;

                    case "ff00ff00":
                        Factory.SetExitArea(CellPos);
                        break;

                    case "ffffff00":
                        Factory.SetBaseEnemy(CellPos);
                        break;

                    case "ff0000ff":
                        Factory.SetDecal(CellPos);
                        break;

                    case "ffff00ff":
                        Factory.SetDmgArea(CellPos);
                        break;
                    }
                }
            }
            bg = bmp.GetPixel(0, 0);

            Inform.Set_Pos(new PointF());

            actor.Set_Pos(StartPos);
            actor.Set_Sprite(new SquareSprite(PointOp.Mul(CellSize, 0.5f)));
            actor.Set_Shape(new SquareShape(0.5f));
            actor.Set_Speed(0.12f);

            GameIdle = true;
        }