public static Asteroid CreateCustomAsteroid(ServerMgr mgr, int rad, Vector pos, Vector dir, AsteroidType type) { Random randomGenerator = mgr.GetRandomGenerator(); Asteroid s; s = new Asteroid(null, IdMgr.GetNewId(0)); s.AsteroidType = type; if (type == AsteroidType.NORMAL) { s.TextureId = randomGenerator.Next(1, 18); } else { s.TextureId = randomGenerator.Next(1, 6); } s.Radius = rad; s.Direction = dir; s.Position = pos; s.Rotation = mgr.GetRandomGenerator().Next(360); SphereCollisionShape cs = new SphereCollisionShape(); cs.Center = s.Center; cs.Radius = s.Radius; s.CollisionShape = cs; CreateAsteroidControls(mgr, s); return(s); }
public static SingularityMine CreatePowerlessMine(SceneMgr mgr, Vector pos, Vector dir, Player plr) { SingularityMine mine = new SingularityMine(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); mine.Position = pos; mine.Owner = plr; mine.Radius = 2; mine.Direction = dir; mine.Color = Colors.BlueViolet; mine.SetGeometry(SceneGeometryFactory.CreateMineImage(mine)); SphereCollisionShape cs = new SphereCollisionShape(); cs.Center = mine.Center; cs.Radius = mine.Radius; mine.CollisionShape = cs; PowerlessSingularityControl sc = new PowerlessSingularityControl(); sc.Speed = plr.Data.MineGrowthSpeed; sc.Strength = plr.Data.MineStrength; sc.StatsReported = true; mine.AddControl(sc); mine.AddControl(new StickySphereCollisionShapeControl()); return(mine); }
public static Base CreateBase(SceneMgr mgr, Player plr) { Base baze = new Base(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); baze.Owner = plr; baze.BasePosition = plr.Data.PlayerPosition; baze.Color = plr.Data.PlayerColor; baze.Position = new Vector(plr.GetBaseLocation().X, plr.GetBaseLocation().Y); baze.Size = new Size(plr.GetBaseLocation().Width, plr.GetBaseLocation().Height); SphereCollisionShape cs = new SphereCollisionShape(); cs.Center = new Vector(baze.Center.X, baze.Position.Y + 2.5 * baze.Size.Height); cs.Radius = (int)(baze.Size.Width / 1.6); baze.CollisionShape = cs; BaseHealthControl hc = new BaseHealthControl(); baze.AddControl(hc); baze.AddControl(new BaseCollisionControl()); baze.LoadImages(); baze.SetGeometry(baze.Image100); return(baze); }
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); }
protected override void InitControl(ISceneObject me) { if (!(me.CollisionShape is SphereCollisionShape)) { throw new Exception("Collision shape must be Sphere"); } cs = me.CollisionShape as SphereCollisionShape; }
public static Asteroid CreateNewRandomAsteroid(ServerMgr mgr, bool headingRight) { Random randomGenerator = mgr.GetRandomGenerator(); Asteroid s; int chance = randomGenerator.Next(100); if (chance <= SharedDef.ASTEROID_GOLD_CHANCE) { s = new Asteroid(null, IdMgr.GetNewId(0)); s.AsteroidType = AsteroidType.GOLDEN; s.TextureId = randomGenerator.Next(1, 6); s.Radius = randomGenerator.Next(SharedDef.MIN_ASTEROID_RADIUS, SharedDef.MAX_ASTEROID_RADIUS); s.Gold = (s.Radius / 2) * SharedDef.GOLD_ASTEROID_BONUS_MULTIPLY; } else if (chance <= SharedDef.ASTEROID_UNSTABLE_CHANCE) { s = new UnstableAsteroid(null, IdMgr.GetNewId(0)); s.AsteroidType = AsteroidType.UNSTABLE; s.TextureId = randomGenerator.Next(1, 6); s.Radius = randomGenerator.Next(SharedDef.MIN_ASTEROID_RADIUS, SharedDef.MAX_ASTEROID_RADIUS); s.Gold = s.Radius / 2; } else { s = new Asteroid(null, IdMgr.GetNewId(0)); s.AsteroidType = AsteroidType.NORMAL; s.TextureId = randomGenerator.Next(1, 18); s.Radius = randomGenerator.Next(SharedDef.MIN_ASTEROID_RADIUS, SharedDef.MAX_ASTEROID_RADIUS); s.Gold = s.Radius / 2; } s.IsHeadingRight = headingRight; s.Direction = headingRight ? new Vector(1, 0) : new Vector(-1, 0); s.Position = GetRandomPositionInOrbitArea(randomGenerator, s.Radius); s.Color = Color.FromRgb((byte)randomGenerator.Next(40, 255), (byte)randomGenerator.Next(40, 255), (byte)randomGenerator.Next(40, 255)); s.Rotation = mgr.GetRandomGenerator().Next(360); SphereCollisionShape cs = new SphereCollisionShape(); cs.Center = s.Center; cs.Radius = s.Radius; s.CollisionShape = cs; CreateAsteroidControls(mgr, s); return(s); }
public void ReadObject(NetIncomingMessage msg) { msg.ReadObjectSingularityMine(this); SphereCollisionShape cs = new SphereCollisionShape(); cs.Center = Center; cs.Radius = Radius; CollisionShape = cs; IList <IControl> controls = msg.ReadControls(); foreach (Control c in controls) { AddControl(c); } }
public static SphereField CreateSphereField(SceneMgr mgr, Vector position, int radius, Color color) { SphereField f = new SphereField(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); f.Radius = radius; f.Color = color; f.Position = position; f.HeavyWeightGeometry = HeavyweightGeometryFactory.CreateConstantColorEllipseGeometry(f); SphereCollisionShape shape = new SphereCollisionShape(); shape.Radius = radius; shape.Center = f.Center; f.CollisionShape = shape; return(f); }
public void SpawnAsteroid() { if (AsteroidSpawned) { return; } AsteroidSpawned = true; me.RemoveControlsOfType <HighlightingControl>(); Asteroid ast = new Asteroid(me.SceneMgr, IdMgr.GetNewId(me.SceneMgr.GetCurrentPlayer().GetId())); ast.Gold = 0; ast.Radius = 20; ast.Position = new Vector(me.Position.X - ast.Radius, me.Position.Y - ast.Radius); ast.Direction = (me as IMovable).Direction; ast.AsteroidType = AsteroidType.NORMAL; ast.TextureId = me.SceneMgr.GetRandomGenerator().Next(1, 18); SphereCollisionShape cs = new SphereCollisionShape(); cs.Center = ast.Center; cs.Radius = ast.Radius; ast.CollisionShape = cs; ast.SetGeometry(SceneGeometryFactory.CreateAsteroidImage(ast)); me.SceneMgr.DelayedAttachToScene(ast); collided.Add(ast.Id); ast.AddControl(new StickySphereCollisionShapeControl()); NewtonianMovementControl nmc = new NewtonianMovementControl(); nmc.Speed = me.SceneMgr.GetCurrentPlayer().Data.MineFallingSpeed; ast.AddControl(nmc); NetOutgoingMessage msg = me.SceneMgr.CreateNetMessage(); ast.WriteObject(msg); me.SceneMgr.SendMessage(msg); }
public static MiningModule CreateMiningModule(SceneMgr mgr, Vector position, Player owner) { MiningModule module = new MiningModule(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId()), owner); module.Position = position; module.Radius = 10; module.Color = Colors.Crimson; ModuleDamageControl mc = new ModuleDamageControl(); mc.MaxHp = SharedDef.SPECTATOR_MAX_HP; module.AddControl(mc); SphereCollisionShape cs = new SphereCollisionShape(); cs.Center = module.Center; cs.Radius = module.Radius; module.CollisionShape = cs; ControlableDeviceControl dc = new ControlableMiningModuleControl(); module.AddControl(dc); LinearRotationControl rc = new LinearRotationControl(); rc.RotationSpeed = SharedDef.SPECTATOR_MODULE_ROTATION_SPEED; module.AddControl(rc); HpRegenControl hc = new HpRegenControl(); hc.MaxRegenTime = SharedDef.SPECTATOR_HP_REGEN_CD; hc.RegenTimer = SharedDef.SPECTATOR_HP_REGEN_CD; hc.RegenSpeed = SharedDef.SPECTATOR_REGEN_SPEED; module.AddControl(hc); module.AddControl(new RespawningObjectControl()); module.AddControl(new StickySphereCollisionShapeControl()); module.SetGeometry(SceneGeometryFactory.CrateMiningModule(module)); return(module); }
public static PowerHook CreatePowerHook(SceneMgr mgr, Point point, Player player) { Vector position = new Vector(player.GetBaseLocation().X + player.GetBaseLocation().Width / 2, player.GetBaseLocation().Y - 5); Vector direction = point.ToVector() - position; direction.Normalize(); PowerHook hook = new PowerHook(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); hook.Owner = player; hook.Radius = 8; position.X -= hook.Radius; position.Y -= hook.Radius; hook.Position = position; hook.Rotation = (float)Vector.AngleBetween(new Vector(0, -1), direction); hook.Direction = direction; hook.Color = Colors.RoyalBlue; hook.SetGeometry(SceneGeometryFactory.CreateHookHead(hook)); SphereCollisionShape cs = new SphereCollisionShape(); cs.Radius = hook.Radius / 2; cs.Center = hook.Center; hook.CollisionShape = cs; PowerHookControl hookControl = new PowerHookControl(); hookControl.Origin = new Vector(hook.Center.X, hook.Center.Y); hookControl.Speed = player.Data.HookSpeed; hookControl.Lenght = player.Data.HookLenght; hook.AddControl(hookControl); hook.AddControl(new StickySphereCollisionShapeControl()); hook.PrepareLine(); return(hook); }
public static SingularityMine CreateDroppingSingularityMine(SceneMgr mgr, Point point, Player plr) { SingularityMine mine = new SingularityMine(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); mine.Position = new Vector(point.X, 0); mine.Owner = plr; mine.Radius = 12; mine.Direction = new Vector(0, 1); mine.Color = Colors.BlueViolet; SphereCollisionShape cs = new SphereCollisionShape(); cs.Center = mine.Center; cs.Radius = mine.Radius; mine.CollisionShape = cs; DroppingSingularityControl sc = new DroppingSingularityControl(); sc.Speed = plr.Data.MineGrowthSpeed; sc.Strength = plr.Data.MineStrength; mine.AddControl(sc); LinearMovementControl lmc = new LinearMovementControl(); lmc.Speed = plr.Data.MineFallingSpeed; mine.AddControl(lmc); LinearRotationControl lrc = new LinearRotationControl(); lrc.RotationSpeed = (float)FastMath.LinearInterpolate(0, Math.PI, mgr.GetRandomGenerator().NextDouble()); mine.AddControl(lrc); mine.AddControl(new StickySphereCollisionShapeControl()); mine.SetGeometry(SceneGeometryFactory.CreateMineImage(mine)); return(mine); }
protected override void InitControl(ISceneObject me) { shape = new SphereCollisionShape(); events.AddEvent(1, new Event(LifeTime, EventType.ONE_TIME, new Action(() => { Destroy(); }))); }