예제 #1
0
        private Picture DrawPalace()
        {
            Player.PalaceData palace  = Human.Palace;
            Picture           picture = new Picture(320, 200);

            picture.AddLayer(_background);
            switch (palace.GetGardenLevel(1))
            {
            case 1: picture.AddLayer(Resources["CBACKS1"], 0, 135); break;

            case 2: picture.AddLayer(Resources["CBACKS2"], 0, 135); break;

            case 3: picture.AddLayer(Resources["CBACKS3"], 0, 135); break;
            }

            for (int i = palace.PalaceLeft; i <= palace.PalaceRight; i++)
            {
                if (i == 3)
                {
                    continue;
                }

                byte        level = palace.GetPalaceLevel(i);
                PalaceStyle style = palace.GetPalaceStyle(i);
                PalacePart  part  = PalacePart.None;

                if (level == 0 && (i < 2 || i > 4))
                {
                    continue;
                }

                int xx = 17;
                switch (i)
                {
                case 1:
                case 2: xx = 17 + (48 * i) - 33; break;

                //case 3: i = 17; break;
                case 4:
                case 5:
                case 6: xx = 185 + ((i - 4) * 48); break;
                }

                switch (i)
                {
                case 0:
                    xx   = 9;
                    part = PalacePart.LeftTower;
                    break;

                case 1:
                case 2:
                    xx = 17 + (48 * i);
                    if (palace.GetPalaceLevel(i - 1) > 0)
                    {
                        part = PalacePart.Wall;
                        xx  -= 24;
                        break;
                    }
                    part = PalacePart.LeftTowerWall;
                    xx  -= 33;
                    break;

                case 4:
                    xx = 185 + ((i - 4) * 48);
                    if (palace.GetPalaceLevel(i + 1) > 0)
                    {
                        part = PalacePart.WallShadow;
                        break;
                    }
                    part = PalacePart.RightTowerWallShadow;
                    break;

                case 5:
                    xx = 185 + ((i - 4) * 48);
                    if (palace.GetPalaceLevel(i + 1) > 0)
                    {
                        part = PalacePart.Wall;
                        break;
                    }
                    part = PalacePart.RightTowerWall;
                    break;

                case 6:
                    xx   = 185 + ((i - 4) * 48) - 3;
                    part = PalacePart.RightTower;
                    break;
                }

                picture.AddLayer(Resources.GetPalace(palace.GetPalaceStyle(i), part, palace.GetPalaceLevel(i)), xx, 37);
            }

            // Draw palace middle
            picture.AddLayer(Resources.GetPalace(palace.GetPalaceStyle(3), PalacePart.Center, palace.GetPalaceLevel(3)), 135, palace.GetPalaceLevel(3) == 0 ? 37 : 38);

            switch (palace.GetGardenLevel(0))
            {
            case 1: picture.AddLayer(Resources["CBRUSH0"], 0, 105); break;

            case 2: picture.AddLayer(Resources["CBRUSH2"], 0, 94); break;

            case 3: picture.AddLayer(Resources["CBRUSH4"], 0, 94); break;
            }
            switch (palace.GetGardenLevel(2))
            {
            case 1: picture.AddLayer(Resources["CBRUSH1"], 184, 105); break;

            case 2: picture.AddLayer(Resources["CBRUSH3"], 184, 94); break;

            case 3: picture.AddLayer(Resources["CBRUSH5"], 184, 94); break;
            }
            return(picture);
        }
예제 #2
0
        public override bool KeyDown(KeyboardEventArgs args)
        {
            Player.PalaceData palace = Human.Palace;

            switch (_currentStage)
            {
            case Stage.Message:
                _currentStage = Stage.SelectPart;
                _update       = true;
                break;

            case Stage.SelectPart:
                bool morph = false;
                _palaceMorph = DrawPalace();

                try
                {
                    switch (args.KeyChar)
                    {
                    case 'A':
                    case 'B':
                    case 'C':
                    {
                        int  index = (int)(args.KeyChar - 'A');
                        byte level = (byte)(palace.GetGardenLevel(index) + 1);
                        if (level > 2)
                        {
                            break;
                        }
                        morph = true; palace.SetGarden(index, (byte)(Human.Palace.GetGardenLevel(2) + 1));
                    }
                    break;

                    case '1':
                    case '2':
                    case '3':
                    case '4':
                    case '5':
                    case '6':
                    case '7':
                    {
                        int  index = (int)(args.KeyChar - '1');
                        byte level = (byte)(palace.GetPalaceLevel(index) + 1);
                        if (level > 4)
                        {
                            break;
                        }
                        morph = true; palace.SetPalace(index, 1, level);
                    }
                    break;
                    }
                    ;
                }
                catch
                {
                    // TODO: Check for valid choice before handling keypress
                    _currentStage = Stage.View;
                    _update       = true;
                    break;
                }
                if (morph)
                {
                    _update       = true;
                    _currentStage = Stage.Morph;
                    break;
                }
                _palaceMorph = null;
                break;

            case Stage.View:
                Destroy();
                break;
            }
            return(true);
        }