Ejemplo n.º 1
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.º 2
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();
            }
        }