public RouteManager(Texture2D markerText, Texture2D lineText, int screenWidth, int screenHeight, Simulation sim, CityManager cityManager = null)
        {
            mScreenWidth       = screenWidth;
            mScreenHeight      = screenHeight;
            mXResolutionScaler = (float)screenWidth / 800f;
            mYResolutionScaler = (float)screenHeight / 600f;
            mMapWidth          = (int)(mScreenWidth * 0.75f);
            mMarkerTexture     = markerText;
            mLineTexture       = lineText;
            rnd = new Random();
            mUnassignedRoutes = new List <Route>();
            mAssignedRoutes   = new List <Route>();
            this.cityManager  = cityManager;
            mPortLocation     = new Vector2(mScreenWidth / 12, mScreenHeight / 2);
            simulation        = sim;

            for (int i = 0; i < 50; i++)
            {
                if (simulation == Simulation.UK)
                {
                    mUnassignedRoutes.Add(generateRealisticRoute());
                }
                if (simulation == Simulation.Boat)
                {
                    mUnassignedRoutes.Add(generateRouteForBoatSim());
                }
            }
            //For testing purposes only---
            //mUnassignedRoutes.Add(new Route(mMarkerTexture, mLineTexture, new Vector2(615, 488), new Vector2(727, 728)));
            //mUnassignedRoutes.Add(new Route(mMarkerTexture, mLineTexture, new Vector2(589, 522), new Vector2(727, 728)));
            //----------------------------
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            podTexture              = Content.Load <Texture2D>("LiliumJetRescaled");
            formationPodTexture     = Content.Load <Texture2D>("LiliumJetRescaled");
            destinationTexture      = Content.Load <Texture2D>("Destination");
            lineTexture             = Content.Load <Texture2D>("Line");
            cityTexture             = Content.Load <Texture2D>("City");
            collabCityTexture       = Content.Load <Texture2D>("CollabCity");
            UKBackground            = Content.Load <Texture2D>("BackgroundRescaled");
            UKBackgroundRectangle   = new Rectangle(0, 0, MAP_WIDTH, MAP_HEIGHT);
            boatBackground          = Content.Load <Texture2D>("BoatBackground");
            boatBackgroundRectangle = new Rectangle(0, 0, MAP_WIDTH, MAP_HEIGHT);
            skyBackground           = Content.Load <Texture2D>("SkyBackground");
            skyBackgroundRectangle  = new Rectangle((int)((float)SCREEN_WIDTH * 0.75f), (int)((float)SCREEN_HEIGHT / 3), 1000, 1000);
            cityPodTexture          = Content.Load <Texture2D>("PodWithoutWingsRecaled"); //I know this is spelt wrong I typo'ed on the image itself and its easier to just leave it
            backgroundPane          = Content.Load <Texture2D>("BackgroundPane");

            metricFont = Content.Load <SpriteFont>("Metric");

            formationManager = new FormationManager(formationPodTexture, new Vector2(SCREEN_WIDTH, SCREEN_HEIGHT));
            UKcityManager    = new CityManager(cityTexture, MAP_WIDTH, MAP_HEIGHT);
            UKrouteManager   = new RouteManager(destinationTexture, lineTexture, MAP_WIDTH, MAP_HEIGHT, Simulation.UK, UKcityManager);
            UKcityPodManager = new CityPodManager(podTexture, SCREEN_WIDTH, SCREEN_HEIGHT, new Vector2((SCREEN_WIDTH * 7) / 8, SCREEN_HEIGHT / 2), collabCityTexture, cityPodTexture);
            UKpodManager     = new PodManager(podTexture, destinationTexture, UKrouteManager, Vector2.Zero, UKKilometerToPixelMultiplier, UKHourToSecondMultiplier, UKcityPodManager, UKcityManager);
            UKmetricManager  = new MetricManager(UKpodManager, UKpixelReference, UKKilometerReference, metricFont, new Vector2(SCREEN_WIDTH * 0.75f, SCREEN_HEIGHT * 2 / 3));


            //boatCityManager = new CityManager(cityTexture, SCREEN_WIDTH, SCREEN_HEIGHT);
            boatRouteManager = new RouteManager(destinationTexture, lineTexture, SCREEN_WIDTH, SCREEN_HEIGHT, Simulation.Boat);
            //boatCityPodManager = new CityPodManager(podTexture, SCREEN_WIDTH, SCREEN_HEIGHT, new Vector2(1050, SCREEN_HEIGHT / 2), collabCityTexture);
            boatPodManager = new PodManager(podTexture, destinationTexture, boatRouteManager, new Vector2(0, SCREEN_HEIGHT / 2), boatKilometerToPixelMultiplier, boatHourToSecondMultiplier);
        }
Example #3
0
 public Pod(Texture2D texture, Texture2D markerTexture, Vector2 initialPosition, CityManager cityManager, int randomSeed, int podId, float distMulti, float timeMulti, CityPodManager cityPodManager) : base(texture, initialPosition)
 {
     id              = podId;
     rnd             = new Random(randomSeed);
     mStartLocation  = initialPosition;
     maxVelocity     = 1;
     mGoal           = initialPosition;
     mCityManager    = cityManager;
     mCityPodManager = cityPodManager;
     maxDistance     = 300 / mDistMulti;
     VELOCITY        = 300 * distMulti / timeMulti;
     mDistMulti      = distMulti;
     mRechargeRate   = 300 / timeMulti;
     try
     {
         mLondonLocation = cityManager.findLondon();
     }
     catch (NullReferenceException)
     {
         mLondonLocation = Vector2.Zero;
     }
 }
Example #4
0
        public PodManager(Texture2D podText, Texture2D destinationText, RouteManager routeManager, Vector2 startLocation, float distMulti, float timeMulti, CityPodManager cityPodManager = null, CityManager cityManager = null)
        {
            mPodTexture         = podText;
            mDestinationTexture = destinationText;
            mCityManager        = cityManager;

            mPods     = new List <Pod>();
            mFreePods = new List <Pod>();

            mRouteManager  = routeManager;
            mCityPodManger = cityPodManager;

            mDistMulti = distMulti;
            mTimeMulti = timeMulti;
            //For testing purposes only---
            //mPods.Add(new Pod(mPodTexture, mDestinationTexture, new Vector2(615, 488), routeManager.CityManager, rnd.Next(), currentId++));
            //mPods.Add(new Pod(mPodTexture, mDestinationTexture, new Vector2(589, 522), routeManager.CityManager, rnd.Next(), currentId++));
            //----------------------------

            //establish some number of pods
            if (mCityPodManger != null)
            {
                mCreatingSkeins = false;
                for (int i = 0; i < initialNumberOfPods; i++)
                {
                    mPods.Add(new Pod(mPodTexture, mDestinationTexture, mCityManager.Cities[rnd.Next(mCityManager.Cities.Count)].Position, routeManager.CityManager, rnd.Next(), currentId++, mDistMulti, mTimeMulti, cityPodManager));
                }
            }
            else
            {
                mCreatingSkeins = true;
                for (int i = 0; i < initialNumberOfPods; i++)
                {
                    mPods.Add(new Pod(mPodTexture, mDestinationTexture, mRouteManager.PortLocation, routeManager.CityManager, rnd.Next(), currentId++, mDistMulti, mTimeMulti, cityPodManager));
                }
            }
        }