Ejemplo n.º 1
0
        public Game()
        {
            world = new World();
            user = new User();
            networkManager = new ClientNetworkManager(world, user);

            _graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }
Ejemplo n.º 2
0
        public Game()
        {
            world = new World();
            user = new User();
            networkManager = new ClientNetworkManager(world, user);
            worldView = new WorldView(world, user);
            userController = new UserController(user, networkManager);
            networkManager.UserController = userController;

            _graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }
        public ServerNetworkManager(World world, UserManager userManager)
        {
            packetSerializer = new PacketSerializer();
            this.world = world;
            this.userManager = userManager;
            context = GlobalHost.ConnectionManager.GetHubContext<ServerHub>();

            // Setup the synchronization timer
            syncTimer = new Timer(1000 / syncsPerSecond);
            syncTimer.AutoReset = true;
            syncTimer.Elapsed += Sync;
        }
Ejemplo n.º 4
0
        public Ship(World world)
        {
            Movement = new ShipMovement(this);
            Health = new ShipHealth();
            Weapons = new ShipWeapons(this, world);

            Actions = new Dictionary<Action, bool>();
            Actions.Add(Action.TurnLeft, false);
            Actions.Add(Action.TurnRight, false);
            Actions.Add(Action.ThrustForward, false);
            Actions.Add(Action.ThrustBackward, false);
            Actions.Add(Action.Fire, false);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructs the game
        /// </summary>
        public Game()
        {
            world = new World();

            updateTimer = new Timer(1000 / updatesPerSecond);
            updateTimer.AutoReset = true;
            updateTimer.Elapsed += Update;

            previousUpdateTime = DateTime.Now;

            UserManager = new UserManager(world.ShipManager);

            networkManager = new ServerNetworkManager(world, UserManager);

            Initialize();
        }
        public object[] Serialize(World world, User user)
        {
            // Serialize the ships
            List<object> serializedShips = new List<object>();

            foreach (Ship ship in world.ShipManager.Ships.Values)
            {
                object[] serializedShip = Serialize(ship);
                serializedShips.Add(serializedShip);
            }

            // Serialize the bullets
            List<object> serializedBullets = new List<object>();

            lock (world.BulletManager.Bullets)
            {
                List<Bullet> bullets = new List<Bullet>(world.BulletManager.Bullets);

                foreach (Bullet bullet in bullets)
                {
                    object[] seriealizedBullet = Serialize(bullet);
                    serializedBullets.Add(seriealizedBullet);
                }
            }

            // Serialize the bots
            List<object> serializedBots = new List<object>();

            foreach (Bot bot in world.BotManager.Bots)
            {
                object[] serializedBot = Serialize(bot);
                serializedBots.Add(serializedBot);
            }

            // Serialize the world
            object[] serializedWorld = new object[4];

            serializedWorld[0] = serializedShips;
            serializedWorld[1] = serializedBullets;
            serializedWorld[2] = serializedBots;
            serializedWorld[3] = user.LatestCommandId;

            return serializedWorld;
        }
        /// <summary>
        /// Constructs the client network manager
        /// </summary>
        public ClientNetworkManager(World world, User user)
        {
            // Construct the connection to the hub
            #if DEBUG
            connection = new HubConnection("http://localhost:29058");
            #else
            connection = new HubConnection("http://vectorarena.cloudapp.net");
            #endif

            // Construct the proxy to the hub
            proxy = connection.CreateHubProxy("ServerHub");

            // Setup the packet deserializer
            packetDeserializer = new PacketDeserializer();

            // Set the world context
            this.world = world;

            this.user = user;
        }
 /// <summary>
 /// Constructs the world display
 /// </summary>
 /// <param name="world"></param>
 /// <param name="user"></param>
 public WorldView(World world, User user)
 {
     this.world = world;
     this.user = user;
     starfield = new Starfield(World.Width, World.Height);
     grid = new Grid(World.Width, World.Height);
     shipView = new ShipView();
 }
 public ShipWeapons(Ship ship, World world)
 {
     this.ship = ship;
     this.world = world;
     lastBulletFired = DateTime.Now;
 }
        public ShipManager(World world)
        {
            Ships = new Dictionary<int, Ship>();

            this.world = world;
        }