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 void PrepareLine()
        {
            HookControl control = GetControlOfType <HookControl>();

            lineGeom = SceneGeometryFactory.CreateLineGeometry(SceneMgr, Colors.LightSteelBlue, 2, Colors.Black, control.Origin, control.Origin);
            SceneMgr.AttachGraphicalObjectToScene(lineGeom, DrawingCategory.PROJECTILE_BACKGROUND);
        }
        private void ReceivedAllAsteroidsMsg(NetIncomingMessage msg)
        {
            if (objects.Count > 2)
            {
                Logger.Error("Receiving All Asteroids packet but already have " + objects.Count + " objects");
                return;
            }

            int count = msg.ReadInt32();

            for (int i = 0; i < count; ++i)
            {
                if (msg.ReadInt32() != (int)PacketType.NEW_ASTEROID)
                {
                    Logger.Error("Corrupted object PacketType.SYNC_ALL_ASTEROIDS");
                    return;
                }
                Asteroid s = CreateNewAsteroid((AsteroidType)msg.ReadByte());
                s.ReadObject(msg);
                s.SetGeometry(SceneGeometryFactory.CreateAsteroidImage(s));
                DelayedAttachToScene(s);
                SyncReceivedObject(s, msg);
            }
            isGameInitialized = true;
        }
Beispiel #4
0
 public void LoadImages()
 {
     image100   = SceneGeometryFactory.CreateBaseImage(this, "pack://application:,,,/resources/images/base/base_bw_shaded.png");
     image75    = SceneGeometryFactory.CreateBaseImage(this, "pack://application:,,,/resources/images/base/base_bw_shaded_75.png");
     image50    = SceneGeometryFactory.CreateBaseImage(this, "pack://application:,,,/resources/images/base/base_bw_shaded_50.png");
     image25    = SceneGeometryFactory.CreateBaseImage(this, "pack://application:,,,/resources/images/base/base_bw_shaded_25.png");
     background = SceneGeometryFactory.CreateBaseImage(this, "pack://application:,,,/resources/images/base/base_background_city.png", false);
 }
        private void ReceivedNewStatPowerupMsg(NetIncomingMessage msg)
        {
            StatPowerUp p = new StatPowerUp(this, -1);

            p.ReadObject(msg);
            p.SetGeometry(SceneGeometryFactory.CreatePowerUpImage(p));
            DelayedAttachToScene(p);
            SyncReceivedObject(p, msg);
        }
        private void ReceivedNewAsteroidMsg(NetIncomingMessage msg)
        {
            Asteroid s = CreateNewAsteroid((AsteroidType)msg.ReadByte());

            s.ReadObject(msg);
            s.SetGeometry(SceneGeometryFactory.CreateAsteroidImage(s));
            DelayedAttachToScene(s);
            SyncReceivedObject(s, msg);
        }
Beispiel #7
0
        public Line(SceneMgr mgr, long id, Vector start, Vector end, Color color, int width)
            : base(mgr, id)
        {
            SceneMgr = mgr;
            Start    = start;
            End      = end;

            geometryElement = SceneGeometryFactory.CreateLineGeometry(SceneMgr, color, width, color, Start, End);
        }
        private void ReceivedNewSingularityMineMsg(NetIncomingMessage msg)
        {
            SingularityMine s = new SingularityMine(this, -1);

            s.ReadObject(msg);
            s.Owner = GetOpponentPlayer();
            s.SetGeometry(SceneGeometryFactory.CreateSolidColorEllipseGeometry(s));
            DelayedAttachToScene(s);
            SyncReceivedObject(s, msg);
        }
Beispiel #9
0
        private void PrepareLine()
        {
            if (lineGeom != null)
            {
                RemoveLine();
            }

            lineGeom = SceneGeometryFactory.CreateLineGeometry(SceneMgr, Colors.Crimson, 1, Colors.Red, startPoint.ToVector(), endPoint.ToVector());
            SceneMgr.AttachGraphicalObjectToScene(lineGeom, DrawingCategory.PROJECTILE_BACKGROUND);
        }
        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);
        }
        private void ReceivedNewHookMsg(NetIncomingMessage msg)
        {
            Hook h = msg.ReadObjectHook(this);

            h.ReadObject(msg);
            h.Owner = GetOpponentPlayer();
            h.SetGeometry(SceneGeometryFactory.CreateHookHead(h));

            h.PrepareLine();
            DelayedAttachToScene(h);
            SyncReceivedObject(h, msg);
        }
