protected override ISceneObject SpawnBullet(Point point)
        {
            if (lastBullet != null)
            {
                lastBullet.GetControlOfType <HighlightingControl>().Enabled = false;
            }

            if (point.Y > Owner.GetBaseLocation().Y)
            {
                point.Y = Owner.GetBaseLocation().Y;
            }

            lastBullet = SceneObjectFactory.CreateSingularityBouncingBullet(SceneMgr, point, Owner);

            NetOutgoingMessage msg = SceneMgr.CreateNetMessage();

            lastBullet.WriteObject(msg);
            SceneMgr.SendMessage(msg);

            HighlightingControl hc = new HighlightingControl();

            lastBullet.AddControl(hc);

            SceneMgr.DelayedAttachToScene(lastBullet);
            return(lastBullet);
        }
        private void ReceivedNewSingularityBouncingBulletMsg(NetIncomingMessage msg)
        {
            SingularityBouncingBullet s = new SingularityBouncingBullet(this, -1);

            s.ReadObject(msg);
            s.Owner = GetOpponentPlayer();
            s.SetGeometry(SceneGeometryFactory.CreateConstantColorEllipseGeometry(s));
            DelayedAttachToScene(s);
            SyncReceivedObject(s, msg);
        }
예제 #3
0
        public static SingularityBouncingBullet CreateSingularityBouncingBullet(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();

            SingularityBouncingBullet bullet = new SingularityBouncingBullet(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId()));

            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;

            PointCollisionShape cs = new PointCollisionShape();

            cs.Center             = bullet.Center;
            bullet.CollisionShape = cs;

            LinearMovementControl lmc = new LinearMovementControl();

            lmc.Speed = plr.Data.BulletSpeed;
            bullet.AddControl(lmc);

            BouncingSingularityBulletControl c = new BouncingSingularityBulletControl();

            c.Speed    = SharedDef.BULLET_EXPLOSION_SPEED;
            c.Strength = SharedDef.BULLET_EXPLOSION_STRENGTH;
            bullet.AddControl(c);

            bullet.AddControl(new StickyPointCollisionShapeControl());

            bullet.SetGeometry(SceneGeometryFactory.CreateConstantColorEllipseGeometry(bullet));

            return(bullet);
        }