Ejemplo n.º 1
0
        public void ZapiszGrę(Bohater bohater)
        {
            string zapytanie = "INSERT INTO Bohater (Imie, MaxZycie, PosiadaneZycie, Obrazenia, Lvl, Doswiadczenie, Sakwa) " +
                               $"VALUES('{bohater.Imie}', {bohater.MaksymalneŻycie}, {bohater.PosiadaneZycie}, {bohater.Obrazenia}, {bohater.Level}, {bohater.PunktyDoswiadczenia}, {bohater.Sakwa})";

            ModyfikacjaDanych(zapytanie);
        }
Ejemplo n.º 2
0
        public bool CheckCompletion(Bohater gracz)  // sprawdza czy quest został wykonany, jesli w ekwipunku jest odpowiednia ilosc wymaganego przedmiotu, zabiera je i ustawia quest na skonczony
        {
            if (getStatus() == QuestStatus.Complited)
            {
                return(true);
            }
            int iloscWEkwipunku = 0;

            foreach (Przedmiot przedmiot in gracz.Ekwipunek)
            {
                if (przedmiot.getId() == QuestItemId)
                {
                    iloscWEkwipunku += przedmiot.getIlosc();
                }
            }

            if (iloscWEkwipunku >= wymaganaIlosc)
            {
                for (int i = 0; i < wymaganaIlosc; i++)  // usuniecie przedmiotu(przedmiotów) questowych z ekwipunku gracza. UsunPrzedmiot powinien zapewnic poprawne usuniecie i w przypadku stackowalnych i niestackowalnych przedmiotow
                {
                    gracz.UsunPrzedmiot(QuestItemId);
                }
                setStatus(QuestStatus.Complited);

                // nadanie nagrody tutaj?

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        public void UpdateEquipment(Bohater Player)
        {
            postac         = Player;
            PlayerPB.Image = postac.getBattleImage();

            setTextColor();

            listBox1.Items.Clear();

            int i = 0;

            foreach (Przedmiot item in Player.Ekwipunek)
            {
                listBox1.Items.Add(Player.Ekwipunek.ElementAt(i).getNazwa().ToString() + " - " +
                                   Player.Ekwipunek.ElementAt(i).getIlosc().ToString());
                i++;
            }

            bohaterHP.Text    = Player.GetHP().ToString();
            bohaterMP.Text    = Player.GetMP().ToString();
            bohaterHPMax.Text = Player.GetMaxHP().ToString();
            bohaterMPMax.Text = Player.GetMaxMP().ToString();

            bohaterLevel.Text   = Player.GetLevel().ToString();
            bohaterPunktyD.Text = Player.GetSkillpoints().ToString();

            bohaterZloto.Text = Player.GetGold().ToString();

            bohaterInteligencja.Text = Player.GetIntelligence().ToString();
            bohaterZrecznosc.Text    = Player.GetDexterity().ToString();
            bohaterSila.Text         = Player.GetStrength().ToString();

            bohaterExp.Maximum = Player.GetEXPtoLevel();
            bohaterExp.Value   = Player.GetEXP();

            uzycie.Enabled = false;
            uzycie.Visible = false;

            zdjecie.Enabled = false;
            zdjecie.Visible = false;

            if (postac.getZalozonaZbroja() != null)
            {
                imageList1.Images.Add(postac.getZalozonaZbroja().getArmorImage());

                ListViewItem listViewItem = new ListViewItem();
                listViewItem.ImageIndex = 0;
                EquippedArmor.Items.Add(listViewItem);
            }

            if (postac.getZalozonaBron() != null)
            {
                imageList2.Images.Add(postac.getZalozonaBron().getWeaponImage());

                ListViewItem listViewItem = new ListViewItem();
                listViewItem.ImageIndex = 0;
                EquippedWeapon.Items.Add(listViewItem);
            }
        }
Ejemplo n.º 4
0
        static void StworzPostac()
        {
            Console.Clear();
            Console.Write("Podaj imie postaci: ");
            string imie = Console.ReadLine();

            _bohater = new Bohater(imie);
        }
Ejemplo n.º 5
0
        public void UpdateEquipment(Bohater Player)
        {
            postac = Player;

            listBox1.Items.Clear();

            int i = 0;

            foreach (Przedmiot item in Player.Ekwipunek)
            {
                listBox1.Items.Add(Player.Ekwipunek.ElementAt(i).getNazwa().ToString() + " - " +
                                   Player.Ekwipunek.ElementAt(i).getIlosc().ToString());
                i++;
            }

            bohaterZloto.Text = postac.GetGold().ToString();
        }
Ejemplo n.º 6
0
        public void StartCombat(Bohater player, Przeciwnik enemy, int mapX, int mapY)
        {
            if (Player == null)
            {
                Player = player;
            }

            if (Enemy == null)
            {
                Enemy = enemy;
            }

            inCombat   = true;
            playerTurn = true;

            PlayerPB.Image = player.getBattleImage();
            EnemyPB.Image  = enemy.getBattleImage();

            Image img;

            if (mapX < 0 && mapY >= 0)
            {
                mapX *= -1;
                img   = new Bitmap((Image)Gra.Properties.Resources.ResourceManager.GetObject("world_" + mapX + "" + mapY), Width, Height);
            }
            else if (mapX >= 0 && mapY < 0)
            {
                mapY *= -1;
                img   = new Bitmap((Image)Gra.Properties.Resources.ResourceManager.GetObject("world" + mapX + "_" + mapY), Width, Height);
            }
            else if (mapX < 0 && mapY < 0)
            {
                mapX *= -1;
                mapY *= -1;
                img   = new Bitmap((Image)Gra.Properties.Resources.ResourceManager.GetObject("world_" + mapX + "_" + mapY), Width, Height);
            }
            else
            {
                img = new Bitmap((Image)Gra.Properties.Resources.ResourceManager.GetObject("world" + mapX + "" + mapY), Width, Height);
            }

            BackgroundPB.SizeMode = PictureBoxSizeMode.Zoom;
            BackgroundPB.Image    = img;

            UpdateStats();
        }
Ejemplo n.º 7
0
        public IEnumerable <Bohater> ListaZapisanychGier()
        {
            string            zapytanie = "SELECT NrZapisu, Imie, MaxZycie, PosiadaneZycie, Obrazenia, Lvl, Doswiadczenie, Sakwa FROM Bohater";
            DataRowCollection wiersze   = PobierzDane(zapytanie);

            foreach (DataRow wiersz in wiersze)
            {
                string  imie    = wiersz["Imie"].ToString();
                Bohater bohater = new Bohater(imie);
                bohater.MaksymalneŻycie     = (int)wiersz["MaxZycie"];
                bohater.PosiadaneZycie      = (int)wiersz["PosiadaneZycie"];
                bohater.Obrazenia           = (int)wiersz["Obrazenia"];
                bohater.Level               = (int)wiersz["Lvl"];
                bohater.PunktyDoswiadczenia = (int)wiersz["Doswiadczenie"];
                bohater.Sakwa               = (int)wiersz["Sakwa"];
                bohater.NrZapisu            = (int)wiersz["NrZapisu"];
                yield return(bohater);
            }
        }
Ejemplo n.º 8
0
        public void UpdateQuestsList(Bohater Player)
        {
            postac = Player;

            listBox1.Items.Clear();
            quests.Clear();

            int i = 0;

            foreach (Quest quest in Player.quests)
            {
                if ((quest.getIsActive() == true && (quest.getStatus() == QuestStatus.Active || quest.getStatus() == QuestStatus.Success) || quest.getStatus() == QuestStatus.Complited))
                {
                    quests.Add(quest);
                    listBox1.Items.Add(Player.quests.ElementAt(i).getName().ToString() + "\t\t\t\t" + Player.quests.ElementAt(i).getStatus().ToString());
                }

                i++;
            }
        }
Ejemplo n.º 9
0
        static void WczytajGre()
        {
            Console.Clear();
            Dane           dane = new Dane();
            List <Bohater> gry  = dane.ListaZapisanychGier().ToList();

            foreach (Bohater bohater in gry)
            {
                Console.WriteLine($"{bohater.NrZapisu}. {bohater.Imie}");
            }
            string opcja = Console.ReadLine();

            _bohater = gry.FirstOrDefault(g => g.NrZapisu == int.Parse(opcja));
            //foreach(Bohater g in gry)
            //{
            //    if(g.NrZapisu == int.Parse(opcja))
            //    {
            //        _bohater = g;
            //        break;
            //    }
            //}
        }
Ejemplo n.º 10
0
        public void UpdateDialog(Bohater Player, PrzyjaznyNPC Npc)
        {
            postac = Player;
            npc    = Npc;

            PlayerPB.Image = postac.getDialogImage();
            NPCPB.Image    = npc.getDialogImage();

            PlayerName.Text = "Godric";
            NPCName.Text    = npc.getNazwa();

            if (npc.getActiveQuestID() > 0)
            {
                for (i = 0; ; i++)
                {
                    if (npc.Questy.ElementAt(i).getIsActive())
                    {
                        break;
                    }
                }

                if (npc.Questy.ElementAt(i).getDialogOccured() == false)
                {
                    Reader = new StreamReader(@"Dialogs\Quest" + npc.getActiveQuestID() + npc.Questy.ElementAt(i).getStatus().ToString() + ".txt");
                    if (!Reader.EndOfStream)
                    {
                        line = Reader.ReadLine();

                        if (line == npc.getId().ToString())
                        {
                            line = Reader.ReadLine();
                            if (line != "PLAYER" && line != "NPC" && line != "NEWQUEST" && line != "UPDATEQUEST" && line != "UPDATEFAKE" && line != "STARTNEWDIALOG")
                            {
                                Player.ChangeQuestDescription(npc.getActiveQuestID(), line);
                            }

                            while (line != "PLAYER" && line != "NPC")
                            {
                                line = Reader.ReadLine();
                            }

                            if (line == "PLAYER")
                            {
                                textBox1.Text   = "Godric" + Environment.NewLine;
                                PlayerIsTalking = true;
                            }
                            else if (line == "NPC")
                            {
                                textBox1.Text   = npc.getNazwa() + Environment.NewLine;
                                PlayerIsTalking = false;
                            }

                            line = Reader.ReadLine();

                            while (line != "PLAYER" && line != "NPC")
                            {
                                if (!Reader.EndOfStream)
                                {
                                    if (line == "\n")
                                    {
                                        textBox1.Text += Environment.NewLine;
                                    }
                                    else if (line == "NEWQUEST")
                                    {
                                        bool found = false;

                                        foreach (Quest quest in Player.quests)
                                        {
                                            if (quest.getId() == npc.Questy.ElementAt(i).getId() && quest.getIsActive() == true && quest.getStatus() != QuestStatus.Complited)
                                            {
                                                found = true;
                                            }
                                        }

                                        if (!found)
                                        {
                                            for (i = 0; i < npc.Questy.Count; i++)
                                            {
                                                if (npc.Questy.ElementAt(i).getIsActive())
                                                {
                                                    break;
                                                }
                                            }
                                            Player.AddQuest(npc.Questy.ElementAt(i).getId());
                                            Player.ChangeQuestIsActive(npc.Questy.ElementAt(i).getId(), true);
                                            Player.ChangeQuestStatus(npc.Questy.ElementAt(i).getId(), QuestStatus.Active);
                                            questNotification                 = new QuestNotification();
                                            questNotification.Size            = new Size(DesktopBounds.Width / 5, DesktopBounds.Height * 3 / 7);
                                            questNotification.DesktopLocation = new Point(DesktopBounds.Width * 2 / 5, DesktopBounds.Height / 16);
                                            questNotification.Show();
                                            questNotification.Owner = Owner;
                                            this.Focus();
                                            this.Activate();
                                        }
                                    }
                                    else if (line == "UPDATEQUEST")
                                    {
                                        bool found = false;

                                        foreach (Quest quest in Player.quests)
                                        {
                                            if (quest.getId() == npc.Questy.ElementAt(i).getId())
                                            {
                                                found = true;
                                            }
                                        }

                                        if (found)
                                        {
                                            Player.UpdateQuestStatus(npc.Questy.ElementAt(i).getId());
                                            //npc.UpdateQuestStatus(npc.Questy.ElementAt(i).getId());
                                            questNotification                 = new QuestNotification();
                                            questNotification.Size            = new Size(DesktopBounds.Width / 5, DesktopBounds.Height * 3 / 7);
                                            questNotification.DesktopLocation = new Point(DesktopBounds.Width * 2 / 5, DesktopBounds.Height / 16);
                                            questNotification.Show();
                                            questNotification.Owner = Owner;
                                            this.Focus();
                                            this.Activate();
                                        }
                                    }
                                    else if (line == "UPDATEFAKE")
                                    {
                                        questNotification                 = new QuestNotification();
                                        questNotification.Size            = new Size(DesktopBounds.Width / 5, DesktopBounds.Height * 3 / 7);
                                        questNotification.DesktopLocation = new Point(DesktopBounds.Width * 2 / 5, DesktopBounds.Height / 16);
                                        questNotification.Show();
                                        questNotification.Owner = Owner;
                                        this.Focus();
                                        this.Activate();
                                    }
                                    else if (line == "STARTNEWDIALOG")
                                    {
                                        Dialog dialog = new Dialog();
                                        dialog.Size            = new Size(this.Width, this.Height);
                                        dialog.DesktopLocation = new Point(0, this.Location.Y);
                                        dialog.UpdateDialog(Player, npc);
                                        dialog.Show();
                                        dialog.Focus();

                                        this.Close();
                                    }
                                    else
                                    {
                                        textBox1.Text = textBox1.Text + line;
                                    }

                                    line = Reader.ReadLine();
                                }
                                else
                                {
                                    //npc.Questy.ElementAt(i).setDialogOccured(true);

                                    if (line == "NEWQUEST")
                                    {
                                        bool found = false;

                                        foreach (Quest quest in Player.quests)
                                        {
                                            if (quest.getId() == npc.Questy.ElementAt(i).getId() && quest.getIsActive() == true && quest.getStatus() != QuestStatus.Complited)
                                            {
                                                found = true;
                                            }
                                        }

                                        if (!found)
                                        {
                                            for (i = 0; i < npc.Questy.Count; i++)
                                            {
                                                if (npc.Questy.ElementAt(i).getIsActive())
                                                {
                                                    break;
                                                }
                                            }
                                            Player.AddQuest(npc.Questy.ElementAt(i).getId());
                                            Player.ChangeQuestIsActive(npc.Questy.ElementAt(i).getId(), true);
                                            Player.ChangeQuestStatus(npc.Questy.ElementAt(i).getId(), QuestStatus.Active);
                                            questNotification                 = new QuestNotification();
                                            questNotification.Size            = new Size(DesktopBounds.Width / 5, DesktopBounds.Height * 3 / 7);
                                            questNotification.DesktopLocation = new Point(DesktopBounds.Width * 2 / 5, DesktopBounds.Height / 16);
                                            questNotification.Show();
                                            questNotification.Owner = Owner;
                                            this.Focus();
                                            this.Activate();
                                        }
                                    }
                                    else if (line == "UPDATEQUEST")
                                    {
                                        bool found = false;

                                        foreach (Quest quest in Player.quests)
                                        {
                                            if (quest.getId() == npc.Questy.ElementAt(i).getId())
                                            {
                                                found = true;
                                            }
                                        }

                                        if (found)
                                        {
                                            Player.UpdateQuestStatus(npc.Questy.ElementAt(i).getId());
                                            //npc.UpdateQuestStatus(npc.Questy.ElementAt(i).getId());
                                            questNotification                 = new QuestNotification();
                                            questNotification.Size            = new Size(DesktopBounds.Width / 5, DesktopBounds.Height * 3 / 7);
                                            questNotification.DesktopLocation = new Point(DesktopBounds.Width * 2 / 5, DesktopBounds.Height / 16);
                                            questNotification.Show();
                                            questNotification.Owner = Owner;
                                            this.Focus();
                                            this.Activate();
                                        }
                                    }
                                    else if (line == "UPDATEFAKE")
                                    {
                                        questNotification                 = new QuestNotification();
                                        questNotification.Size            = new Size(DesktopBounds.Width / 5, DesktopBounds.Height * 3 / 7);
                                        questNotification.DesktopLocation = new Point(DesktopBounds.Width * 2 / 5, DesktopBounds.Height / 16);
                                        questNotification.Show();
                                        questNotification.Owner = Owner;
                                        this.Focus();
                                        this.Activate();
                                    }
                                    else if (line == "STARTNEWDIALOG")
                                    {
                                        Dialog dialog = new Dialog();
                                        dialog.Size            = new Size(this.Width, this.Height);
                                        dialog.DesktopLocation = new Point(0, this.Location.Y);
                                        dialog.UpdateDialog(Player, npc);
                                        dialog.Show();
                                    }
                                    else
                                    {
                                        textBox1.Text = textBox1.Text + line;
                                    }
                                    break;
                                }
                            }
                        }
                        else
                        {
                            textBox1.Text = npc.getEndingLine();
                        }
                    }
                }
                else
                {
                    textBox1.Text = npc.getEndingLine();
                }
            }
            else
            {
                textBox1.Text = npc.getEndingLine();
            }
        }
Ejemplo n.º 11
0
        private void ReadDialog(Bohater Player, PrzyjaznyNPC Npc)
        {
            if (textBox1.Text == npc.getEndingLine())
            {
                this.Close();
            }

            else if (!Reader.EndOfStream)
            {
                if (line == "PLAYER")
                {
                    textBox1.Text   = "Godric" + Environment.NewLine;
                    PlayerIsTalking = true;
                    line            = Reader.ReadLine();
                }
                else if (line == "NPC")
                {
                    textBox1.Text   = npc.getNazwa() + Environment.NewLine;
                    PlayerIsTalking = false;
                    line            = Reader.ReadLine();
                }

                while (line != "PLAYER" && line != "NPC")
                {
                    if (!Reader.EndOfStream)
                    {
                        if (line == "\\n")
                        {
                            textBox1.Text = textBox1.Text + Environment.NewLine;
                        }
                        else if (line == "NEWQUEST")
                        {
                            bool found = false;

                            foreach (Quest quest in Player.quests)
                            {
                                if (quest.getId() == npc.Questy.ElementAt(i).getId())
                                {
                                    found = true;
                                }
                            }

                            if (!found)
                            {
                                Player.AddQuest(npc.Questy.ElementAt(i).getId());
                                Player.ChangeQuestIsActive(npc.Questy.ElementAt(i).getId(), true);
                                Player.ChangeQuestStatus(npc.Questy.ElementAt(i).getId(), QuestStatus.Active);
                                questNotification                 = new QuestNotification();
                                questNotification.Size            = new Size(DesktopBounds.Width / 5, DesktopBounds.Height * 3 / 7);
                                questNotification.DesktopLocation = new Point(DesktopBounds.Width * 2 / 5, DesktopBounds.Height / 16);
                                questNotification.Show();
                                questNotification.Owner = Owner;
                                this.Focus();
                                this.Activate();
                            }
                        }
                        else if (line == "UPDATEQUEST")
                        {
                            bool found = false;

                            foreach (Quest quest in Player.quests)
                            {
                                if (quest.getId() == npc.Questy.ElementAt(i).getId())
                                {
                                    found = true;
                                }
                            }

                            if (found)
                            {
                                Player.UpdateQuestStatus(npc.Questy.ElementAt(i).getId());
                                //npc.UpdateQuestStatus(npc.Questy.ElementAt(i).getId());
                                questNotification                 = new QuestNotification();
                                questNotification.Size            = new Size(DesktopBounds.Width / 5, DesktopBounds.Height * 3 / 7);
                                questNotification.DesktopLocation = new Point(DesktopBounds.Width * 2 / 5, DesktopBounds.Height / 16);
                                questNotification.Show();
                                questNotification.Owner = Owner;
                                this.Focus();
                                this.Activate();
                            }
                        }
                        else if (line == "UPDATEFAKE")
                        {
                            questNotification                 = new QuestNotification();
                            questNotification.Size            = new Size(DesktopBounds.Width / 5, DesktopBounds.Height * 3 / 7);
                            questNotification.DesktopLocation = new Point(DesktopBounds.Width * 2 / 5, DesktopBounds.Height / 16);
                            questNotification.Show();
                            questNotification.Owner = Owner;
                            this.Focus();
                            this.Activate();
                        }
                        else if (line == "STARTNEWDIALOG")
                        {
                            Dialog dialog = new Dialog();
                            dialog.Size            = new Size(this.Width, this.Height);
                            dialog.DesktopLocation = new Point(0, this.Location.Y);
                            dialog.UpdateDialog(Player, npc);
                            dialog.Show();
                            dialog.Focus();

                            this.Close();
                        }
                        else
                        {
                            textBox1.Text = textBox1.Text + line;
                        }

                        line = Reader.ReadLine();
                    }
                    else
                    {
                        npc.Questy.ElementAt(i).setDialogOccured(true);

                        if (line == "NEWQUEST")
                        {
                            bool found = false;

                            foreach (Quest quest in Player.quests)
                            {
                                if (quest.getId() == npc.Questy.ElementAt(i).getId())
                                {
                                    found = true;
                                }
                            }

                            if (!found)
                            {
                                Player.AddQuest(npc.Questy.ElementAt(i).getId());
                                Player.ChangeQuestIsActive(npc.Questy.ElementAt(i).getId(), true);
                                Player.ChangeQuestStatus(npc.Questy.ElementAt(i).getId(), QuestStatus.Active);
                                questNotification                 = new QuestNotification();
                                questNotification.Size            = new Size(DesktopBounds.Width / 5, DesktopBounds.Height * 3 / 7);
                                questNotification.DesktopLocation = new Point(DesktopBounds.Width * 2 / 5, DesktopBounds.Height / 16);
                                questNotification.Show();
                                questNotification.Owner = Owner;
                                this.Focus();
                                this.Activate();
                            }
                        }
                        else if (line == "UPDATEQUEST")
                        {
                            bool found = false;

                            foreach (Quest quest in Player.quests)
                            {
                                if (quest.getId() == npc.Questy.ElementAt(i).getId())
                                {
                                    found = true;
                                }
                            }

                            if (found)
                            {
                                Player.UpdateQuestStatus(npc.Questy.ElementAt(i).getId());
                                //npc.UpdateQuestStatus(npc.Questy.ElementAt(i).getId());
                                questNotification                 = new QuestNotification();
                                questNotification.Size            = new Size(DesktopBounds.Width / 5, DesktopBounds.Height * 3 / 7);
                                questNotification.DesktopLocation = new Point(DesktopBounds.Width * 2 / 5, DesktopBounds.Height / 16);
                                questNotification.Show();
                                questNotification.Owner = Owner;
                                this.Focus();
                                this.Activate();
                            }
                        }
                        else if (line == "UPDATEFAKE")
                        {
                            questNotification                 = new QuestNotification();
                            questNotification.Size            = new Size(DesktopBounds.Width / 5, DesktopBounds.Height * 3 / 7);
                            questNotification.DesktopLocation = new Point(DesktopBounds.Width * 2 / 5, DesktopBounds.Height / 16);
                            questNotification.Show();
                            questNotification.Owner = Owner;
                            this.Focus();
                            this.Activate();
                            //npc.Questy.ElementAt(i).setDialogOccured(false);
                        }
                        else if (line == "STARTNEWDIALOG")
                        {
                            Dialog dialog = new Dialog();
                            dialog.Size            = new Size(this.Width, this.Height);
                            dialog.DesktopLocation = new Point(0, this.Location.Y);
                            dialog.UpdateDialog(Player, npc);
                            dialog.Show();
                        }
                        else
                        {
                            textBox1.Text = textBox1.Text + line;
                        }

                        break;
                    }
                }
            }
            else
            {
                foreach (Quest _quest in Player.quests)
                {
                    if (_quest.getId() == Task.questId_Danger)
                    {
                        if (_quest.getStatus() == QuestStatus.Complited)
                        {
                            Ending ending = new Ending();
                            ending.Size = new Size(DesktopBounds.Width, DesktopBounds.Height);
                            ending.sendForm(Owner);
                            ending.UpdateEnding(true);
                            ending.Show();
                            ending.Focus();
                        }
                    }
                }
                this.Close();
            }
        }