private void setupData(DataRow r) { int objectType = int.Parse(r["type"].ToString()); String oType = ""; switch (objectType) { case 0: oType = "Mobs"; break; case 3: oType = "Planets"; break; case 11: oType = "Stargates"; break; case 12: oType = "Starbases"; break; case 37: oType = "Decorations"; break; case 38: oType = "Harvestables"; break; } dp = new MobProps(); dp.SectorID = int.Parse(r["sector_id"].ToString()); dp.NavType = r["nav_type"].ToString(); dp.Signature = float.Parse(r["signature"].ToString()); dp.IsHuge = (Boolean) r["is_huge"]; dp.BaseXP = int.Parse(r["base_xp"].ToString()); dp.ExplorationRange = float.Parse(r["exploration_range"].ToString()); dp.BaseAssetID = int.Parse(r["base_asset_id"].ToString()); AdobeColors.HSL hslColor = new AdobeColors.HSL(); hslColor.H = float.Parse(r["h"].ToString()); hslColor.S = float.Parse(r["s"].ToString()); hslColor.L = float.Parse(r["v"].ToString()); Color newColor = AdobeColors.HSL_to_RGB(hslColor); dp.Color = newColor; dp.Type = oType; dp.Scale = float.Parse(r["scale"].ToString()); ; dp.PositionX = float.Parse(r["position_x"].ToString()); dp.PositionY = float.Parse(r["position_y"].ToString()); dp.PositionZ = float.Parse(r["position_z"].ToString()); ; double[] quat1 = new double[4]; quat1[0] = double.Parse(r["orientation_z"].ToString()); quat1[1] = double.Parse(r["orientation_u"].ToString()); quat1[2] = double.Parse(r["orientation_v"].ToString()); quat1[3] = double.Parse(r["orientation_w"].ToString()); QuaternionCalc qc1 = new QuaternionCalc(); double[] ang1 = qc1.QuatToAngle(quat1); if (ang1[0] == double.NaN) { ang1[0] = 0; } if (ang1[1] == double.NaN) { ang1[1] = 0; } if (ang1[2] == double.NaN) { ang1[2] = 0; } dp.Orientation_Yaw = Math.Round(ang1[0], 0); dp.Orientation_Pitch = Math.Round(ang1[1], 0); dp.Orientation_Roll = Math.Round(ang1[2], 0); dp.Name = r["name"].ToString(); dp.AppearsInRadar = (Boolean) r["appears_in_radar"]; dp.RadarRange = float.Parse(r["radar_range"].ToString()); dp.Destination = int.Parse(r["gate_to"].ToString()); dp.SoundEffect = int.Parse(r["sound_effect_id"].ToString()); dp.SoundEffectRange = float.Parse(r["sound_effect_range"].ToString()); dp.SpawnGroup = "<Collection...>"; dp.Count = int.Parse(r["mob_count"].ToString()); dp.SpawnRadius = float.Parse(r["mob_spawn_radius"].ToString()); dp.RespawnTime = float.Parse(r["respawn_time"].ToString()); dp.DelayedSpawn = (Boolean) r["delayed_spawn"]; }
public void updateChangedInfo(String propertyName, Object _changedValue) { String changedValue = _changedValue.ToString(); //Update DataRow and Graphics (only certain props require graphical updating). if (propertyName == "SectorID") { dr["sector_id"] = int.Parse(changedValue); } else if (propertyName == "NavType") { dr["nav_type"] = changedValue; } else if (propertyName == "Signature") { dr["signature"] = float.Parse(changedValue); float imageWidth = mobImage.Width; float imageHeight = mobImage.Height; float x = mobImage.X; float y = mobImage.Y; mobImage.GetChild(0).X = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100); mobImage.GetChild(0).Y = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100); mobImage.GetChild(0).Width = (float.Parse(changedValue) * 2) / 100; mobImage.GetChild(0).Height = (float.Parse(changedValue) * 2) / 100; } else if (propertyName == "IsHuge") { dr["is_huge"] = bool.Parse(changedValue); } else if (propertyName == "BaseXP") { dr["base_xp"] = int.Parse(changedValue); } else if (propertyName == "ExplorationRange") { dr["exploration_range"] = float.Parse(changedValue); float imageWidth = mobImage.Width; float imageHeight = mobImage.Height; float x = mobImage.X; float y = mobImage.Y; mobImage.GetChild(2).X = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100); mobImage.GetChild(2).Y = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100); mobImage.GetChild(2).Width = (float.Parse(changedValue) * 2) / 100; mobImage.GetChild(2).Height = (float.Parse(changedValue) * 2) / 100; } else if (propertyName == "BaseAssetID") { dr["base_asset_id"] = int.Parse(changedValue); foreach (DataGridViewRow row in _dgv.SelectedRows) { _dgv.Rows[row.Index].Cells["base_asset_id"].Value = int.Parse(changedValue); _dgv.Update(); _dgv.Refresh(); } } else if (propertyName == "Color") { Color color = (Color)_changedValue; AdobeColors.HSL hsv = AdobeColors.RGB_to_HSL(color); dr["h"] = hsv.H; dr["s"] = hsv.S; dr["v"] = hsv.L; } else if (propertyName == "Type") { _layer.RemoveChild(mobImage); /* if (changedValue == "Planets") { dr["type"] = 3; new PlanetSprite(_layer, dr, _pg); } else if (changedValue == "Stargates") { dr["type"] = 11; new StargateSprite(_layer, dr, _pg); } else if (changedValue == "Starbases") { dr["type"] = 12; new StarbaseSprite(_layer, dr, _pg); } else if (changedValue == "Decorations") { dr["type"] = 37; new DecorationSprite(_layer, dr, _pg); } else if (changedValue == "Harvestables") { dr["type"] = 38; new HarvestableSprite(_layer, dr, _pg); }*/ _pg.SelectedObject = null; } else if (propertyName == "Scale") { dr["scale"] = float.Parse(changedValue); } else if (propertyName == "PositionX") { dr["position_x"] = float.Parse(changedValue); float dx = (float.Parse(changedValue) / 100) - mobImage.X; mobImage.TranslateBy(dx, 0); } else if (propertyName == "PositionY") { dr["position_y"] = float.Parse(changedValue); float dy = (float.Parse(changedValue) / 100) - mobImage.Y; mobImage.TranslateBy(0, dy); } else if (propertyName == "PositionZ") { dr["position_z"] = float.Parse(changedValue); } else if (propertyName == "Orientation_Yaw" || propertyName == "Orientation_Pitch" || propertyName == "Orientation_Roll") { QuaternionCalc qtmp = new QuaternionCalc(); double[] q1 = qtmp.AngleToQuat(dp.Orientation_Yaw, dp.Orientation_Pitch, dp.Orientation_Roll); dr["orientation_z"] = q1[0]; dr["orientation_u"] = q1[1]; dr["orientation_v"] = q1[2]; dr["orientation_w"] = q1[3]; } else if (propertyName == "Name") { dr["name"] = changedValue; float x = mobImage.X; float y = mobImage.Y; PText name = (PText)mobImage.GetChild(3); name.Text = changedValue; name.TextAlignment = StringAlignment.Center; name.X = x - (name.Width / 2); name.Y = y - 20; foreach (DataGridViewRow row in _dgv.SelectedRows) { _dgv.Rows[row.Index].Cells["name"].Value = changedValue; _dgv.Update(); _dgv.Refresh(); } } else if (propertyName == "AppearsInRadar") { dr["appears_in_radar"] = bool.Parse(changedValue); if (bool.Parse(changedValue) == true) { changeImage(1); } else { changeImage(0); } } else if (propertyName == "RadarRange") { dr["radar_range"] = float.Parse(changedValue); float imageWidth = mobImage.Width; float imageHeight = mobImage.Height; float x = mobImage.X; float y = mobImage.Y; mobImage.GetChild(1).X = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100); mobImage.GetChild(1).Y = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100); mobImage.GetChild(1).Width = (float.Parse(changedValue) * 2) / 100; mobImage.GetChild(1).Height = (float.Parse(changedValue) * 2) / 100; } else if (propertyName == "Destination") { dr["gate_to"] = int.Parse(changedValue); } else if (propertyName == "SpawnRadius") { dr["mob_spawn_radius"] = float.Parse(changedValue); int navType = int.Parse(dr["nav_type"].ToString()); int nodeCount = (3 + navType) + 1; float imageWidth = mobImage.Width; float imageHeight = mobImage.Height; float x = mobImage.X; float y = mobImage.Y; mobImage.GetChild(nodeCount).X = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100); mobImage.GetChild(nodeCount).Y = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100); mobImage.GetChild(nodeCount).Width = (float.Parse(changedValue) * 2) / 100; mobImage.GetChild(nodeCount).Height = (float.Parse(changedValue) * 2) / 100; } else if (propertyName == "Count") { dr["mob_count"] = int.Parse(changedValue); } else if (propertyName == "SoundEffect") { dr["sound_effect_id"] = int.Parse(changedValue); } else if (propertyName == "SoundEffectRange") { dr["sound_effect_range"] = float.Parse(changedValue); } else if (propertyName == "RespawnTime") { dr["respawn_time"] = int.Parse(changedValue); } else if (propertyName == "DelayedSpawn") { dr["delayed_spawn"] = bool.Parse(changedValue); } if (dr.RowState != DataRowState.Modified) { dr.SetModified(); } }
private void setupData(DataRow r) { int objectType = int.Parse(r["type"].ToString()); String oType = ""; switch (objectType) { case 0: oType = "Mobs"; break; case 3: oType = "Planets"; break; case 11: oType = "Stargates"; break; case 12: oType = "Starbases"; break; case 37: oType = "Decorations"; break; case 38: oType = "Harvestables"; break; } dp = new HarvestableProps(); //Base Props dp.SectorID = int.Parse(r["sector_id"].ToString()); dp.NavType = r["nav_type"].ToString(); dp.Signature = float.Parse(r["signature"].ToString()); dp.IsHuge = (Boolean) r["is_huge"]; dp.BaseXP = int.Parse(r["base_xp"].ToString()); dp.ExplorationRange = float.Parse(r["exploration_range"].ToString()); dp.BaseAssetID = int.Parse(r["base_asset_id"].ToString()); AdobeColors.HSL hslColor = new AdobeColors.HSL(); hslColor.H = float.Parse(r["h"].ToString()); hslColor.S = float.Parse(r["s"].ToString()); hslColor.L = float.Parse(r["v"].ToString()); Color newColor = AdobeColors.HSL_to_RGB(hslColor); dp.Color = newColor; dp.Type = oType; dp.Scale = float.Parse(r["scale"].ToString()); ; dp.PositionX = float.Parse(r["position_x"].ToString()); dp.PositionY = float.Parse(r["position_y"].ToString()); dp.PositionZ = float.Parse(r["position_z"].ToString()); ; double[] quat1 = new double[4]; quat1[0] = double.Parse(r["orientation_z"].ToString()); quat1[1] = double.Parse(r["orientation_u"].ToString()); quat1[2] = double.Parse(r["orientation_v"].ToString()); quat1[3] = double.Parse(r["orientation_w"].ToString()); QuaternionCalc qc1 = new QuaternionCalc(); double[] ang1 = qc1.QuatToAngle(quat1); if (ang1[0] == double.NaN) { ang1[0] = 0; } if (ang1[1] == double.NaN) { ang1[1] = 0; } if (ang1[2] == double.NaN) { ang1[2] = 0; } dp.Orientation_Yaw = Math.Round(ang1[0], 0); dp.Orientation_Pitch = Math.Round(ang1[1], 0); dp.Orientation_Roll = Math.Round(ang1[2], 0); dp.Name = r["name"].ToString(); dp.AppearsInRadar = (Boolean) r["appears_in_radar"]; dp.RadarRange = float.Parse(r["radar_range"].ToString()); dp.Destination = int.Parse(r["gate_to"].ToString()); dp.SoundEffect = int.Parse(r["sound_effect_id"].ToString()); dp.SoundEffectRange = float.Parse(r["sound_effect_range"].ToString()); //Harvestable Props try { dp.Level = r["level"].ToString(); dp.ResType = "<Collection...>"; dp.ResCount = int.Parse(r["res_count"].ToString()); dp.MobSpawnRadius = float.Parse(r["spawn_radius"].ToString()); dp.PopRockChance = int.Parse(r["pop_rock_chance"].ToString()); dp.SpawnGroup = "<Collection...>"; dp.MaxFieldRadius = float.Parse(r["max_field_radius"].ToString()); String fieldName = ""; switch(int.Parse(r["field"].ToString())) { case 0: fieldName = "Random"; break; case 1: fieldName = "Ring"; break; case 2: fieldName = "Donut"; break; case 3: fieldName = "Cylinder"; break; case 4: fieldName = "Sphere"; break; case 5: fieldName = "Gas Cloud Clump"; break; } dp.Field = fieldName; } catch (Exception) { dp.Level = "1"; dp.Field = "Single"; dp.ResCount = 0; dp.MaxFieldRadius = 0; dp.MobSpawnRadius = 0; dp.PopRockChance = 0; dp.SpawnGroup = "<Collection...>"; } }
private void button2_Click(object sender, EventArgs e) { if (lastInsertID == 0) { DataTable tmp = sectorObjectsSQL.getSectorObject(); newSectorObjectsRow = tmp.NewRow(); QuaternionCalc qtmp = new QuaternionCalc(); double[] q1 = null; switch (type2) { case 0: newSectorObjectsRow["sector_id"] = mp.SectorID; newSectorObjectsRow["nav_type"] = mp.NavType; newSectorObjectsRow["signature"] = mp.Signature; newSectorObjectsRow["is_huge"] = mp.IsHuge; newSectorObjectsRow["base_xp"] = mp.BaseXP; newSectorObjectsRow["exploration_range"] = mp.ExplorationRange; newSectorObjectsRow["base_asset_id"] = mp.BaseAssetID; newSectorObjectsRow["h"] = mp.Color.GetHue(); newSectorObjectsRow["s"] = mp.Color.GetSaturation(); newSectorObjectsRow["v"] = mp.Color.GetBrightness(); newSectorObjectsRow["type"] = 0; newSectorObjectsRow["scale"] = mp.Scale; newSectorObjectsRow["position_x"] = mp.PositionX; newSectorObjectsRow["position_y"] = mp.PositionY; newSectorObjectsRow["position_z"] = mp.PositionZ; q1 = qtmp.AngleToQuat(mp.Orientation_Yaw, mp.Orientation_Pitch, mp.Orientation_Roll); newSectorObjectsRow["orientation_z"] = q1[0]; newSectorObjectsRow["orientation_u"] = q1[1]; newSectorObjectsRow["orientation_v"] = q1[2]; newSectorObjectsRow["orientation_w"] = q1[3]; newSectorObjectsRow["name"] = mp.Name.Replace("'", "''"); newSectorObjectsRow["appears_in_radar"] = mp.AppearsInRadar; newSectorObjectsRow["radar_range"] = mp.RadarRange; newSectorObjectsRow["gate_to"] = mp.Destination; newSectorObjectsRow["sound_effect_id"] = mp.SoundEffect; newSectorObjectsRow["sound_effect_range"] = mp.SoundEffectRange; newSectorObjectsRow["mob_spawn_radius"] = mp.SpawnRadius; newSectorObjectsRow["mob_count"] = mp.Count; newSectorObjectsRow["respawn_time"] = mp.RespawnTime; newSectorObjectsRow["delayed_spawn"] = mp.DelayedSpawn; break; case 3: newSectorObjectsRow["sector_id"] = pp.SectorID; newSectorObjectsRow["nav_type"] = pp.NavType; newSectorObjectsRow["signature"] = pp.Signature; newSectorObjectsRow["is_huge"] = pp.IsHuge; newSectorObjectsRow["base_xp"] = pp.BaseXP; newSectorObjectsRow["exploration_range"] = pp.ExplorationRange; newSectorObjectsRow["base_asset_id"] = pp.BaseAssetID; newSectorObjectsRow["h"] = pp.Color.GetHue(); newSectorObjectsRow["s"] = pp.Color.GetSaturation(); newSectorObjectsRow["v"] = pp.Color.GetBrightness(); newSectorObjectsRow["type"] = 3; newSectorObjectsRow["scale"] = pp.Scale; newSectorObjectsRow["position_x"] = pp.PositionX; newSectorObjectsRow["position_y"] = pp.PositionY; newSectorObjectsRow["position_z"] = pp.PositionZ; q1 = qtmp.AngleToQuat(pp.Orientation_Yaw, pp.Orientation_Pitch, pp.Orientation_Roll); newSectorObjectsRow["orientation_z"] = q1[0]; newSectorObjectsRow["orientation_u"] = q1[1]; newSectorObjectsRow["orientation_v"] = q1[2]; newSectorObjectsRow["orientation_w"] = q1[3]; newSectorObjectsRow["name"] = pp.Name.Replace("'", "''"); newSectorObjectsRow["appears_in_radar"] = pp.AppearsInRadar; newSectorObjectsRow["radar_range"] = pp.RadarRange; newSectorObjectsRow["gate_to"] = pp.Destination; newSectorObjectsRow["sound_effect_id"] = pp.SoundEffect; newSectorObjectsRow["sound_effect_range"] = pp.SoundEffectRange; newSectorObjectsRow["orbit_id"] = pp.OrbitID; newSectorObjectsRow["orbit_dist"] = pp.OrbitDist; newSectorObjectsRow["orbit_angle"] = pp.OrbitAngle; newSectorObjectsRow["orbit_rate"] = pp.OrbitRate; newSectorObjectsRow["rotate_rate"] = pp.RotateRate; newSectorObjectsRow["rotate_angle"] = pp.RotateAngle; newSectorObjectsRow["tilt_angle"] = pp.TiltAngle; newSectorObjectsRow["is_landable"] = pp.IsLandable; break; case 11: newSectorObjectsRow["sector_id"] = sgp.SectorID; newSectorObjectsRow["nav_type"] = sgp.NavType; newSectorObjectsRow["signature"] = sgp.Signature; newSectorObjectsRow["is_huge"] = sgp.IsHuge; newSectorObjectsRow["base_xp"] = sgp.BaseXP; newSectorObjectsRow["exploration_range"] = sgp.ExplorationRange; newSectorObjectsRow["base_asset_id"] = sgp.BaseAssetID; newSectorObjectsRow["h"] = sgp.Color.GetHue(); newSectorObjectsRow["s"] = sgp.Color.GetSaturation(); newSectorObjectsRow["v"] = sgp.Color.GetBrightness(); newSectorObjectsRow["type"] = 11; newSectorObjectsRow["scale"] = sgp.Scale; newSectorObjectsRow["position_x"] = sgp.PositionX; newSectorObjectsRow["position_y"] = sgp.PositionY; newSectorObjectsRow["position_z"] = sgp.PositionZ; q1 = qtmp.AngleToQuat(sgp.Orientation_Yaw, sgp.Orientation_Pitch, sgp.Orientation_Roll); newSectorObjectsRow["orientation_z"] = q1[0]; newSectorObjectsRow["orientation_u"] = q1[1]; newSectorObjectsRow["orientation_v"] = q1[2]; newSectorObjectsRow["orientation_w"] = q1[3]; newSectorObjectsRow["name"] = sgp.Name.Replace("'", "''"); newSectorObjectsRow["appears_in_radar"] = sgp.AppearsInRadar; newSectorObjectsRow["radar_range"] = sgp.RadarRange; newSectorObjectsRow["gate_to"] = sgp.Destination; newSectorObjectsRow["classSpecific"] = sgp.IsClassSpecific; newSectorObjectsRow["sound_effect_id"] = sgp.SoundEffect; newSectorObjectsRow["sound_effect_range"] = sgp.SoundEffectRange; int factionID = mainFrm.factions.findIDbyName(sgp.FactionID); newSectorObjectsRow["faction_id"] = factionID; break; case 12: newSectorObjectsRow["sector_id"] = sbp.SectorID; newSectorObjectsRow["nav_type"] = sbp.NavType; newSectorObjectsRow["signature"] = sbp.Signature; newSectorObjectsRow["is_huge"] = sbp.IsHuge; newSectorObjectsRow["base_xp"] = sbp.BaseXP; newSectorObjectsRow["exploration_range"] = sbp.ExplorationRange; newSectorObjectsRow["base_asset_id"] = sbp.BaseAssetID; newSectorObjectsRow["h"] = sbp.Color.GetHue(); newSectorObjectsRow["s"] = sbp.Color.GetSaturation(); newSectorObjectsRow["v"] = sbp.Color.GetBrightness(); newSectorObjectsRow["type"] = 12; newSectorObjectsRow["scale"] = sbp.Scale; newSectorObjectsRow["position_x"] = sbp.PositionX; newSectorObjectsRow["position_y"] = sbp.PositionY; newSectorObjectsRow["position_z"] = sbp.PositionZ; q1 = qtmp.AngleToQuat(sbp.Orientation_Yaw, sbp.Orientation_Pitch, sbp.Orientation_Roll); newSectorObjectsRow["orientation_z"] = q1[0]; newSectorObjectsRow["orientation_u"] = q1[1]; newSectorObjectsRow["orientation_v"] = q1[2]; newSectorObjectsRow["orientation_w"] = q1[3]; newSectorObjectsRow["name"] = sbp.Name.Replace("'", "''"); newSectorObjectsRow["appears_in_radar"] = sbp.AppearsInRadar; newSectorObjectsRow["radar_range"] = sbp.RadarRange; newSectorObjectsRow["gate_to"] = sbp.Destination; newSectorObjectsRow["sound_effect_id"] = sbp.SoundEffect; newSectorObjectsRow["sound_effect_range"] = sbp.SoundEffectRange; newSectorObjectsRow["capShip"] = sbp.IsCapShip; newSectorObjectsRow["dockable"] = sbp.IsDockable; break; case 37: newSectorObjectsRow["sector_id"] = bp.SectorID; newSectorObjectsRow["nav_type"] = bp.NavType; newSectorObjectsRow["signature"] = bp.Signature; newSectorObjectsRow["is_huge"] = bp.IsHuge; newSectorObjectsRow["base_xp"] = bp.BaseXP; newSectorObjectsRow["exploration_range"] = bp.ExplorationRange; newSectorObjectsRow["base_asset_id"] = bp.BaseAssetID; newSectorObjectsRow["h"] = bp.Color.GetHue(); newSectorObjectsRow["s"] = bp.Color.GetSaturation(); newSectorObjectsRow["v"] = bp.Color.GetBrightness(); newSectorObjectsRow["type"] = 37; newSectorObjectsRow["scale"] = bp.Scale; newSectorObjectsRow["position_x"] = bp.PositionX; newSectorObjectsRow["position_y"] = bp.PositionY; newSectorObjectsRow["position_z"] = bp.PositionZ; q1 = qtmp.AngleToQuat(bp.Orientation_Yaw, bp.Orientation_Pitch, bp.Orientation_Roll); newSectorObjectsRow["orientation_z"] = q1[0]; newSectorObjectsRow["orientation_u"] = q1[1]; newSectorObjectsRow["orientation_v"] = q1[2]; newSectorObjectsRow["orientation_w"] = q1[3]; newSectorObjectsRow["name"] = bp.Name.Replace("'", "''"); newSectorObjectsRow["appears_in_radar"] = bp.AppearsInRadar; newSectorObjectsRow["radar_range"] = bp.RadarRange; newSectorObjectsRow["gate_to"] = bp.Destination; newSectorObjectsRow["sound_effect_id"] = bp.SoundEffect; newSectorObjectsRow["sound_effect_range"] = bp.SoundEffectRange; break; case 38: newSectorObjectsRow["sector_id"] = hp.SectorID; newSectorObjectsRow["nav_type"] = hp.NavType; newSectorObjectsRow["signature"] = hp.Signature; newSectorObjectsRow["is_huge"] = hp.IsHuge; newSectorObjectsRow["base_xp"] = hp.BaseXP; newSectorObjectsRow["exploration_range"] = hp.ExplorationRange; newSectorObjectsRow["base_asset_id"] = hp.BaseAssetID; newSectorObjectsRow["h"] = hp.Color.GetHue(); newSectorObjectsRow["s"] = hp.Color.GetSaturation(); newSectorObjectsRow["v"] = hp.Color.GetBrightness(); newSectorObjectsRow["type"] = 38; newSectorObjectsRow["scale"] = hp.Scale; newSectorObjectsRow["position_x"] = hp.PositionX; newSectorObjectsRow["position_y"] = hp.PositionY; newSectorObjectsRow["position_z"] = hp.PositionZ; q1 = qtmp.AngleToQuat(hp.Orientation_Yaw, hp.Orientation_Pitch, hp.Orientation_Roll); newSectorObjectsRow["orientation_z"] = q1[0]; newSectorObjectsRow["orientation_u"] = q1[1]; newSectorObjectsRow["orientation_v"] = q1[2]; newSectorObjectsRow["orientation_w"] = q1[3]; newSectorObjectsRow["name"] = hp.Name.Replace("'", "''"); newSectorObjectsRow["appears_in_radar"] = hp.AppearsInRadar; newSectorObjectsRow["radar_range"] = hp.RadarRange; newSectorObjectsRow["gate_to"] = hp.Destination; newSectorObjectsRow["sound_effect_id"] = hp.SoundEffect; newSectorObjectsRow["sound_effect_range"] = hp.SoundEffectRange; newSectorObjectsRow["level"] = hp.Level; newSectorObjectsRow["res_count"] = hp.ResCount; newSectorObjectsRow["spawn_radius"] = hp.MobSpawnRadius; newSectorObjectsRow["pop_rock_chance"] = hp.PopRockChance; newSectorObjectsRow["max_field_radius"] = hp.MaxFieldRadius; if (hp.Field == "Random") { newSectorObjectsRow["field"] = 0; } else if (hp.Field == "Ring") { newSectorObjectsRow["field"] = 1; } else if (hp.Field == "Donut") { newSectorObjectsRow["field"] = 2; } else if (hp.Field == "Cylinder") { newSectorObjectsRow["field"] = 3; } else if (hp.Field == "Sphere") { newSectorObjectsRow["field"] = 4; } else if (hp.Field == "Gas Cloud Clump") { newSectorObjectsRow["field"] = 5; } break; } //Check if their is a sound_effect and set its default range if it has not been set. int id = int.Parse(newSectorObjectsRow["sound_effect_id"].ToString()); Console.Out.WriteLine(id); float range = int.Parse(newSectorObjectsRow["sound_effect_range"].ToString()); if (id != -1) { if (range == 0) { newSectorObjectsRow["sound_effect_range"] = 30000; } } //Add To dataTable tmp.Rows.Add(newSectorObjectsRow); ; //Add to Database sectorObjectsSQL.newRow(newSectorObjectsRow); switch(type2) { case 0: Boolean b1 = validateMobs(0); if (b1 == true) { //Add to Graphic window mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow); this.Close(); } break; case 3: mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow); this.Close(); break; case 11: mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow); this.Close(); break; case 12: mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow); this.Close(); break; case 37: mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow); this.Close(); break; case 38: Boolean b2 = validateHarvestables(0); if (b2 == true) { //Add to Graphic window mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow); this.Close(); } break; } } else { if (type2 == 0) { Boolean b1 = validateMobs(lastInsertID); if (b1 == true) { //Add to Graphic window mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow); this.Close(); } } else if (type2 == 38) { Boolean b2 = validateHarvestables(lastInsertID); if (b2 == true) { //Add to Graphic window mainFrm.sectorWindow.addNewObject(type2, newSectorObjectsRow); this.Close(); } } } }
private void setupData(DataRow r) { int objectType = int.Parse(r["type"].ToString()); String oType = ""; switch (objectType) { case 0: oType = "Mobs"; break; case 3: oType = "Planets"; break; case 11: oType = "Stargates"; break; case 12: oType = "Starbases"; break; case 37: oType = "Decorations"; break; case 38: oType = "Harvestables"; break; } dp = new StargateProps(); //Base Props + Nav Point Props dp.SectorID = int.Parse(r["sector_id"].ToString()); dp.NavType = r["nav_type"].ToString(); dp.Signature = float.Parse(r["signature"].ToString()); dp.IsHuge = (Boolean) r["is_huge"]; dp.BaseXP = int.Parse(r["base_xp"].ToString()); dp.ExplorationRange = float.Parse(r["exploration_range"].ToString()); dp.BaseAssetID = int.Parse(r["base_asset_id"].ToString()); AdobeColors.HSL hslColor = new AdobeColors.HSL(); hslColor.H = float.Parse(r["h"].ToString()); hslColor.S = float.Parse(r["s"].ToString()); hslColor.L = float.Parse(r["v"].ToString()); Color newColor = AdobeColors.HSL_to_RGB(hslColor); dp.Color = newColor; dp.Type = oType; dp.Scale = float.Parse(r["scale"].ToString()); ; dp.PositionX = float.Parse(r["position_x"].ToString()); dp.PositionY = float.Parse(r["position_y"].ToString()); dp.PositionZ = float.Parse(r["position_z"].ToString()); ; double[] quat1 = new double[4]; quat1[0] = double.Parse(r["orientation_z"].ToString()); quat1[1] = double.Parse(r["orientation_u"].ToString()); quat1[2] = double.Parse(r["orientation_v"].ToString()); quat1[3] = double.Parse(r["orientation_w"].ToString()); QuaternionCalc qc1 = new QuaternionCalc(); double[] ang1 = qc1.QuatToAngle(quat1); if (ang1[0] == double.NaN) { ang1[0] = 0; } if (ang1[1] == double.NaN) { ang1[1] = 0; } if (ang1[2] == double.NaN) { ang1[2] = 0; } dp.Orientation_Yaw = Math.Round(ang1[0], 0); dp.Orientation_Pitch = Math.Round(ang1[1], 0); dp.Orientation_Roll = Math.Round(ang1[2], 0); dp.Name = r["name"].ToString(); dp.AppearsInRadar = (Boolean) r["appears_in_radar"]; dp.RadarRange = float.Parse(r["radar_range"].ToString()); dp.Destination = int.Parse(r["gate_to"].ToString()); dp.SoundEffect = int.Parse(r["sound_effect_id"].ToString()); dp.SoundEffectRange = float.Parse(r["sound_effect_range"].ToString()); //Stargate Specific Props dp.IsClassSpecific = (Boolean)r["classSpecific"]; //TODO: Get Faction Name from ID; String factionName = mainFrm.factions.findNameByID(int.Parse(r["faction_id"].ToString())); dp.FactionID = factionName; }