Пример #1
0
 public QuestGuideForm(Quest q) {
     this.quest = q;
     this.questInstruction = null;
     this.hunt = null;
     this.direction = null;
     this.missionName = null;
     minInstructions = 1;
     instructionIndex = 1;
     this.InitializeComponent();
 }
Пример #2
0
 public QuestGuideForm(HuntingPlace h) {
     this.hunt = h;
     this.direction = h.directions[0];
     this.quest = null;
     this.questInstruction = null;
     instructionIndex = 1;
     minInstructions = 1;
     maxInstructions = hunt.directions.Count;
     if (hunt.directions.Count > 0) {
         int ordering = hunt.directions[hunt.directions.Count - 1].ordering;
         for (int i = hunt.directions.Count - 1; i >= 0; i--) {
             if (hunt.directions[i].ordering < ordering) {
                 maxInstructions = i + 1;
                 break;
             } else if (i == 0) {
                 maxInstructions = i + 1;
             }
         }
     }
     this.InitializeComponent();
 }
Пример #3
0
        private static HuntingPlace createHunt(SQLiteDataReader reader)
        {
            SQLiteCommand command;

            if (!reader.Read()) {
                return null;
            }

            HuntingPlace huntingPlace = new HuntingPlace();
            huntingPlace.permanent = true;
            huntingPlace.id = reader.GetInt32(0);
            huntingPlace.name = reader["name"].ToString();
            huntingPlace.level = reader.IsDBNull(2) ? DATABASE_NULL : reader.GetInt32(2);
            huntingPlace.exp_quality = reader.IsDBNull(3) ? DATABASE_NULL : reader.GetInt32(3);
            huntingPlace.loot_quality = reader.IsDBNull(4) ? DATABASE_NULL : reader.GetInt32(4);
            string imageName = reader.GetString(5).ToLower();
            Creature cr = getCreature(imageName);
            if (cr != null) {
                huntingPlace.image = cr.GetImage();
            } else {
                NPC npc = getNPC(imageName);
                if (npc != null) {
                    huntingPlace.image = npc.GetImage();
                } else {
                    throw new Exception("Unrecognized npc or creature image.");
                }
            }
            huntingPlace.city = reader["city"].ToString();

            // Hunting place coordinates
            command = new SQLiteCommand(String.Format("SELECT x, y, z FROM HuntingPlaceCoordinates WHERE huntingplaceid={0}", huntingPlace.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Coordinate c = new Coordinate();
                c.x = reader.IsDBNull(0) ? DATABASE_NULL : reader.GetInt32(0);
                c.y = reader.IsDBNull(1) ? DATABASE_NULL : reader.GetInt32(1);
                c.z = reader.IsDBNull(2) ? DATABASE_NULL : reader.GetInt32(2);
                huntingPlace.coordinates.Add(c);
            }
            // Hunting place directions
            command = new SQLiteCommand(String.Format("SELECT beginx, beginy, beginz,endx, endy, endz, ordering, description, settings FROM HuntDirections WHERE huntingplaceid={0} ORDER BY ordering", huntingPlace.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Directions d = new Directions();
                d.huntingplaceid = huntingPlace.id;
                d.begin = new Coordinate(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2));
                d.end = new Coordinate(reader.GetInt32(3), reader.GetInt32(4), reader.GetInt32(5));
                d.ordering = reader.GetInt32(6);
                d.description = reader["description"].ToString();
                d.settings = reader.GetString(8);
                huntingPlace.directions.Add(d);
            }

            // Hunting place creatures
            command = new SQLiteCommand(String.Format("SELECT creatureid FROM HuntingPlaceCreatures WHERE huntingplaceid={0}", huntingPlace.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                int creatureid = reader.GetInt32(0);
                huntingPlace.creatures.Add(creatureid);
            }
            // Hunting place requirements
            command = new SQLiteCommand(String.Format("SELECT questid, requirementtext FROM HuntRequirements WHERE huntingplaceid={0}", huntingPlace.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Requirements r = new Requirements();
                r.huntingplaceid = huntingPlace.id;
                int questid = reader.IsDBNull(0) ? DATABASE_NULL : reader.GetInt32(0);
                r.quest = questIdMap[questid];
                r.notes = reader["requirementtext"].ToString();
                huntingPlace.requirements.Add(r);
            }
            return huntingPlace;
        }
Пример #4
0
        private bool prev()
        {
            currentPage--;
            if (instructionIndex > minInstructions) {
                instructionIndex--;
                if (instructionIndex == 0) {
                    instructionIndex = 1;
                }

                if (this.quest != null) {
                    this.questInstruction = this.questInstructionList[instructionIndex - 1];
                    int ordering = questInstruction.ordering;
                    while (instructionIndex - 2 >= 0 && this.questInstructionList[instructionIndex - 2].ordering == ordering) {
                        instructionIndex--;
                        this.questInstruction = this.questInstructionList[instructionIndex - 1];
                    }
                } else {
                    this.direction = this.hunt.directions[instructionIndex - 1];
                    int ordering = direction.ordering;
                    while (instructionIndex - 2 >= 0 && this.hunt.directions[instructionIndex - 2].ordering == ordering) {
                        instructionIndex--;
                        direction = this.hunt.directions[instructionIndex - 1];
                    }
                }
                return true;
            }
            return false;
        }
Пример #5
0
 private bool next()
 {
     if (maxInstructions > instructionIndex) {
         currentPage++;
         if (quest != null) {
             if (questInstruction == null) {
                 this.questInstruction = this.questInstructionList[instructionIndex++];
             } else {
                 int ordering = this.questInstruction.ordering;
                 while ((this.questInstruction = questInstructionList[instructionIndex++]).ordering == ordering) ;
             }
         } else {
             int ordering = this.direction.ordering;
             while (instructionIndex < this.hunt.directions.Count && (this.direction = this.hunt.directions[instructionIndex++]).ordering == ordering) ;
         }
         return true;
     }
     return false;
 }