Esempio n. 1
0
        private float DistanceSquaredBetweenLocations(Location loc1, Location loc2)
        {
            float horizontalDistance = (loc1.MapPosition.X - loc2.MapPosition.X);
            float verticalDistance = (loc1.MapPosition.Y - loc2.MapPosition.Y);

            return (horizontalDistance * horizontalDistance) + (verticalDistance * verticalDistance);
        }
Esempio n. 2
0
 public ExploreControl(Location currentLocation, MainWindow mainWindow)
 {
     InitializeComponent();
     this.mainWindow = mainWindow;
     encounterButtons = new List<Button>();
     UpdateLocation(currentLocation);
     UINotifier.Get().OnLocationUpdated += UpdateLocation;
 }
Esempio n. 3
0
        internal Monster GetEnemyForLocation(Location location)
        {
            MonsterData monster;
            if (!monstersByAreaType.ContainsKey(location.CurrentAreaType))
            {
                bool x = monstersByAreaType.Keys.First() == location.CurrentAreaType;
                Game.PrintMessage(LogLevel.DEBUG, "No monsters for area type: " + location.CurrentAreaType.Type + location.CurrentAreaType.Level.ToString() + ". Selecting from full monster list");
                monster = monsters[Game.GetRandom(monsters.Count)];
            }
            else
            {
                Game.PrintMessage(LogLevel.DEBUG, "Getting an area specific monster for area type: " + location.CurrentAreaType.Type + location.CurrentAreaType.Level.ToString());
                monster = monstersByAreaType[location.CurrentAreaType][Game.GetRandom(monstersByAreaType[location.CurrentAreaType].Count)];
            }

            return new Monster(Game, monster);
        }
Esempio n. 4
0
 public void UpdateLocation(Location location)
 {
     currentLocation = location;
     foreach (Button button in encounterButtons)
     {
         this.Controls.Remove(button);
         button.Dispose();
     }
     encounterButtons.Clear();
     int height = 63;
     foreach (IEncounter encounter in currentLocation.Encounters)
     {
         CustomButton button = new CustomButton() { AutoSize = true, AutoSizeMode = AutoSizeMode.GrowOnly, Text = encounter.GetName(), Tag = encounter, Height = BUTTON_HEIGHT };
         this.Controls.Add(button);
         button.Location = new Point((this.Width - button.Width) / 2, height);
         button.Click += revisit_Click;
         encounterButtons.Add(button);
         height += BUTTON_HEIGHT + PADDING;
     }
 }
Esempio n. 5
0
 private void UpdateCurrentLocation(Location location)
 {
     mapPicture.Image = baseMap.Clone() as Image;
     using (Graphics G = Graphics.FromImage(mapPicture.Image))
     {
         G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
         G.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
         Image player = game.Player.GetCurrentPicture();
         G.DrawImage(player,location.MapPosition.X, location.MapPosition.Y, (float)0.5*player.Width, (float)0.5*player.Height);
     }
 }
Esempio n. 6
0
 private Tuple<Point, Point> GetDirectConnectionLine(Location loc1, Location loc2)
 {
     Point center1 = new Point(loc1.TopLeft.X + (LOCATION_SIZE / 2), loc1.TopLeft.Y + (LOCATION_SIZE / 2));
     Point center2 = new Point(loc2.TopLeft.X + (LOCATION_SIZE / 2), loc2.TopLeft.Y + (LOCATION_SIZE / 2));
     return new Tuple<Point, Point>(center1, center2);
 }
Esempio n. 7
0
        private Location GetClosestUnconnectedLocation(Location currLoc, List<Tuple<Location, Location>> connectedLocs)
        {
            Location closestUnconnected = null;
            float minDistanceSqr = 999999999;
            foreach(Location otherLoc in locations)
            {
                if (otherLoc == currLoc) continue;
                if (connectedLocs.Contains(new Tuple<Location, Location>(currLoc, otherLoc)) ||
                    connectedLocs.Contains(new Tuple<Location, Location>(otherLoc, currLoc))) continue;
                float dist = DistanceSquaredBetweenLocations(currLoc, otherLoc);
                if (dist < minDistanceSqr)
                {
                    closestUnconnected = otherLoc;
                    minDistanceSqr = dist;
                }

            }
            return closestUnconnected;
        }
Esempio n. 8
0
 public void TravelTo(Location location)
 {
     if (CurrentLocation == location)
         return;
     if (CurrentLocation != null)
         CurrentLocation.Leave();
     CurrentLocation = location;
     UINotifier.Get().NotifyLocationUpdated(location);
     PrintMessage(LogLevel.INFO, "You've arrived at " + location.FullName);
 }
Esempio n. 9
0
 public void NotifyLocationUpdated(Location location)
 {
     OnLocationUpdated?.Invoke(location);
 }