private void SpawnNewBullet(ISceneObject target, ISceneObject ignored = null) { SingularityExplodingBullet bullet = new SingularityExplodingBullet(me.SceneMgr, IdMgr.GetNewId(me.SceneMgr.GetCurrentPlayer().GetId())); Vector targettedPosition = AIUtils.ComputeDestinationPositionToHitTarget(target, meBullet.Owner.Data.BulletSpeed, me.Center, me.SceneMgr.GetRandomGenerator()); SceneObjectFactory.InitSingularityBullet(bullet, me.SceneMgr, targettedPosition, me.Position, meBullet.Owner); PointCollisionShape cs = new PointCollisionShape(); cs.Center = bullet.Center; bullet.CollisionShape = cs; ExcludingExplodingSingularityBulletControl c = new ExcludingExplodingSingularityBulletControl(); c.Speed = SharedDef.BULLET_EXPLOSION_SPEED; c.Strength = SharedDef.BULLET_EXPLOSION_STRENGTH; c.StatReported = true; if (ignored != null) { c.IgnoredObjects.Add(ignored.Id); } bullet.AddControl(c); bullet.AddControl(new StickyPointCollisionShapeControl()); NetOutgoingMessage msg = me.SceneMgr.CreateNetMessage(); (bullet as ISendable).WriteObject(msg); me.SceneMgr.SendMessage(msg); me.SceneMgr.DelayedAttachToScene(bullet); }
public static SingularityExplodingBullet CreateSingularityExploadingBullet(SceneMgr mgr, Vector point, Vector position, Player plr) { Vector direction = point - position; direction.Normalize(); SingularityExplodingBullet bullet = new SingularityExplodingBullet(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); InitSingularityBullet(bullet, mgr, point, position, plr); PointCollisionShape cs = new PointCollisionShape(); cs.Center = bullet.Center; bullet.CollisionShape = cs; ExplodingSingularityBulletControl c = new ExplodingSingularityBulletControl(); c.Speed = SharedDef.BULLET_EXPLOSION_SPEED; c.Strength = SharedDef.BULLET_EXPLOSION_STRENGTH; bullet.AddControl(c); bullet.AddControl(new StickyPointCollisionShapeControl()); return(bullet); }
private void ReceivedNewSingularityExplodingBulletMsg(NetIncomingMessage msg) { SingularityExplodingBullet s = new SingularityExplodingBullet(this, -1); s.ReadObject(msg); s.Owner = GetOpponentPlayer(); s.SetGeometry(SceneGeometryFactory.CreateConstantColorEllipseGeometry(s)); DelayedAttachToScene(s); SyncReceivedObject(s, msg); }
protected override void InitControl(ISceneObject me) { base.InitControl(me); if (!(me is SingularityExplodingBullet)) { throw new InvalidOperationException("Cannot attach SingularityControl to non SingularityExploadingBullet object"); } hitObjects = new List <long>(); meBullet = me as SingularityExplodingBullet; hitSomething = false; events.AddEvent((int)Events.DEATH_AND_BULLET_SPAWN, new Event(SharedDef.BULLET_LIFE_TIME, EventType.ONE_TIME, new Action(() => { DieAndSpawnBullets(); }))); }
protected override ISceneObject SpawnBullet(Point point) { if (point.Y > Owner.GetBaseLocation().Y) { point.Y = Owner.GetBaseLocation().Y; } SingularityExplodingBullet bullet = SceneObjectFactory.CreateSingularityExploadingBullet(SceneMgr, point.ToVector(), Owner); NetOutgoingMessage msg = SceneMgr.CreateNetMessage(); (bullet as ISendable).WriteObject(msg); SceneMgr.SendMessage(msg); SceneMgr.DelayedAttachToScene(bullet); return(bullet); }