private void CreateMovingParticleEmmitor(Vector position, Vector direction, float speed, float time) { ParticleEmmitor e = new ParticleEmmitor(null, IdMgr.GetNewId(0)); e.Direction = direction; e.EmmitingDirection = direction.Rotate(180); e.MinAngle = (float)(-Math.PI); e.MaxAngle = (float)(Math.PI); e.MinForce = 1; e.MaxForce = 2; e.MinLife = 2f; e.MaxLife = 2.5f; e.Position = position; e.MinSize = 0.2f; e.MaxSize = 1; e.Amount = 250; e.SizeMultiplier = 0; e.Infinite = true; e.Enabled = false; ParticleSphereFactory f = new ParticleSphereFactory(); f.Color = Color.FromArgb(125, 255, 20, 0); e.Factory = f; LinearMovementControl c = new LinearMovementControl(); c.Speed = speed; e.AddControl(c); GameLevelManager.SendNewObject(mgr, e); }
public static SingularityBullet CreateSingularityBullet(SceneMgr mgr, Point point, Player plr) { Vector position = new Vector(plr.GetBaseLocation().X + plr.GetBaseLocation().Width / 2, plr.GetBaseLocation().Y); Vector direction = point.ToVector() - position; direction.Normalize(); SingularityBullet bullet = new SingularityBullet(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); bullet.Position = position; bullet.Owner = plr; bullet.Radius = 2; bullet.Damage = plr.Data.BulletDamage; bullet.Direction = direction; bullet.Color = plr.Data.PlayerColor; PointCollisionShape cs = new PointCollisionShape(); cs.Center = bullet.Center; bullet.CollisionShape = cs; LinearMovementControl lmc = new LinearMovementControl(); lmc.Speed = plr.Data.BulletSpeed; bullet.AddControl(lmc); bullet.AddControl(new SingularityBulletCollisionReactionControl()); bullet.AddControl(new StickyPointCollisionShapeControl()); bullet.SetGeometry(SceneGeometryFactory.CreateConstantColorEllipseGeometry(bullet)); return(bullet); }
private void CreateSmallBullet(double rotation) { SingularityBullet smallBullet = new SingularityBullet(SceneMgr, IdMgr.GetNewId(SceneMgr.GetCurrentPlayer().GetId())); smallBullet.Owner = Owner; Vector dir = Direction; dir.Normalize(); smallBullet.Direction = dir.Rotate(rotation); smallBullet.Position = Center; smallBullet.Radius = 2; smallBullet.Damage = Damage / 2; PointCollisionShape cs = new PointCollisionShape(); cs.Center = smallBullet.Center; smallBullet.CollisionShape = cs; smallBullet.Color = Color; smallBullet.SetGeometry(SceneGeometryFactory.CreateConstantColorEllipseGeometry(smallBullet)); LinearMovementControl nmc = new LinearMovementControl(); nmc.Speed = GetControlOfType <LinearMovementControl>().Speed; smallBullet.AddControl(nmc); SingularityBulletCollisionReactionControl cc = new SingularityBulletCollisionReactionControl(); cc.StatReported = true; smallBullet.AddControl(cc); smallBullet.AddControl(new StickyPointCollisionShapeControl()); SceneMgr.DelayedAttachToScene(smallBullet); }
public static ParticleEmmitor CreateMovingSphereEmmitor(SceneMgr mgr, Vector position, Vector direction, Color color, float speed) { ParticleEmmitor e = CreateBasicSphere(mgr, color); e.Direction = direction; e.EmmitingDirection = direction.Rotate(180); e.MinAngle = (float)(-Math.PI); e.MaxAngle = (float)(Math.PI); e.MinForce = 1; e.MaxForce = 2; e.MinLife = 2f; e.MaxLife = 2.5f; e.Position = position; e.MinSize = 0.2f; e.MaxSize = 1; e.Amount = 250; e.SizeMultiplier = 0; e.Infinite = true; e.Enabled = true; LinearMovementControl c = new LinearMovementControl(); c.Speed = speed; e.AddControl(c); return(e); }
protected override ISceneObject SpawnMine(Point point) { SingularityMine mine = SceneObjectFactory.CreateAsteroidDroppingSingularityMine(SceneMgr, point, Owner); Vector dir = new Vector(endPoint.X - startPoint.X, endPoint.Y - startPoint.Y); dir.Normalize(); mine.Direction = dir; LinearMovementControl c = mine.GetControlOfType <LinearMovementControl>(); c.Speed = Owner.Data.MineFallingSpeed * SharedDef.MINE_LAUNCHER_SPEED_MODIFIER; if (SceneMgr.GameType != Gametype.SOLO_GAME) { NetOutgoingMessage msg = SceneMgr.CreateNetMessage(); (mine as ISendable).WriteObject(msg); SceneMgr.SendMessage(msg); } HighlightingControl hc = new HighlightingControl(); mine.AddControl(hc); lastMine = mine; SceneMgr.DelayedAttachToScene(mine); return(mine); }
public static void InitSingularityBullet(SingularityBullet bullet, SceneMgr mgr, Vector point, Vector position, Player plr) { Vector direction = point - position; direction.Normalize(); bullet.Position = position; bullet.Owner = plr; bullet.Radius = 2; bullet.Damage = plr.Data.BulletDamage; bullet.Direction = direction; bullet.Direction.Normalize(); bullet.Color = plr.Data.PlayerColor; LinearMovementControl lmc = new LinearMovementControl(); lmc.Speed = plr.Data.BulletSpeed; bullet.AddControl(lmc); bullet.SetGeometry(SceneGeometryFactory.CreateConstantColorEllipseGeometry(bullet)); }
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); }
public static void ReadObjectLinearMovementControl(this NetIncomingMessage msg, LinearMovementControl c) { msg.ReadControl(c); c.Speed = msg.ReadFloat(); }
public static void WriteObjectLinearMovementControl(this NetOutgoingMessage msg, LinearMovementControl c) { msg.WriteControl(c); msg.Write(c.Speed); }
public static IList <IControl> ReadControls(this NetIncomingMessage msg) { int controlCount = msg.ReadInt32(); IList <IControl> controls = new List <IControl>(controlCount); for (int i = 0; i < controlCount; ++i) { int hash = msg.ReadInt32(); if (hash == typeof(BaseCollisionControl).GUID.GetHashCode()) { BaseCollisionControl c = new BaseCollisionControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(BouncingSingularityBulletControl).GUID.GetHashCode()) { BouncingSingularityBulletControl c = new BouncingSingularityBulletControl(); msg.ReadObjectExplodingSingularityBulletControl(c); controls.Add(c); } else if (hash == typeof(DroppingSingularityControl).GUID.GetHashCode()) { DroppingSingularityControl c = new DroppingSingularityControl(); msg.ReadObjectDroppingSingularityControl(c); controls.Add(c); } else if (hash == typeof(AsteroidDroppingSingularityControl).GUID.GetHashCode()) { AsteroidDroppingSingularityControl c = new AsteroidDroppingSingularityControl(); msg.ReadObjectDroppingSingularityControl(c); controls.Add(c); } else if (hash == typeof(NewtonianMovementControl).GUID.GetHashCode()) { NewtonianMovementControl c = new NewtonianMovementControl(); msg.ReadObjectNewtonianMovementControl(c); controls.Add(c); } else if (hash == typeof(LinearMovementControl).GUID.GetHashCode()) { LinearMovementControl c = new LinearMovementControl(); msg.ReadObjectLinearMovementControl(c); controls.Add(c); } else if (hash == typeof(LinearRotationControl).GUID.GetHashCode()) { LinearRotationControl c = new LinearRotationControl(); msg.ReadObjectLinearRotationControl(c); controls.Add(c); } else if (hash == typeof(PowerHookControl).GUID.GetHashCode()) { PowerHookControl c = new PowerHookControl(); msg.ReadObjectHookControl(c); controls.Add(c); } else if (hash == typeof(HookControl).GUID.GetHashCode()) { HookControl c = new HookControl(); msg.ReadObjectHookControl(c); controls.Add(c); } else if (hash == typeof(ExplodingSingularityBulletControl).GUID.GetHashCode()) { ExplodingSingularityBulletControl c = new ExplodingSingularityBulletControl(); msg.ReadObjectExplodingSingularityBulletControl(c); controls.Add(c); } else if (hash == typeof(ExcludingExplodingSingularityBulletControl).GUID.GetHashCode()) { ExcludingExplodingSingularityBulletControl c = new ExcludingExplodingSingularityBulletControl(); msg.ReadObjectExcludingExplodingSingularityBulletControl(c); controls.Add(c); } else if (hash == typeof(MinorAsteroidCollisionReactionControl).GUID.GetHashCode()) { MinorAsteroidCollisionReactionControl c = new MinorAsteroidCollisionReactionControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(SingularityBulletCollisionReactionControl).GUID.GetHashCode()) { SingularityBulletCollisionReactionControl c = new SingularityBulletCollisionReactionControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(StatPowerUpCollisionReactionControl).GUID.GetHashCode()) { StatPowerUpCollisionReactionControl c = new StatPowerUpCollisionReactionControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(StickyPointCollisionShapeControl).GUID.GetHashCode()) { StickyPointCollisionShapeControl c = new StickyPointCollisionShapeControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(StickySphereCollisionShapeControl).GUID.GetHashCode()) { StickySphereCollisionShapeControl c = new StickySphereCollisionShapeControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(StickySquareCollisionShapeControl).GUID.GetHashCode()) { StickySquareCollisionShapeControl c = new StickySquareCollisionShapeControl(); msg.ReadControl(c); controls.Add(c); } else if (hash == typeof(BaseHealthControl).GUID.GetHashCode()) { BaseHealthControl c = new BaseHealthControl(); msg.ReadHealthControl(c); controls.Add(c); } else if (hash == typeof(DestroyHpControl).GUID.GetHashCode()) { DestroyHpControl c = new DestroyHpControl(); msg.ReadHealthControl(c); controls.Add(c); } else if (hash == typeof(HpRegenControl).GUID.GetHashCode()) { HpRegenControl c = new HpRegenControl(); msg.ReadHealthRegenControl(c); controls.Add(c); } else if (hash == typeof(ModuleDamageControl).GUID.GetHashCode()) { ModuleDamageControl c = new ModuleDamageControl(); msg.ReadModuleDamageControl(c); controls.Add(c); } else if (hash == typeof(HighlightingControl).GUID.GetHashCode()) { // skip } else { Logger.Error("Received unsupported control (" + hash + ")!"); } } return(controls); }