Beispiel #12
0
        private void VisualiseBase()
        {
            Square sq = new SimpleSquare(SceneMgr, SceneMgr.GetCurrentPlayer().GetId());

            sq.Position = Position;
            sq.Size     = Size;
            SceneMgr.AttachGraphicalObjectToScene(SceneGeometryFactory.CreateConstantColorRectangleGeometry(sq), DrawingCategory.PROJECTILE_BACKGROUND);

            Sphere s = new SimpleSphere(SceneMgr, SceneMgr.GetCurrentPlayer().GetId());

            s.Position = new Vector(Center.X, Position.Y + 2.5 * Size.Height);
            s.Radius   = (int)(Size.Width / 1.6);
            SceneMgr.AttachGraphicalObjectToScene(SceneGeometryFactory.CreateConstantColorEllipseGeometry(s), DrawingCategory.PROJECTILE_BACKGROUND);
        }
Beispiel #13
0
        public void SpawnAsteroid()
        {
            if (AsteroidSpawned)
            {
                return;
            }

            AsteroidSpawned = true;
            me.RemoveControlsOfType <HighlightingControl>();

            Asteroid ast = new Asteroid(me.SceneMgr, IdMgr.GetNewId(me.SceneMgr.GetCurrentPlayer().GetId()));

            ast.Gold      = 0;
            ast.Radius    = 20;
            ast.Position  = new Vector(me.Position.X - ast.Radius, me.Position.Y - ast.Radius);
            ast.Direction = (me as IMovable).Direction;

            ast.AsteroidType = AsteroidType.NORMAL;
            ast.TextureId    = me.SceneMgr.GetRandomGenerator().Next(1, 18);

            SphereCollisionShape cs = new SphereCollisionShape();

            cs.Center          = ast.Center;
            cs.Radius          = ast.Radius;
            ast.CollisionShape = cs;

            ast.SetGeometry(SceneGeometryFactory.CreateAsteroidImage(ast));

            me.SceneMgr.DelayedAttachToScene(ast);

            collided.Add(ast.Id);

            ast.AddControl(new StickySphereCollisionShapeControl());

            NewtonianMovementControl nmc = new NewtonianMovementControl();

            nmc.Speed = me.SceneMgr.GetCurrentPlayer().Data.MineFallingSpeed;
            ast.AddControl(nmc);

            NetOutgoingMessage msg = me.SceneMgr.CreateNetMessage();

            ast.WriteObject(msg);

            me.SceneMgr.SendMessage(msg);
        }
        private void CreateHighlighter()
        {
            if (highlighter == null)
            {
                if (me is Sphere)
                {
                    highlighter                    = new HighlightingSphere(me.SceneMgr, IdMgr.GetNewId(me.SceneMgr.GetCurrentPlayer().GetId()));
                    highlighter.Position           = me.Position;
                    (highlighter as Sphere).Radius = (me as Sphere).Radius + 10;
                    (highlighter as Sphere).Color  = (me as Sphere).Color;
                    Color border = (me as Sphere).Color;
                    Color center = (me as Sphere).Color;
                    border.A = 0x0;
                    center.A = 0xAA;

                    if (IsCircle)
                    {
                        highlighter.SetGeometry(SceneGeometryFactory.CreateRadialGradientEllipseGeometry(
                                                    me.SceneMgr, (highlighter as Sphere).Radius, Colors.Transparent, Colors.Transparent, (me as Sphere).Color, me.Position, 1));
                    }
                    else
                    {
                        highlighter.SetGeometry(SceneGeometryFactory.CreateRadialGradientEllipseGeometry(
                                                    me.SceneMgr, (highlighter as Sphere).Radius, border, center, Colors.Transparent, me.Position, 1));
                    }

                    highlighter.AddControl(new CenterCloneControl(me));

                    highlighter.Visible = false;

                    me.SceneMgr.DelayedAttachToScene(highlighter);
                }
                else
                {
                    throw new NotSupportedException("Highlighting control supports only Sphere parent object yet");
                }
            }
        }