public static MinorAsteroid CreateSmallAsteroid(SceneMgr mgr, Vector direction, Vector center, int rot, int textureId, int radius, float speed, double rotation) { MinorAsteroid asteroid = new MinorAsteroid(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); asteroid.AsteroidType = AsteroidType.SPAWNED; asteroid.Rotation = rot; asteroid.Direction = direction.Rotate(rotation); asteroid.Radius = radius; asteroid.Position = center; asteroid.Gold = radius * 2; asteroid.TextureId = textureId; asteroid.Enabled = true; asteroid.SetGeometry(SceneGeometryFactory.CreateAsteroidImage(asteroid)); SphereCollisionShape cs = new SphereCollisionShape(); cs.Center = asteroid.Center; cs.Radius = asteroid.Radius; asteroid.CollisionShape = cs; NewtonianMovementControl nmc = new NewtonianMovementControl(); nmc.Speed = speed; asteroid.AddControl(nmc); LinearRotationControl lrc = new LinearRotationControl(); lrc.RotationSpeed = mgr.GetRandomGenerator().Next(SharedDef.MIN_ASTEROID_ROTATION_SPEED, SharedDef.MAX_ASTEROID_ROTATION_SPEED) / 10.0f; asteroid.AddControl(lrc); asteroid.AddControl(new MinorAsteroidCollisionReactionControl()); asteroid.AddControl(new StickySphereCollisionShapeControl()); return(asteroid); }
public static AsteroidOverlay CreateAsteroidOverlay(SceneMgr mgr, Asteroid parent) { AsteroidOverlay ao = new AsteroidOverlay(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); ao.Radius = parent.Radius; ao.Position = parent.Position; ao.Rotation = parent.Rotation; ao.AddControl(new PositionCloneControl(parent, true)); ao.AddControl(new RotationCloneControl(parent)); ao.AddControl(new RadiusCloneControl(parent)); ao.AddControl(new OverlayControl(parent)); ao.SetGeometry(SceneGeometryFactory.CreateAsteroidImage(parent, true)); return(ao); }