Ejemplo n.º 1
0
        public void ModelFacade_MoveToLocation()
        {
            LocationModel workingLM = gs.GetLM();

            Assert.AreEqual(locations[18].ParseToString(), workingLM.GetCurentLocation().ParseToString(), "Location should be location 19");
            Assert.IsTrue(mf.ChangeLocation(gs, 20), "Moving to 20 should be successful");
            Assert.AreEqual(locations[19].ParseToString(), workingLM.GetCurentLocation().ParseToString(), "Location should now be location 20");
            Assert.IsFalse(mf.ChangeLocation(gs, 20), "Moving to 20 should be unsuccessful");
            Assert.AreEqual(locations[19].ParseToString(), workingLM.GetCurentLocation().ParseToString(), "Location should still be location 20");
            Assert.IsTrue(mf.ChangeLocation(gs, 21), "Moving to 21 should be successful");
            Assert.AreEqual(21, workingLM.GetCurentLocation().GetLocationID(), "Location should now be location 21");
        }
Ejemplo n.º 2
0
        public void LocationModel_InitializeLM()
        {
            lm = new LocationModel();
            lm.InitializeLocationModel(1024);

            Assert.IsTrue(lm.GetCurentLocation().GetLocationID() == 0, "Start location should be 0");
            Assert.IsTrue(lm.GetVisited().Count == 1, "Only one visited location");
        }
Ejemplo n.º 3
0
        public void LocationModel_MoveToLocation()
        {
            LocationModel temp  = new LocationModel(1024);
            Location      start = temp.GetCurentLocation();
            Location      curr  = temp.GetCurentLocation();
            Location      expected;
            SortedList <int, DummyLocation> unvisited = temp.GetUnvisited();
            SortedList <int, Location>      visited   = temp.GetVisited();

            Assert.AreSame(start, curr, "Start and current should be the same");

            Assert.IsTrue(temp.LocationVisited(0), "Start should be visisted");
            Assert.IsFalse(temp.LocationVisited(1), "Location 1 should be unvisisted");


            //Assert.IsFalse(temp.MoveToVisitedLocation(1), "Move should be unsuccessful as location is unvisited");
            //Assert.IsTrue(temp.MoveToUnvisitedLocation(1), "Move should be successful");
            Assert.IsTrue(temp.MoveToLocation(1), "Move should be successful");
            curr = temp.GetCurentLocation();
            visited.TryGetValue(1, out expected);

            Assert.IsTrue(temp.LocationVisited(0), "Start should be visisted");
            Assert.IsTrue(temp.LocationVisited(1), "Location 1 should be visisted");

            Assert.AreEqual(1, curr.GetLocationID(), "Current location should now be 1");
            Assert.IsTrue(curr.GetVisited(), "Location should be visited");
            Assert.IsNull(temp.GetSubLocation(), "Sublocation should be null");
            Assert.AreNotSame(start, curr, "Start and current should not be the same");
            Assert.AreSame(expected, curr, "Should be at the expected location");
            Assert.IsFalse(temp.MoveToLocation(1), "Move should be unsuccessful");
            Assert.IsFalse(temp.MoveToLocation(-1), "Move should be unsuccessful");

            Assert.IsFalse(temp.MoveToLocation(20000), "Move should be unsuccessful");

            Assert.IsTrue(temp.MoveToLocation(0), "Move should be successful");
            //Assert.IsFalse(temp.MoveToUnvisitedLocation(0), "Move should be unsuccessful as location has been visited");
            //curr = temp.GetCurentLocation();
            //Assert.AreNotSame(start, curr, "Start and current should not be the same");
            //Assert.AreSame(expected, curr, "Should be at the expected location");

            //Assert.IsTrue(temp.MoveToVisitedLocation(0), "Move should be successful");
            curr = temp.GetCurentLocation();
            Assert.AreSame(start, curr, "Start and current should be the same");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets a list of current sublocations
        /// </summary>
        /// <param name="gs">The current gamestate</param>
        /// <returns>All sublocations at this location</returns>
        public List <Sublocation> GetCurrentSublocations(GameState gs)
        {
            LocationModel      lm           = gs.GetLM();
            var                subs         = lm.GetCurentLocation().GetSublocations().Values;
            List <Sublocation> sublocations = new List <Sublocation>();

            foreach (Sublocation sub in subs)
            {
                sublocations.Add(sub);
            }

            return(sublocations);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Calculates the movement cost
        /// </summary>
        /// <param name="gs"></param>
        /// <param name="locationID"></param>
        /// <returns></returns>
        public double CalculateMoveCost(GameState gs, int locationID)
        {
            LocationModel lm          = gs.GetLM();
            int           current     = lm.GetCurentLocation().GetLocationID();
            var           buttonAreas = lm.GetButtonAreas();

            System.Windows.Point source;
            System.Windows.Point target;
            if (buttonAreas.TryGetValue(current, out source) && buttonAreas.TryGetValue(locationID, out target))
            {
                double xDistance = source.X - target.X;
                double yDistance = source.Y - target.Y;
                double distance  = Math.Sqrt(xDistance * xDistance + yDistance * yDistance);

                return(distance / 5);
            }

            return(0);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Draw location details
        /// </summary>
        public void DrawLocations()
        {
            GameState     gs = mc.GetGameState();
            LocationModel lm = gs.GetLM();

            String curr        = lm.ParseCurrLocationToString();
            String currS       = lm.ParseCurrSubLocToString();
            String connections = "";
            String subloc      = "";


            var subs = lm.GetCurentLocation().GetSublocations();

            foreach (Sublocation sub in subs.Values)
            {
                subloc += sub.GetSublocationID() + ", ";
            }

            IList <Location>      visited   = lm.GetVisited().Values;
            IList <DummyLocation> unvisited = lm.GetUnvisited().Values;

            List <String> vis   = new List <string>();
            List <String> unvis = new List <string>();

            foreach (Location lc in visited)
            {
                vis.Add(lc.ParseToString());
            }

            foreach (DummyLocation dl in unvisited)
            {
                unvis.Add(dl.ParseToString());
            }
            currentLocLbl.Content = curr;
            currentSubLbl.Content = currS;
            currentConLbl.Content = connections;
            availSubLbl.Content   = subloc;

            visitedLB.ItemsSource   = vis;
            unvisitedLB.ItemsSource = unvis;
        }
Ejemplo n.º 7
0
        public int GetCurrentLocation(GameState gs)
        {
            LocationModel lm = gs.GetLM();

            return(lm.GetCurentLocation().GetLocationID());
        }