示例#1
0
        private void AddGameObjCoord(string zone, double x, double y, double z, int type)
        {
            BotDataSet.GameObjectsRow cur_row = GetCurrentRow();

            // Check if new coord not too close
            DataRow[] crows = new DataRow[0];

            DataRow[] zrows = DataManager.GameData.CoordinatesZone.Select("GID=" + cur_row.ID);
            foreach (BotDataSet.CoordinatesZoneRow zrow in zrows)
            {
                DataRow[] coords  = DataManager.GameData.Coordinates.Select("ZONE_ID=" + zrow.ID);
                int       old_idx = crows.Length;
                Array.Resize <DataRow>(ref crows, crows.Length + coords.Length);
                coords.CopyTo(crows, old_idx);
            }

            foreach (BotDataSet.CoordinatesRow row in crows)
            {
                if (Math.Sqrt(Math.Pow((double)(row.X - x), 2) +
                              Math.Pow((double)(row.Y - y), 2) +
                              Math.Pow((double)(row.Z - z), 2)) < 5)
                {
                    ShowErrorMessage("New coordinates located in less than 5 yards with [" +
                                     row.COORD + "]");
                    return;
                }
            }

            // Check if zone exists
            object   zx   = cbCoordZone.Items;
            DataView view = ((DataRowView)fKGameObjectsCoordinatesZone.Current).DataView;

            DataRowView[] rows = view.FindRows(zone);

            BotDataSet.CoordinatesZoneRow zone_row = null;
            if (rows.Length == 0)
            {
                zone_row = DataManager.GameData.CoordinatesZone.
                           AddCoordinatesZoneRow(GetCurrentRow(), zone);
            }
            else
            {
                zone_row = (BotDataSet.CoordinatesZoneRow)rows[0].Row;
            }

            DataManager.GameData.Coordinates.AddCoordinatesRow(zone_row, x, y, z, type);

            // Select last row
            lbCoordinates.SelectedIndex = lbCoordinates.Items.Count - 1;

            IsChanged = true;
        }
示例#2
0
        private void fKGameObjectsCoordinatesZone_CurrentChanged(object sender, EventArgs e)
        {
            if ((fKGameObjectsCoordinatesZone.Current == null) || (bsZoneList.Current == null))
            {
                return;
            }

            // Get current row
            BotDataSet.CoordinatesZoneRow row = (BotDataSet.CoordinatesZoneRow)
                                                    ((DataRowView)fKGameObjectsCoordinatesZone.Current).Row;

            // Get Zone List Data View
            DataView view = ((DataRowView)bsZoneList.Current).DataView;

            // Set Zone List to same zone as current GameObject coordinates
            cbAllZones.SelectedItem = view[view.Find(row.ZONE_NAME)];
        }