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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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 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);
        }
Beispiel #5
0
        protected override void InitControl(ISceneObject me)
        {
            if (!(me.CollisionShape is PointCollisionShape))
            {
                throw new Exception("Collision shape must be Point");
            }

            cs = me.CollisionShape as PointCollisionShape;
        }
        public override void ReadObject(NetIncomingMessage msg)
        {
            msg.ReadObjectSingularityBullet(this);

            PointCollisionShape cs = new PointCollisionShape();

            cs.Center      = Center;
            CollisionShape = cs;

            IList <IControl> controls = msg.ReadControls();

            foreach (Control c in controls)
            {
                AddControl(c);
            }
        }