예제 #1
0
파일: Game1.cs 프로젝트: DuckDefense/duck
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            ContentLoader.SetContent(Content, graphics);
            _contentLoader.LoadContent();

            var playerList = DatabaseConnector.GetCharacters(Login.UserName);
            player = playerList[0];

            if (player.Monsters.Count == 0)
            {

                List<string> lines = new List<string>
                {
                    $"Oh..\n(Press `{Settings.conversation}` to advance in conversations",
                    $"Hello, I'm professor Koak\nYou must be {player.Name}",
                    "Nice to meet you.",
                    "I've heard you are new to this place.",
                    "This is a place overrun with monsters.",
                    "Without your own, they can be deadly!",
                    "So let's get you started.",
                    "I have three monsters here,",
                    "And you can choose one of them!",
                    "So have at them.",
                    "Come now, I won't bite!"
                };
                intro = new Conversation.Message(lines, Color.Black, new Character("Koak"));
                intro.Visible = true;
                Armler = new Button(new Rectangle(96, 128, 96, 96), ContentLoader.ArmlerFront);
                Mimird = new Button(new Rectangle(192, 128, 96, 96), ContentLoader.MimirdFront);
                Guilail = new Button(new Rectangle(288, 128, 96, 96), ContentLoader.GuilailFront);
            }

            menu = new Menu(player, new Vector2(Settings.ResolutionWidth - 64, 0));
        }
예제 #2
0
파일: Shop.cs 프로젝트: DuckDefense/duck
        public void Update(MouseState cur, MouseState prev)
        {
            if (buyButton.IsClicked(cur, prev)) {
                Buy(cur, prev);
                drawBuy = true;
                drawSell = false;
            }
            if (sellButton.IsClicked(cur, prev)) {
                Sell(cur, prev);
                drawSell = true;
                drawBuy = false;
            }
            if (drawSell) Sell(cur, prev);
            if (drawBuy) Buy(cur, prev);
            if (SelectedCapture != null && SelectedCapture.Amount > 0 || SelectedMedicine != null && SelectedMedicine.Amount > 0) {
                if (drawSell) {
                    List<string> selllines = new List<string>
                        {
                            "Are you sure you want to sell this?"
                        };
                    drawSellConfirm = true;
                    sell = new Conversation.Message(selllines, Color.Black, ShopKeeper);
                    Rectangle rec = new Rectangle(0, ContentLoader.GrassyBackground.Height + (ContentLoader.Button.Height * 2), ContentLoader.Button.Width, ContentLoader.Button.Height);
                    yesButton = new Button(new Rectangle(rec.X += ContentLoader.Button.Width, rec.Y + (ContentLoader.Button.Height * 4), rec.Width, rec.Height), ContentLoader.Button, "Yes", ContentLoader.Arial);
                    NoButton = new Button(new Rectangle(rec.X += ContentLoader.Button.Width, rec.Y + (ContentLoader.Button.Height * 4), rec.Width, rec.Height), ContentLoader.Button, "No", ContentLoader.Arial);
                }
                if (drawBuy) {
                    List<string> buylines = new List<string>();
                    if (SelectedMedicine != null) {
                        if (player.Money >= SelectedMedicine.Worth) {
                            buylines = new List<string> {
                                $"Are you sure you want to buy this? It costs {SelectedMedicine.Worth}"
                            };
                            drawBuyConfirm = true;
                            buy = new Conversation.Message(buylines, Color.Black, ShopKeeper);
                            Rectangle rec = new Rectangle(0, ContentLoader.GrassyBackground.Height + (ContentLoader.Button.Height * 2), ContentLoader.Button.Width, ContentLoader.Button.Height);
                            yesButton = new Button(new Rectangle(rec.X += ContentLoader.Button.Width, rec.Y + (ContentLoader.Button.Height * 4), rec.Width, rec.Height), ContentLoader.Button, "Yes", ContentLoader.Arial);
                            NoButton = new Button(new Rectangle(rec.X += ContentLoader.Button.Width, rec.Y + (ContentLoader.Button.Height * 4), rec.Width, rec.Height), ContentLoader.Button, "No", ContentLoader.Arial);

                        }
                        else {
                            buylines = new List<string> { "You don't have enough money" };
                            buy = new Conversation.Message(buylines, Color.Black, ShopKeeper);
                        }
                    }
                    else if (SelectedCapture != null) {
                        if (player.Money >= SelectedCapture.Worth) {
                            buylines = new List<string> {
                                $"Are you sure you want to buy this? It costs {SelectedCapture.Worth}"
                            }; drawBuyConfirm = true;
                            buy = new Conversation.Message(buylines, Color.Black, ShopKeeper);
                            Rectangle rec = new Rectangle(0, ContentLoader.GrassyBackground.Height + (ContentLoader.Button.Height * 2), ContentLoader.Button.Width, ContentLoader.Button.Height);
                            yesButton = new Button(new Rectangle(rec.X += ContentLoader.Button.Width, rec.Y + (ContentLoader.Button.Height * 4), rec.Width, rec.Height), ContentLoader.Button, "Yes", ContentLoader.Arial);
                            NoButton = new Button(new Rectangle(rec.X += ContentLoader.Button.Width, rec.Y + (ContentLoader.Button.Height * 4), rec.Width, rec.Height), ContentLoader.Button, "No", ContentLoader.Arial);
                        }
                        else {
                            buylines = new List<string> { "You don't have enough money" };
                            buy = new Conversation.Message(buylines, Color.Black, ShopKeeper);
                        }
                    }
                }
            }
            if (drawSellConfirm) {
                if (yesButton.IsClicked(cur, prev)) {
                    if (SelectedMedicine != null) {
                        SelectedMedicine.Amount -= 1;
                        player.Money += SelectedMedicine.Worth / 2;
                        drawSellConfirm = false;
                        SelectedMedicine = null;
                    }
                    if (SelectedCapture != null) {
                        SelectedCapture.Amount -= 1;
                        player.Money += SelectedCapture.Worth / 2;
                        drawSellConfirm = false;
                        SelectedCapture = null;
                    }
                }
                if (NoButton.IsClicked(cur, prev)) {
                    SelectedMedicine = null;
                    SelectedCapture = null;
                }
            }

            if (drawBuyConfirm) {
                if (yesButton.IsClicked(cur, prev)) {
                    if (SelectedMedicine != null) {
                        player.Inventory.Add(SelectedMedicine, 1);
                        player.Money -= SelectedMedicine.Worth;
                        drawBuyConfirm = false;
                        SelectedMedicine = null;
                    }
                    if (SelectedCapture != null) {
                        player.Inventory.Add(SelectedCapture, 1);
                        player.Money -= SelectedCapture.Worth;
                        drawBuyConfirm = false;
                        SelectedCapture = null;
                    }
                }
                if (NoButton.IsClicked(cur, prev)) {
                    SelectedMedicine = null;
                    SelectedCapture = null;
                    drawBuyConfirm = false;
                }
            }
            Drawer.UpdateItemButtons(cur, prev);
        }