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 ReceivedNewSingularityBulletMsg(NetIncomingMessage msg) { SingularityBullet s = new SingularityBullet(this, -1); s.ReadObject(msg); s.Owner = GetOpponentPlayer(); s.SetGeometry(SceneGeometryFactory.CreateConstantColorEllipseGeometry(s)); DelayedAttachToScene(s); SyncReceivedObject(s, msg); //SoundManager.Instance.StartPlayingOnce(SharedDef.MUSIC_SHOOT); }
protected virtual ISceneObject SpawnBullet(Point point) { if (point.Y > Owner.GetBaseLocation().Y) { point.Y = Owner.GetBaseLocation().Y; } SingularityBullet bullet = SceneObjectFactory.CreateSingularityBullet(SceneMgr, point, Owner); if (SceneMgr.GameType != Gametype.SOLO_GAME) { NetOutgoingMessage msg = SceneMgr.CreateNetMessage(); (bullet as ISendable).WriteObject(msg); SceneMgr.SendMessage(msg); } SceneMgr.DelayedAttachToScene(bullet); return(bullet); }
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)); }
protected override void InitControl(ISceneObject me) { bullet = me as SingularityBullet; }
public static void ReadObjectSingularityBullet(this NetIncomingMessage msg, SingularityBullet s) { msg.ReadObjectSphere(s); s.Damage = msg.ReadInt32(); }
public static void WriteObjectSingularityBullet(this NetOutgoingMessage msg, SingularityBullet s) { msg.WriteObjectSphere(s); msg.Write(s.Damage); }