public Object2(string s) { PropIntPrivate = 1; //PropInt = 1; PropString = s; PropObject3 = new Object3(); }
/// <summary> /// Add an entity to the active scene. /// </summary> /// <param name="entity">Entity to add.</param> /// <param name="layer">Layer to assign to the object.</param> /// <returns>The ID assigned to the object.</returns> public int Add(Object3 entity, int layer) { lock (this) { return(scene.Add(entity, layer)); } }
/// <summary> /// Populate the listboxes with turret and tank models /// </summary> private void PopulateBoxes() { List <object> turrets = new List <object>(); //Populate turrets weapons = WeaponLoader.GetWeaponsAsList(); foreach (Weapon weapon in weapons) { turrets.Add(weapon.Name); } form.Turrets = turrets; form.Tanks = Utils.GetTankModels(); Renderer.SceneTools.Scene scene = ServiceManager.Scene; selectedTankRenderID = scene.Add( ServiceManager.Resources.GetModel("tanks\\" + tank.model), Vector3.Zero, 0); selectedTank = scene.Access3D(selectedTankRenderID); selectedTurretRenderID = scene.Add( ServiceManager.Resources.GetModel("weapons\\" + WeaponLoader.GetWeapon(tank.weaponID).Model), Vector3.Zero, 0); selectedTurret = scene.Access3D(selectedTurretRenderID); selectedTurret.Attach(selectedTank, Constants.TURRET_MOUNT); }
public double MoonPhase(double JD) { Object3 CelObject = new Object3(); OnSurface onSurface = new OnSurface(); CatEntry3 catEntry3 = new CatEntry3(); SkyPos Output1 = new SkyPos(); SkyPos Output2 = new SkyPos(); Observer Location = new Observer(); double DeltaT = DeltatCode.DeltaTCalc(JD); CelObject.Name = "Moon"; CelObject.Number = Body.Moon; CelObject.Star = catEntry3; CelObject.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; Location.OnSurf = onSurface; Location.Where = ObserverLocation.EarthGeoCenter; int num1 = (int)Nov31.Place(JD + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output2); CelObject.Name = "Sun"; CelObject.Number = Body.Sun; CelObject.Star = catEntry3; CelObject.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; int num2 = (int)Nov31.Place(JD + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output1); return(Range((Output2.RA - Output1.RA) * 15.0, -180.0, false, 180.0, true)); }
public void EnumTest1() { ObjectMapper om = Map.GetObjectMapper(typeof(Object3)); Object3 o = (Object3)om.CreateInstance(); om.SetValue(o, "Enum1", "1"); om.SetValue(o, "Enum2", "2"); om.SetValue(o, "Enum3", "30"); om.SetValue(o, "Enum4", null); Assert.AreEqual(Enum1.Value1, o.Enum1); Assert.AreEqual(Enum1.Value2, o.Enum2); Assert.AreEqual(Enum1.Value3, o.Enum3); Assert.AreEqual(Enum1.Value4, o.Enum4); om.SetValue(o, "Enum3", "31"); Assert.AreEqual(Enum1.Value3, o.Enum3); om.SetValue(o, "Enum3", "32"); Assert.AreEqual(Enum1.Value3, o.Enum3); Assert.AreEqual("1", om.GetValue(o, "Enum1")); Assert.AreEqual("2", om.GetValue(o, "Enum2")); Assert.Contains(om.GetValue(o, "Enum3"), new[] { "30", "31", "32", "3" }); Assert.IsNull(om.GetValue(o, "Enum4")); }
public double MoonIllumination(double JD) { Object3 CelObject = new Object3(); OnSurface onSurface = new OnSurface(); CatEntry3 catEntry3 = new CatEntry3(); SkyPos Output1 = new SkyPos(); SkyPos Output2 = new SkyPos(); Observer Location = new Observer(); double DeltaT = DeltatCode.DeltaTCalc(JD); CelObject.Name = "Moon"; CelObject.Number = Body.Moon; CelObject.Star = catEntry3; CelObject.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; Location.OnSurf = onSurface; Location.Where = ObserverLocation.EarthGeoCenter; int num1 = (int)Nov31.Place(JD + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output2); CelObject.Name = "Sun"; CelObject.Number = Body.Sun; CelObject.Star = catEntry3; CelObject.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; int num2 = (int)Nov31.Place(JD + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output1); double num3 = Math.Acos(Math.Sin(Output1.Dec * (Math.PI / 180.0)) * Math.Sin(Output2.Dec * (Math.PI / 180.0)) + Math.Cos(Output1.Dec * (Math.PI / 180.0)) * Math.Cos(Output2.Dec * (Math.PI / 180.0)) * Math.Cos((Output1.RA - Output2.RA) * 15.0 * (Math.PI / 180.0))); return((1.0 + Math.Cos(Math.Atan2(Output1.Dis * Math.Sin(num3), Output2.Dis - Output1.Dis * Math.Cos(num3)))) / 2.0); }
/// <summary> /// Event handler for when the user selects a different turret /// </summary> void TurretSelectionChanged(object sender, TomShane.Neoforce.Controls.EventArgs e) { Weapon selectedWeapon = weapons[form.TurretIndex]; form.TurretPower = Utils.ConvertPowerToProgressBar( selectedWeapon.Projectile.AverageDamage); form.TurretRange = Utils.ConvertRangeToProgressBar(selectedWeapon.Projectile.Range); form.TurretRate = Utils.ConvertRateToProgressBar( selectedWeapon.Cooldown); Scene scene = ServiceManager.Game.Renderer.ActiveScene; scene.Delete(selectedTurretRenderID); selectedTurretRenderID = ServiceManager.Game.Renderer.ActiveScene.Add( ServiceManager.Resources.GetModel("weapons\\" + selectedWeapon.Model), Vector3.Zero, 0); float oldRotation = selectedTurret.ZRotation; selectedTurret = scene.Access3D(selectedTurretRenderID); selectedTurret.Attach(selectedTank, "Mount"); selectedTurret.ZRotation = oldRotation; ApplySkin(); }
/// <summary> /// Populate the listboxes with turret and tank models /// </summary> private void PopulateBoxes() { //Populate turrets weapons = WeaponLoader.GetWeaponsAsList(); List <object> weaponNames = new List <object>(); foreach (Weapon weapon in weapons) { weaponNames.Add(weapon.Name); } form.Turrets = weaponNames; form.Tanks = Utils.GetTankModels(); Scene scene = ServiceManager.Game.Renderer.ActiveScene; selectedTankRenderID = scene.Add( ServiceManager.Resources.GetModel("tanks\\" + form.Tanks[0]), Vector3.Zero, 0); selectedTank = scene.Access3D(selectedTankRenderID); selectedTurretRenderID = scene.Add( ServiceManager.Resources.GetModel("weapons\\" + weapons[0].Model), Vector3.Zero, 0); selectedTurret = scene.Access3D(selectedTurretRenderID); selectedTurret.Attach(selectedTank, "Mount"); }
public void TestNumberString() { ObjectMapper om = Map.GetObjectMapper(typeof(Object3)); Object3 o = new Object3(); om.SetValue(o, "Num", 123); Assert.AreEqual(123, o.Num.Num); }
public PositionVector GetApparentPosition(double tjd) { double[] peb = new double[4]; double[] veb = new double[4]; double[] pes = new double[4]; double[] ves = new double[4]; double[] pos = new double[4]; double[] vel = new double[4]; double[] pos2_1 = new double[4]; double[] pos2_2 = new double[4]; double[] pos2_3 = new double[4]; double[] pos2_4 = new double[4]; double[] pos2_5 = new double[9]; Object3 SsBody = new Object3(); PositionVector positionVector; if (this.m_type == BodyType.Moon & (this.m_number == 10 | this.m_number == 11)) { SsBody.Number = CommonCode.NumberToBody(this.m_number); SsBody.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; double Ra = 0; double Dec = 0; double Dis = 0; int num = (int)this.Nov31.AppPlanet(tjd, SsBody, Accuracy.Full, ref Ra, ref Dec, ref Dis); this.Nov31.RaDec2Vector(Ra, Dec, Dis, ref pos); positionVector = new PositionVector(pos[0], pos[1], pos[2], Ra, Dec, Dis, Dis / 173.14463348); } else { double tdb = 0; EphemerisCode.get_earth_nov(ref this.m_earthephobj, tjd, ref tdb, ref peb, ref veb, ref pes, ref ves); EphemerisCode.ephemeris_nov(ref this.m_ephobj, tdb, this.m_type, this.m_number, this.m_name, Origin.Barycentric, ref pos, ref vel); double lighttime = 0; NOVAS2.BaryToGeo(pos, peb, ref pos2_1, ref lighttime); double num1 = tdb - lighttime; int num2 = 0; double tjd1; do { tjd1 = num1; EphemerisCode.ephemeris_nov(ref this.m_ephobj, tjd1, this.m_type, this.m_number, this.m_name, Origin.Barycentric, ref pos, ref vel); NOVAS2.BaryToGeo(pos, peb, ref pos2_1, ref lighttime); num1 = tdb - lighttime; checked { ++num2; } }while (Math.Abs(num1 - tjd1) > 1E-06 & num2 < 100); int num3 = (int)NOVAS2.SunField(pos2_1, pes, ref pos2_2); int num4 = (int)NOVAS2.Aberration(pos2_2, veb, lighttime, ref pos2_3); NOVAS2.Precession(2451545.0, pos2_3, tdb, ref pos2_4); int num5 = (int)NOVAS2.Nutate(tdb, NutationDirection.MeanToTrue, pos2_4, ref pos2_5); positionVector = new PositionVector(); positionVector.x = pos2_5[0]; positionVector.y = pos2_5[1]; positionVector.z = pos2_5[2]; } return(positionVector); }
/// <summary> /// Converts a model to a RendererEntity and starts tracking it /// </summary> /// <param name="_entity">The Model to insert</param> /// <param name="_position">The position to insert the Model</param> /// <param name="_layer">The layer to associate the entity with. Lower layer numbers are drawn first.</param> /// <returns>The unique entity id used to keep track of each entity</returns> public int Add(Model _entity, Vector3 _position, int _layer) { RendererAssetPool.UniversalEffect.RemapModel(_entity); int x = entityID.GetID(); Object3 obj = new Object3(_entity, _position); entityList.Add(x, obj); AddLayers(_layer); layers[_layer].Add(x, obj); return(x); }
/// <summary> /// Starts tracking a new Renderer3DObject /// </summary> /// <param name="_entity">The Renderer3DObject to add</param> /// <param name="_position">The position to assign the object</param> /// <param name="_layer">The layer to associate the entity with. Lower layer numbers are drawn first.</param> /// <returns>The unique entity id used to keep track of each entity</returns> public int Add(Object3 _entity, int _layer) { RendererAssetPool.UniversalEffect.RemapModel(_entity.Model); int x = entityID.GetID(); entityList.Add(x, _entity); AddLayers(_layer); layers[_layer].Add(x, _entity); return(x); }
public void TestEnum3() { ObjectMapper om = Map.GetObjectMapper(typeof(Object3)); Object3 o = (Object3)om.CreateInstance(); om.SetValue(o, "Enum1", "55"); Assert.AreEqual(Enum2.Value2, o.Enum1); Assert.AreEqual("2", om.GetValue(o, "Enum1")); }
public PositionVector GetAstrometricPosition(double tjd) { double[] pos = new double[4]; double[] vel = new double[4]; double[] pos2 = new double[4]; double[] peb = new double[4]; double[] veb = new double[4]; double[] pes = new double[4]; double[] ves = new double[4]; Object3 SsBody = new Object3(); PositionVector positionVector; if (this.m_type == BodyType.Moon & (this.m_number == 10 | this.m_number == 11)) { SsBody.Number = CommonCode.NumberToBody(this.m_number); SsBody.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; double Ra = 0; double Dec = 0; double Dis = 0; int num = (int)this.Nov31.AstroPlanet(tjd, SsBody, Accuracy.Full, ref Ra, ref Dec, ref Dis); this.Nov31.RaDec2Vector(Ra, Dec, Dis, ref pos); positionVector = new PositionVector(pos[0], pos[1], pos[2], Ra, Dec, Dis, Dis / 173.14463348); } else { double tdb = 0; EphemerisCode.get_earth_nov(ref this.m_earthephobj, tjd, ref tdb, ref peb, ref veb, ref pes, ref ves); EphemerisCode.ephemeris_nov(ref this.m_ephobj, tdb, this.m_type, this.m_number, this.m_name, Origin.Barycentric, ref pos, ref vel); double lighttime = 0; NOVAS2.BaryToGeo(pos, peb, ref pos2, ref lighttime); double num1 = tdb - lighttime; int num2 = 0; double tjd1; do { tjd1 = num1; EphemerisCode.ephemeris_nov(ref this.m_ephobj, tjd1, this.m_type, this.m_number, this.m_name, Origin.Barycentric, ref pos, ref vel); NOVAS2.BaryToGeo(pos, peb, ref pos2, ref lighttime); num1 = tdb - lighttime; checked { ++num2; } }while (Math.Abs(num1 - tjd1) > 1E-06 & num2 < 100); if (num2 >= 100) { throw new HelperException("Planet:GetAstrometricPoition ephemeris_nov did not converge in 100 iterations"); } positionVector = new PositionVector(); positionVector.x = pos2[0]; positionVector.y = pos2[1]; positionVector.z = pos2[2]; } return(positionVector); }
public void OMM_SubConfig_Object_ConditionalDefault_SubConfigure_NoNewType() { Object3 obj = new Object3() { Value = 3254 }; string value1 = ObjectMessageMap.GetMessage(obj); string value2 = ObjectMessageMap.GetMessage(typeof(Object3)); Assert.AreEqual(TestResources.JUST_RIGHT, value1); Assert.AreEqual(TestResources.JUST_RIGHT, value2); }
public void TriggerPanelOpen() { if (gm.currentLevel == 13) { if (gm.TutorialCanvas != null) { gm.TutorialCanvas.SetActive(true); } } Object1.SetActive(true); Object2.SetActive(true); Object3.SetActive(true); }
public void FlagPickedUp(GameSession.Alliance alliance, Object3 tank) { if (!flags.ContainsKey(alliance)) { this.AddFlag(alliance, tank.Position); } flags[alliance].ParticleEmitter0.Emitting = true; flags[alliance].ParticleEmitter1.Emitting = true; flags[alliance].MimicPosition(tank, new Vector3(0, 0, 70)); flags[alliance].Hidden = false; //TODO add continuous particle emitter to flag //TODO stop emitter from base }
public void SqlTypeMemberTest() { ObjectMapper om = Map.GetObjectMapper(typeof(Object3)); Object3 o = new Object3(); om.SetValue(o, "Int32", 123.56); om.SetValue(o, "Single", 123.57.ToString(CultureInfo.InvariantCulture)); Assert.AreEqual(123, o.Int32.Value); Assert.AreEqual(123.57f, o.Single.Value); Assert.AreEqual(123, om.GetValue(o, "Int32")); Assert.AreEqual(123.57f, om.GetValue(o, "Single")); }
public void CollectionTest([Values] bool useAction) { var src = new Object3(); src.HashSet.Add(Guid.NewGuid().ToString()); src.HashSet.Add(Guid.NewGuid().ToString()); var mapper = new MapHelper <Object3, Object3>().Map(useAction, src, m => m); Assert.That(mapper.To, Is.Not.Null); foreach (var str in src.HashSet) { Assert.That(mapper.To.HashSet.Contains(str)); } }
public void ICollectionMapTest() { var mapper = Map.GetObjectMapper <Object3, Object3>(); var src = new Object3(); src.HashSet.Add(Guid.NewGuid().ToString()); src.HashSet.Add(Guid.NewGuid().ToString()); var dest = mapper(src); Assert.IsNotNull(dest); foreach (var str in src.HashSet) { Assert.That(dest.HashSet.Contains(str)); } }
void TankSelectionChanged(object sender, TomShane.Neoforce.Controls.EventArgs e) { Renderer.SceneTools.Scene scene = ServiceManager.Scene; scene.Delete(selectedTankRenderID); selectedTankRenderID = scene.Add( ServiceManager.Resources.GetModel("tanks\\" + form.Tanks[form.TankIndex]), Vector3.Zero, 0); float oldRotation = selectedTank.ZRotation; selectedTank = scene.Access3D(selectedTankRenderID); selectedTurret.Attach(selectedTank, Constants.TURRET_MOUNT); selectedTank.ZRotation = oldRotation; selectedTankModelName = (string)form.Tanks[form.TankIndex]; ApplySkin(); }
/// <summary> /// Event handler for when the user selects a different tank /// </summary> void TankSelectionChanged(object sender, TomShane.Neoforce.Controls.EventArgs e) { Scene scene = ServiceManager.Game.Renderer.ActiveScene; scene.Delete(selectedTankRenderID); selectedTankRenderID = scene.Add( ServiceManager.Resources.GetModel("tanks\\" + form.Tanks[form.TankIndex]), Vector3.Zero, 0); float oldRotation = selectedTank.ZRotation; selectedTank = scene.Access3D(selectedTankRenderID); selectedTurret.Attach(selectedTank, "Mount"); selectedTank.ZRotation = oldRotation; ApplySkin(); }
/// <summary> /// Set the object which acts as this tank's turret. /// </summary> /// <param name="turretObject">Turret object to add.</param> public void SetTurret(int id, Object3 turretObject) { TurretRenderID = id; if (Team == GameSession.Alliance.BLUE) { turretObject.MeshColor = Color.Blue; } else if (Team == GameSession.Alliance.RED) { turretObject.MeshColor = Color.Red; } else { turretObject.MeshColor = Toolkit.GetColor(attributes.color); } Turret = turretObject; }
/// <summary> /// Add a player to the player list, overwriting any existing member /// whose key is also "key". /// </summary> /// <param name="key">Key of the tank. This is the tank's name. Should be unique.</param> /// <param name="value">The tank object stored.</param> public void Add(int key, PlayerTank value) { if (players.ContainsKey(key)) { Remove(key); } if (value.RenderID != -1) { throw new Exception("Integrity error: Player already in renderer."); } int id = ServiceManager.Scene.Add(value, 2); value.RenderID = id; Microsoft.Xna.Framework.Graphics.Model turretModel = ServiceManager.Resources.GetModel( "weapons\\" + value.Weapon.Model); Object3 turret = new Object3(turretModel, Vector3.Zero); // The turret's position shouldn't matter since it's being // attached to the tank. int turretId = ServiceManager.Scene.Add(turret, 0); if (value.HealthBar != null) { int healthBarId = ServiceManager.Scene.Add(value.HealthBar, 4); value.HealthBarRenderID = healthBarId; } if (value.NameObject != null) { int nameBarId = ServiceManager.Scene.Add(value.NameObject, 4); value.NameObjectRenderID = nameBarId; } turret.Attach(value, Constants.TURRET_MOUNT); value.SetTurret(turretId, turret); players.Add(key, value); }
public void TestString3() { ObjectMapper om = Map.GetObjectMapper(typeof(Object3)); Object3 o = (Object3)om.CreateInstance(); om.SetValue(o, "Str1", null); om.SetValue(o, "Str2", null); om.SetValue(o, "Str3", null); om.SetValue(o, "Str4", null); Assert.AreEqual("", o.Str1); Assert.AreEqual("", o.Str2); Assert.AreEqual("(null)", o.Str3); Assert.IsNull(o.Str4); Assert.IsNotNull(om.GetValue(o, "Str1")); Assert.IsNull(om.GetValue(o, "Str2")); Assert.IsNull(om.GetValue(o, "Str3")); Assert.IsNull(om.GetValue(o, "Str4")); }
/// <summary> /// Add an entity to the active scene. The new entity is automatically added to /// the second layer because it is a 3D object. /// </summary> /// <param name="entity">Entity to add.</param> /// <returns>The ID assigned to the object.</returns> public int Add(Object3 entity) { return(this.Add(entity, 2)); }
/// <summary> /// Calculates parameters for tiles with height and creates DrawableTiles from them /// </summary> private void FillTiles() { Random random = new Random(); Dictionary <uint, int> borderTileCounter = new Dictionary <uint, int>(); for (uint y = 0; y < map.Height; y++) { if (borderTileCounter.ContainsKey(map.GetTile(0, y).ID) && map.GetTile(0, y).Height == 0) { borderTileCounter[map.GetTile(0, y).ID]++; } else if (map.GetTile(0, y).Height == 0) { borderTileCounter.Add(map.GetTile(0, y).ID, 1); } if (borderTileCounter.ContainsKey(map.GetTile(map.Width - 1, y).ID) && map.GetTile(map.Width - 1, y).Height == 0) { borderTileCounter[map.GetTile(map.Width - 1, y).ID]++; } else if (map.GetTile(map.Width - 1, y).Height == 0) { borderTileCounter.Add(map.GetTile(map.Width - 1, y).ID, 1); } } for (uint x = 0; x < map.Width - 1; x++) { if (borderTileCounter.ContainsKey(map.GetTile(x, 0).ID) && map.GetTile(x, 0).Height == 0) { borderTileCounter[map.GetTile(x, 0).ID]++; } else if (map.GetTile(x, 0).Height == 0) { borderTileCounter.Add(map.GetTile(x, 0).ID, 1); } if (borderTileCounter.ContainsKey(map.GetTile(x, map.Height - 1).ID) && map.GetTile(x, map.Height - 1).Height == 0) { borderTileCounter[map.GetTile(x, map.Height - 1).ID]++; } else if (map.GetTile(x, map.Height - 1).Height == 0) { borderTileCounter.Add(map.GetTile(x, map.Height - 1).ID, 1); } } int maxValue = 0; uint maxValueTile = 0; foreach (KeyValuePair <uint, int> element in borderTileCounter) { if (element.Value > maxValue) { maxValue = element.Value; maxValueTile = element.Key; } } //Load floor float minX = -10000f; float maxX = 100000f; float minY = -100000f; float maxY = 10000f; float Xspread = (maxX - minX) / Constants.TILE_SIZE; float Yspread = (maxY - minY) / Constants.TILE_SIZE; List <VertexPositionNormalTexture> verts = new List <VertexPositionNormalTexture>(); verts.Add(new VertexPositionNormalTexture(new Vector3(minX, minY, -0.75f), Vector3.UnitZ, Vector2.UnitY * Yspread)); verts.Add(new VertexPositionNormalTexture(new Vector3(minX, maxY, -0.75f), Vector3.UnitZ, Vector2.Zero)); verts.Add(new VertexPositionNormalTexture(new Vector3(maxX, minY, -0.75f), Vector3.UnitZ, new Vector2(Xspread, Yspread))); verts.Add(new VertexPositionNormalTexture(new Vector3(maxX, maxY, -0.75f), Vector3.UnitZ, Vector2.UnitX * Xspread)); verts.Add(new VertexPositionNormalTexture(new Vector3(maxX, minY, -0.75f), Vector3.UnitZ, new Vector2(Xspread, Yspread))); verts.Add(new VertexPositionNormalTexture(new Vector3(minX, maxY, -0.75f), Vector3.UnitZ, Vector2.Zero)); VertexGroup floor = new VertexGroup(TileList.GetTile((int)maxValueTile), verts); floor.Technique = RendererAssetPool.UniversalEffect.Techniques.TexturedWrap; floor.CastsShadow = false; floor.TransparencyEnabled = false; floor.Ready(); renderer.ActiveScene.Add(floor, 0); //Loads the tiles into the background array for (uint y = 0; y < map.Height; y++) { for (uint x = 0; x < map.Width; x++) { Tile tempTile = map.GetTile(x, y); // Figure out the height of each tile in each direction relative to this one. int positionNorth = (int)(y - 1); int positionSouth = (int)(y + 1); int positionWest = (int)(x - 1); int positionEast = (int)(x + 1); if (positionNorth >= 0) { tempTile.heightN = map.GetTile(x, y - 1).Height; } if (positionSouth < map.Height) { tempTile.heightS = map.GetTile(x, y + 1).Height; } if (positionWest >= 0) { tempTile.heightW = map.GetTile(x - 1, y).Height; } if (positionEast < map.Width) { tempTile.heightE = map.GetTile(x + 1, y).Height; } map.SetTile(x, y, tempTile); Texture2D texture = TileList.GetTile((int)tempTile.ID); DrawableTile tile = new DrawableTile( texture, tempTile, (int)x, (int)y, tempTile.heightN, tempTile.heightW, tempTile.heightE, tempTile.heightS); Vector3 pos = new Vector3( x * Constants.TILE_SIZE + (Constants.TILE_SIZE / 2), -(y * Constants.TILE_SIZE + (Constants.TILE_SIZE / 2)), 0); if (tempTile.ObjectID != 0) { Model objectModel = TileList.GetObject(tempTile.ObjectID); Object3 newTileObj = new Object3(objectModel, pos + (Vector3.UnitZ * tempTile.Height * Constants.TILE_SIZE)); newTileObj.TransparencyEnabled = true; Scene.Add(newTileObj, 1); } switch (tempTile.EventID) { case 4: case 5: GameSession.Alliance team = tempTile.EventID == 4 ? GameSession.Alliance.RED : GameSession.Alliance.BLUE; if (currentGameMode == VTankObject.GameMode.CAPTURETHEFLAG) { Flags.AddFlag(team, pos); } break; case 8: case 9: case 10: if (currentGameMode == VTankObject.GameMode.CAPTURETHEBASE) { Bases.AddBase(GameSession.Alliance.BLUE, tempTile.EventID, pos); } break; case 11: case 12: case 13: if (currentGameMode == VTankObject.GameMode.CAPTURETHEBASE) { Bases.AddBase(GameSession.Alliance.RED, tempTile.EventID, pos); } break; default: break; } visibleTiles[y * map.Width + x] = tile; } } #region Make Flat Tiles for (uint y = 0; y < map.Height; y++) { for (uint x = 0; x < map.Width; x++) { Tile tempTile = map.GetTile(x, y); Vector3 pos = new Vector3(x * Constants.TILE_SIZE, (-(y + 1) * Constants.TILE_SIZE), 0); Tiles.AddFloor(pos, tempTile.Height, (int)tempTile.ID); } } #endregion #region Make North Walls int height = 0; int tileID = 0; int width = 0; int Hdir = 0; //Make north facing walls for (uint y = 0; y < map.Height; y++) { for (uint x = 0; x < map.Width; x++) { Tile tempTile = map.GetTile(x, y); if ((width == 0 || (tempTile.Height == height && tempTile.ID == tileID && Hdir == tempTile.heightN)) && (x + 1) < map.Width) { height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightN; width++; } else { if (height > Hdir) { Vector3 pos = new Vector3(x * Constants.TILE_SIZE, (-y * Constants.TILE_SIZE), 0); Tiles.AddWall(pos, Vector3.UnitY, width, height, tileID); } width = 1; height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightN; } } width = 0; } #endregion #region Make South Walls height = 0; tileID = 0; width = 0; Hdir = 0; uint startX = 0; //Make south facing walls for (uint y = 0; y < map.Height; y++) { for (uint x = 0; x < map.Width; x++) { Tile tempTile = map.GetTile(x, y); if ((width == 0 || (tempTile.Height == height && tempTile.ID == tileID && Hdir == tempTile.heightS)) && (x + 1) < map.Width) { if (width == 0) { startX = x; } height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightS; width++; } else { if (height > Hdir) { Vector3 pos = new Vector3(startX * Constants.TILE_SIZE, (-(y + 1) * Constants.TILE_SIZE), 0); Tiles.AddWall(pos, -Vector3.UnitY, width, height, tileID); } width = 1; height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightS; startX = x; } } width = 0; } #endregion #region Make East Walls height = 0; tileID = 0; width = 0; Hdir = 0; //Make east facing walls for (uint x = 0; x < map.Width; x++) { for (uint y = 0; y < map.Height; y++) { Tile tempTile = map.GetTile(x, y); if ((width == 0 || (tempTile.Height == height && tempTile.ID == tileID && Hdir == tempTile.heightE)) && (y + 1) < map.Height) { height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightE; width++; } else { if (height > Hdir) { Vector3 pos = new Vector3((x + 1) * Constants.TILE_SIZE, (-y * Constants.TILE_SIZE), 0); Tiles.AddWall(pos, Vector3.UnitX, width, height, tileID); } width = 1; height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightE; } } width = 0; } #endregion #region Make West Walls height = 0; tileID = 0; width = 0; Hdir = 0; uint startY = 0; //Make south facing walls for (uint x = 0; x < map.Width; x++) { for (uint y = 0; y < map.Height; y++) { Tile tempTile = map.GetTile(x, y); if ((width == 0 || (tempTile.Height == height && tempTile.ID == tileID && Hdir == tempTile.heightW)) && (y + 1) < map.Height) { if (width == 0) { startY = y; } height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightW; width++; } else { if (height > Hdir) { Vector3 pos = new Vector3(x * Constants.TILE_SIZE, (-startY * Constants.TILE_SIZE), 0); Tiles.AddWall(pos, -Vector3.UnitX, width, height, tileID); } width = 1; height = tempTile.Height; tileID = (int)tempTile.ID; Hdir = tempTile.heightW; startY = y; } } width = 0; } #endregion Tiles.AllReady(); //////////////////////////////////////////// ///TODO:::: FOR EACH TILE GOING LEFT TO RIGHT // // IF height = height and tileID = tileID // if Hnorth = Hnorth // NorthWidth ++; // else // TexturedTileGroupManager.AddWall(lowerLeftNorth, Vector3.UnitY, NorthWidth, height, tileID) // NorthWidth = 0; // height = -1 // // if Hsouth = Hsouth // SouthWidth ++; // else // TexturedTileGroupManager.AddWall(lowerLeftSouth, -Vector3.UnitY, SouthhWidth, height, tileID) //etc }
void GetOrigine() { if (RightAngle) { if (Object1 != null && Object2 != null) { Line LN1 = Object1.GetComponent <Line>(); Line LN2 = Object2.GetComponent <Line>(); if (LN1 == null || LN2 == null) { Active = false; return; } Point p11 = LN1.Point1.GetComponent <Point>(); Point p12 = LN1.Point2.GetComponent <Point>(); Point p21 = LN2.Point1.GetComponent <Point>(); Point p22 = LN2.Point2.GetComponent <Point>(); if (p11 == null || p12 == null || p21 == null || p22 == null) { Active = false; return; } GetIntersection( p11.Vec.x, p11.Vec.y, p12.Vec.x, p12.Vec.y, p21.Vec.x, p21.Vec.y, p22.Vec.x, p22.Vec.y); } else { GameObject[] OBJs = FindObjectsOfType <GameObject>(); for (int i = 0; i < OBJs.Length; i++) { Line LN = OBJs[i].GetComponent <Line>(); if (LN != null) { if (LN.Id == Object1Id) { Object1 = OBJs[i]; } if (LN.Id == Object2Id) { Object2 = OBJs[i]; } } } if (Object1 == null || Object2 == null) { Active = false; } } } else { if (Object1 != null && Object2 != null && Object3 != null) { Point Point1 = Object1.GetComponent <Point>(); Point Point2 = Object2.GetComponent <Point>(); Point Point3 = Object3.GetComponent <Point>(); Origine = Point2.Vec; UnitX = Point1.Vec - Origine; UnitX.Normalize(); // 長さ1(不要か?) UnitY = Point3.Vec - Origine; UnitY.Normalize(); // 長さ1(不要か?) } else { GameObject[] OBJs = FindObjectsOfType <GameObject>(); for (int i = 0; i < OBJs.Length; i++) { Point PT = OBJs[i].GetComponent <Point>(); if (PT != null) { if (PT.Id == Object1Id) { Object1 = OBJs[i]; } if (PT.Id == Object2Id) { Object2 = OBJs[i]; } if (PT.Id == Object3Id) { Object3 = OBJs[i]; } } } if (Object1 == null || Object2 == null || Object3 == null) { Active = false; } } } }
public void SqlTypeMemberTest() { ObjectMapper om = Map.GetObjectMapper(typeof(Object3)); Object3 o = new Object3(); om.SetValue(o, "Int32", 123.56); om.SetValue(o, "Single", 123.57.ToString(CultureInfo.InvariantCulture)); Assert.AreEqual(123, o.Int32. Value); Assert.AreEqual(123.57f, o.Single.Value); Assert.AreEqual(123, om.GetValue(o, "Int32")); Assert.AreEqual(123.57f, om.GetValue(o, "Single")); }
/// <summary> /// Constructor /// </summary> /// <param name="_model">Projectile model</param> /// <param name="_position">Position of the missile</param> /// <param name="_angle">Angle at which the missile will be fired</param> /// <param name="_velocity">Velocity of the missile</param> /// <param name="_alive">Alive</param> /// <param name="_firedBy">Who fired the missile</param> public Projectile(Vector3 _position, VTankObject.Point target, double _angle, double _velocity, float _alive, PlayerTank _firedBy, ProjectileData projectileData) { this.data = projectileData; this.position = _position; position = _position + Vector3.UnitZ;; base.ZRotation = (float)_angle; velocity = (float)_velocity; timeAlive = _alive; elapsed = 0; this.boundingSphere.Radius = projectileData.CollisionRadius; SetBoundingSpherePosition(); owner = _firedBy; RenderID = -1; ID = projectileData.ID; origin = position; if (_firedBy.Weapon.HasFiringArc) { this.usingLaunchAngle = true; float swivelAngle = ZRotation; float tiltAngle = _firedBy.Weapon.LaunchAngle; float projection = DEFAULT_CANNON_LENGTH * (float)Math.Cos(tiltAngle); float tipX = -projection * (float)Math.Cos(swivelAngle); float tipY = -projection * (float)Math.Sin(swivelAngle); float tipZ = Math.Abs(DEFAULT_CANNON_LENGTH * (float)Math.Sin(swivelAngle)); tip = new float[] { tipX, tipY, tipZ }; Vector3 newPosition = position + new Vector3(tipX, tipY, tipZ); // Calculate initial velocity based on the distance we travel. float distance = (float)Math.Sqrt( Math.Pow(target.x - newPosition.X, 2) + Math.Pow(target.y - newPosition.Y, 2)); float maxDistance = (int)projectileData.Range; if (distance > maxDistance) { distance = maxDistance; } // TODO: This is a temporary work-around until we figure out what velocity component // is missing from the formula. float offset = 1.1f; if (tiltAngle > MathHelper.ToRadians(45.0f)) { offset = 1.6f; } float V = (float)Math.Sqrt(-gravity * distance * offset); float Vx = -V * (float)(Math.Cos(tiltAngle) * Math.Cos(swivelAngle)); float Vy = -V * (float)(Math.Cos(tiltAngle) * Math.Sin(swivelAngle)); float Vz = V * (float)Math.Sin(tiltAngle); componentVelocity = new float[] { Vx, Vy, Vz }; elapsedDelta = 0f; /*this.verticalVelocity = this.FindVerticalVelocity(_firedBy.Weapon.LaunchAngle, velocity); * float flightTime = this.FindFlightTime(verticalVelocity, gravity); * float horizontalVelocity = this.FindHorizontalVelocity( * distance, * flightTime); * velocity = horizontalVelocity;*/ } Object3 turret = owner.Turret; ModelBoneCollection.Enumerator collection = turret.Model.Bones.GetEnumerator(); List <ModelBone> emitters = new List <ModelBone>(); while (collection.MoveNext()) { if (collection.Current.Name.StartsWith("Emitter")) { emitters.Add(collection.Current); } } if (emitters.Count == 0) { ServiceManager.Game.Console.DebugPrint( "Warning: Can't attach to owner tank, no emitter exists."); } else { int emitter = _firedBy.Weapon.GetNextEmitterIndex(); this.Attach(turret, emitters[emitter].Name); this.MimicRotation(turret); this.Unattach(); Vector3 forward = emitters[emitter].Transform.Forward; forward.Z = Math.Abs(forward.Z); //position *= forward; } if (!String.IsNullOrEmpty(projectileData.Model)) { model = new Object3(ServiceManager.Resources.GetModel("projectiles\\" + projectileData.Model), position); model.MimicPosition(this, Vector3.Zero); model.MimicRotation(this); modelRenderID = ServiceManager.Scene.Add(model, 3); } else { model = null; } if (!String.IsNullOrEmpty(projectileData.ParticleEffect) && projectileData.Model == null) { ParticleEmitter.MimicPosition(this, Vector3.Zero); ParticleEmitter.MimicRotation(this); particleEmitterRenderID = ServiceManager.Scene.Add(ParticleEmitter, 3); } else if (!String.IsNullOrEmpty(projectileData.ParticleEffect)) { ParticleEmitter = new ParticleEmitter(projectileData.ParticleEffect, this.Position); this.particleEmitterRenderID = ServiceManager.Scene.Add(ParticleEmitter, 3); ParticleEmitter.Follow(this); } }
public void ClearProp4() { Prop4 = null; }
public void ModifyProp4(Object3 value) { Prop4 = value; Prop3 = "Prop4 has been modified"; }
public void ICollectionMapTest() { var mapper = Map.GetObjectMapper<Object3, Object3>(); var src = new Object3(); src.HashSet.Add(Guid.NewGuid().ToString()); src.HashSet.Add(Guid.NewGuid().ToString()); var dest = mapper(src); Assert.IsNotNull(dest); foreach (var str in src.HashSet) { Assert.That(dest.HashSet.Contains(str)); } }
public void ClearProp4() { Prop4 = null; Prop3 = "Prop4 has been cleared"; }
private ASCOM.Astrometry.AstroUtils.AstroUtils.BodyInfo BodyAltitude(EventType TypeOfEvent, double JD, double Hour, double Latitude, double Longitude) { Object3 CelObject = new Object3(); OnSurface onSurface = new OnSurface(); CatEntry3 catEntry3 = new CatEntry3(); SkyPos Output = new SkyPos(); Observer Location = new Observer(); ASCOM.Astrometry.AstroUtils.AstroUtils.BodyInfo bodyInfo = new ASCOM.Astrometry.AstroUtils.AstroUtils.BodyInfo(); double JdHigh = JD + Hour / 24.0; double DeltaT = DeltatCode.DeltaTCalc(JD); switch (TypeOfEvent) { case EventType.SunRiseSunset: case EventType.CivilTwilight: case EventType.NauticalTwilight: case EventType.AmateurAstronomicalTwilight: case EventType.AstronomicalTwilight: CelObject.Name = "Sun"; CelObject.Number = Body.Sun; break; case EventType.MoonRiseMoonSet: CelObject.Name = "Moon"; CelObject.Number = Body.Moon; break; case EventType.MercuryRiseSet: CelObject.Name = "Mercury"; CelObject.Number = Body.Mercury; break; case EventType.VenusRiseSet: CelObject.Name = "Venus"; CelObject.Number = Body.Venus; break; case EventType.MarsRiseSet: CelObject.Name = "Mars"; CelObject.Number = Body.Mars; break; case EventType.JupiterRiseSet: CelObject.Name = "Jupiter"; CelObject.Number = Body.Jupiter; break; case EventType.SaturnRiseSet: CelObject.Name = "Saturn"; CelObject.Number = Body.Saturn; break; case EventType.UranusRiseSet: CelObject.Name = "Uranus"; CelObject.Number = Body.Uranus; break; case EventType.NeptuneRiseSet: CelObject.Name = "Neptune"; CelObject.Number = Body.Neptune; break; case EventType.PlutoRiseSet: CelObject.Name = "Pluto"; CelObject.Number = Body.Pluto; break; default: throw new InvalidValueException("TypeOfEvent", TypeOfEvent.ToString(), "Unknown type of event"); } CelObject.Star = catEntry3; CelObject.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; Location.OnSurf = onSurface; Location.Where = ObserverLocation.EarthGeoCenter; int num1 = (int)Nov31.Place(JdHigh + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output); bodyInfo.Distance = Output.Dis * 149597870.691; double Gst = 0; Nov31.SiderealTime(JdHigh, 0.0, DeltaT, GstType.GreenwichApparentSiderealTime, ASCOM.Astrometry.Method.EquinoxBased, Accuracy.Full, ref Gst); double num2 = 15.0 * (Range(Gst + Longitude * (1.0 / 15.0), 0.0, true, 24.0, false) - Output.RA); bodyInfo.Altitude = Math.Asin(Math.Sin(Latitude * (Math.PI / 180.0)) * Math.Sin(Output.Dec * (Math.PI / 180.0)) + Math.Cos(Latitude * (Math.PI / 180.0)) * Math.Cos(Output.Dec * (Math.PI / 180.0)) * Math.Cos(num2 * (Math.PI / 180.0))) * (180.0 / Math.PI); switch (TypeOfEvent) { case EventType.MoonRiseMoonSet: bodyInfo.Radius = 1737.0; break; case EventType.MercuryRiseSet: bodyInfo.Radius = 2439.7; break; case EventType.VenusRiseSet: bodyInfo.Radius = 2439.7; break; case EventType.MarsRiseSet: bodyInfo.Radius = 3396.2; break; case EventType.JupiterRiseSet: bodyInfo.Radius = 69911.0; break; case EventType.SaturnRiseSet: bodyInfo.Radius = 6051.8; break; case EventType.UranusRiseSet: bodyInfo.Radius = 24973.0; break; case EventType.NeptuneRiseSet: bodyInfo.Radius = 24767.0; break; case EventType.PlutoRiseSet: bodyInfo.Radius = 1153.0; break; default: bodyInfo.Radius = 696342.0; break; } return(bodyInfo); }