Esempio n. 1
0
        /// <summary>
        /// Internal method that creates and adds a new player to the underlying scenario.
        /// The index and the start location of the created player are determined manually.
        /// </summary>
        /// <param name="race">The race of the created player.</param>
        /// <param name="index">The index of the created player.</param>
        /// <param name="startLocation">The start location of the created player.</param>
        private Player CreatePlayerManually(RaceEnum race, PlayerEnum index, StartLocation startLocation)
        {
            if (index == PlayerEnum.Neutral)
            {
                throw new ArgumentException("index cannot be PlayerEnum.Neutral!", "index");
            }
            if (startLocation == null)
            {
                throw new ArgumentNullException("startLocation");
            }
            if (startLocation.Scenario != this.targetScenario)
            {
                throw new ArgumentException("The given start location belongs to another scenario!", "startLocation");
            }

            /// Check if the incoming player index and start location are not assigned to another player slot.
            if (!this.freePlayerIndices.Contains(index))
            {
                throw new InvalidOperationException("The given player index has already been assigned to another slot!");
            }
            if (!this.freeStartLocations.Contains(startLocation))
            {
                throw new InvalidOperationException("The given start location has already been assigned to another slot!");
            }

            /// Create and add the new player to the target scenario.
            this.targetScenario.InitializePlayer((int)index, startLocation, race);
            Player createdPlayer = this.targetScenario.GetPlayer((int)index);

            /// Remove the determined player index and start location from the appropriate sets.
            this.freePlayerIndices.Remove(index);
            this.freeStartLocations.Remove(startLocation);
            return(createdPlayer);
        }
        private void FindAllRoutesCommandExecuted(MapView mapView)
        {
            DCGraph.ResetGraph();
            //Remove old route graphics
            RemoveRouteGraphics(mapView);
            var dijkstraApproxBucket = new DijkstraApproximateBucketPathFinder(DCGraph);

            var startVertex       = dijkstraApproxBucket.FindClosestVertex(StartLocation.ToCoordinates());
            var endVertex         = dijkstraApproxBucket.FindClosestVertex(EndLocation.ToCoordinates());
            var dijkstaKArrayHeap = new DijkstraMinHeapPathFinder(DCGraph);
            var dikstraList       = new DijkstraPathFinder(DCGraph);

            var astarList         = new AStarPathFinder(DCGraph);
            var astarApproxBucket = new AStarApproximateBucketPathFinder(DCGraph);
            var astarKarrayHeap   = new AStarMinHeapPathFinder(DCGraph);


            AStarKArrayHeapRunningTime = GetRunningTime(astarKarrayHeap, startVertex, endVertex, mapView);
            DCGraph.ResetGraph();
            AStarApproximateBucketRunningTime = GetRunningTime(astarApproxBucket, startVertex, endVertex, mapView);
            DCGraph.ResetGraph();
            AStarListRunningTime = GetRunningTime(astarList, startVertex, endVertex, mapView);
            DCGraph.ResetGraph();

            DijkstraApproximateBucketRunningTime = GetRunningTime(dijkstraApproxBucket, startVertex, endVertex, mapView);
            DCGraph.ResetGraph();
            DijkstraListRunningTime = GetRunningTime(dikstraList, startVertex, endVertex, mapView);
            DCGraph.ResetGraph();
            DijkstraKArrayHeapRunningTime = GetRunningTime(dijkstaKArrayHeap, startVertex, endVertex, mapView);
            DCGraph.ResetGraph();
        }
        private async void DestinationRedio_Click(object sender, System.EventArgs e)
        {
            if (Destinationtext.Text == "")
            {
                Toast.MakeText(this, "Please Add Destination ", ToastLength.Short).Show();
                DestinationRedio.Checked = false;
                return;
            }

            addressRequest           = 2;
            pickupRedio.Checked      = true;
            DestinationRedio.Checked = true;
            CenterMarker.SetColorFilter(Color.Red);


            StartLocation Destination_latlongs = await GetAddressOnMap.GetlatLongbyTextAddress(" مصر " + Destinationtext.Text);

            DestinationLocation = new LatLng(Destination_latlongs.lat, Destination_latlongs.lng);
            mainMap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(DestinationLocation, 14));

            // get Address
            //Address address = await ReverseGeocodeCurrentLocation(DestinationLocation);
            //DisplayAddress(address);
            //Destinationtext.Text = _addressText;

            TripLocationSt();
            // Hide Bottom Sheet
            tripDetailsBottomsheetbehavior.State = BottomSheetBehavior.StateHidden;
        }
Esempio n. 4
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((StartLocation.GetHashCode() * 397) ^ EndLocation.GetHashCode());
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Saves the dungeon
        /// </summary>
        /// <param name="writer">XmlWriter handle</param>
        /// <returns>True if saved</returns>
        public bool Save(XmlWriter writer)
        {
            if (writer == null)
            {
                return(false);
            }

            writer.WriteStartElement(Tag);
            writer.WriteAttributeString("name", Name);


            writer.WriteStartElement(Item.Tag);
            writer.WriteAttributeString("tileset", ItemTileSetName);
            writer.WriteEndElement();

            foreach (Maze maze in MazeList)
            {
                maze.Save(writer);
            }

            StartLocation.Save("start", writer);

            writer.WriteStartElement("note");
            writer.WriteString(Note);
            writer.WriteEndElement();

            writer.WriteEndElement();

            return(true);
        }
 // Use this for initialization
 void Start()
 {
     this.txt                = this.GetComponent <Text> ();
     this.tutorial           = this.txt.text;
     this.txt.text           = "";
     this.startTimerLocation = (StartLocation)this.GetComponentInChildren <StartLocation> ();
     this.skipTextLocation   = (EndLocation)this.GetComponentInChildren <EndLocation> ();
 }
Esempio n. 7
0
        /// <see cref="IPlayerSlot.ConnectPlayer"/>
        public void ConnectPlayer(RaceEnum race, PlayerEnum index, StartLocation startLocation)
        {
            Player player = this.manualConnector(race, index, startLocation);

            this.state  = PlayerSlotStateEnum.Connected;
            this.race   = race;
            this.player = player;
        }
Esempio n. 8
0
        protected override BaseShape CreateAccessibleAreaCore()
        {
            if (StartLocation == null)
            {
                return(null);
            }

            return(StartLocation.Buffer(Distance, 40, GeographyUnit, DistanceUnit));
        }
 public override int GetHashCode()
 {
     unchecked {
         int hash = 23;
         hash = hash * 37 + Text.GetHashCode();
         hash = hash * 37 + StartLocation.GetHashCode();
         hash = hash * 37 + EndLocation.GetHashCode();
         return(hash);
     }
 }
Esempio n. 10
0
 public override bool Equals(object obj)
 {
     if (obj is Lock)
     {
         Lock lock2 = obj as Lock;
         return(StartLocation.Equals(lock2.StartLocation) &&
                EndLocation.Equals(lock2.EndLocation));
     }
     return(false);
 }
Esempio n. 11
0
 private void CalculateDistanceInNauticalMiles()
 {
     if (StartLocation == null || EndLocation == null)
     {
         Distance = null;
     }
     else
     {
         Distance = Length.FromMeters(StartLocation.GreatCircleDistance(EndLocation)).NauticalMiles;
     }
 }
Esempio n. 12
0
 public int CompareTo(GrepMatch other)
 {
     if (other == null)
     {
         return(1);
     }
     else
     {
         return(StartLocation.CompareTo(other.StartLocation));
     }
 }
Esempio n. 13
0
 public override int GetHashCode()
 {
     unchecked {
         int hash = 23;
         hash = hash * 37 + Index.GetHashCode();
         hash = hash * 37 + Alignment.GetHashCode();
         hash = hash * 37 + FormatString.GetHashCode();
         hash = hash * 37 + StartLocation.GetHashCode();
         hash = hash * 37 + EndLocation.GetHashCode();
         return(hash);
     }
 }
 protected virtual void SpawnPlayers()
 {
     foreach (Player player in GM.GameInstance.Players)
     {
         StartLocation startLocation  = GetStartLocation();
         GameObject    pawnGameObject = Instantiate(DefaultPawn, startLocation.transform.position, Quaternion.identity);
         PlayerPawn    pawn           = pawnGameObject.GetComponent <PlayerPawn>();
         player.SetPawn(pawn);
         pawn.SetPlayerParent(player);
         pawn.SetInitialDirection(startLocation.transform.rotation);
     }
 }
Esempio n. 15
0
        /// <see cref="IMapEditorService.PlaceStartLocation"/>
        public bool PlaceStartLocation(RCIntVector position, int playerIndex)
        {
            if (this.scenarioManager.ActiveScenario == null)
            {
                throw new InvalidOperationException("No active scenario!");
            }
            if (position == RCIntVector.Undefined)
            {
                throw new ArgumentNullException("position");
            }

            RCIntVector navCellCoords = this.mapWindowBC.AttachedWindow.WindowToMapCoords(position).Round();
            IQuadTile   quadTileAtPos = this.scenarioManager.ActiveScenario.Map.GetCell(navCellCoords).ParentQuadTile;

            IScenarioElementType objectType        = this.scenarioManager.Metadata.GetElementType(StartLocation.STARTLOCATION_TYPE_NAME);
            RCIntVector          objQuadSize       = this.scenarioManager.ActiveScenario.Map.CellToQuadSize(objectType.Area.Read().Size);
            RCIntVector          topLeftQuadCoords = quadTileAtPos.MapCoords - objQuadSize / 2;

            if (objectType.CheckPlacementConstraints(this.scenarioManager.ActiveScenario, topLeftQuadCoords, new RCSet <Entity>()).Count != 0)
            {
                return(false);
            }

            /// Check if a start location with the given player index already exists.
            RCSet <StartLocation> startLocations = this.scenarioManager.ActiveScenario.GetAllElements <StartLocation>();
            StartLocation         startLocation  = null;

            foreach (StartLocation sl in startLocations)
            {
                if (sl.PlayerIndex == playerIndex)
                {
                    startLocation = sl;
                    break;
                }
            }

            /// If a start location with the given player index already exists, change its quadratic coordinates,
            /// otherwise create a new start location.
            if (startLocation != null)
            {
                startLocation.DetachFromMap();
            }
            else
            {
                startLocation = new StartLocation(playerIndex);
                this.scenarioManager.ActiveScenario.AddElementToScenario(startLocation);
            }
            startLocation.AttachToMap(this.scenarioManager.ActiveScenario.Map.GetQuadTile(topLeftQuadCoords));
            return(true);
        }
Esempio n. 16
0
        public MainPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;

            PushPins = new List<PushPin>();

            PushPin = new PushPin();

            StartLocation = new StartLocation();

            //MyMapControl.Center = "50.6683,17.9230";
            //MyMapControl.Center.Position.Longitude = 50.6683
        }
Esempio n. 17
0
 public int CompareTo(object obj)
 {
     if (obj == null)
     {
         return(1);
     }
     if (obj is GrepMatch)
     {
         return(StartLocation.CompareTo(((GrepMatch)obj).StartLocation));
     }
     else
     {
         return(1);
     }
 }
Esempio n. 18
0
        public override XmlElement ToXml(XmlDocument doc)
        {
            var root = base.ToXml(doc);

            var startLocation = StartLocation.ToXml(doc, "StartLocation");

            startLocation.SetAttribute("equals", EqualsStartLocation.ToString());
            root.AppendChild(startLocation);

            var endLocation = EndLocation.ToXml(doc, "EndLocation");

            endLocation.SetAttribute("equals", EqualsEndLocation.ToString());
            root.AppendChild(endLocation);

            return(root);
        }
        private void AStarCommandExecuted(MapView mapView)
        {
            var   dpf        = new AStarApproximateBucketPathFinder(DCGraph);
            float pathlength = 0;
            var   path       = dpf.FindShortestPath(dpf.FindClosestVertex(StartLocation.ToCoordinates()),
                                                    dpf.FindClosestVertex(EndLocation.ToCoordinates()),
                                                    ref pathlength);

            if (path != null && path.Count > 0)
            {
                DisplayPath(path, mapView);
            }
            else
            {
                MessageBox.Show("No Route Found!");
            }
            DCGraph.ResetGraph();
        }
        private async void PickupRedio_Click(object sender, System.EventArgs e)
        {
            addressRequest           = 1;
            pickupRedio.Checked      = true;
            DestinationRedio.Checked = false;
            CenterMarker.SetColorFilter(Color.DarkGreen);
            // my home
            //PickupLocation = new LatLng(29.983685, 31.155421);
            StartLocation Pickup_latlongs = await GetAddressOnMap.GetlatLongbyTextAddress(" مصر " + PickUpLocationtext.Text);

            PickupLocation = new LatLng(Pickup_latlongs.lat, Pickup_latlongs.lng);

            mainMap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(PickupLocation, 14));

            // Hide Bottom Sheet
            tripDetailsBottomsheetbehavior.State = BottomSheetBehavior.StateHidden;

            // get Address
            //Address address = await ReverseGeocodeCurrentLocation(PickupLocation);
            //DisplayAddress(address);
            //PickUpLocationtext.Text = _addressText;
        }
Esempio n. 21
0
        /// <summary>
        /// Gets the last known owner of the given map object.
        /// </summary>
        /// <param name="mapObject">Reference to the map object.</param>
        /// <returns>The last known owner of the given map object or PlayerEnum.Neutral if the map object hasn't had owner yet.</returns>
        public static PlayerEnum GetMapObjectLastOwner(MapObject mapObject)
        {
            Entity entity = mapObject.Owner as Entity;

            if (entity != null)
            {
                StartLocation entityAsStartLoc = entity as StartLocation;
                PlayerEnum    owner            = entityAsStartLoc != null
                    ? (PlayerEnum)entityAsStartLoc.PlayerIndex
                    : (PlayerEnum)entity.LastOwnerIndex;
                return(owner);
            }

            EntityWreck entityWreck = mapObject.Owner as EntityWreck;

            if (entityWreck != null)
            {
                return((PlayerEnum)entityWreck.PlayerIndex);
            }

            return(PlayerEnum.Neutral);
        }
Esempio n. 22
0
        /// <summary>
        /// Internal method that creates and adds a new player to the target scenario.
        /// The index and the start location of the created player are determined randomly.
        /// </summary>
        /// <param name="race">The race of the created player.</param>
        /// <returns>The index and the start location of the created player.</returns>
        private Player CreatePlayerRandomly(RaceEnum race)
        {
            if (this.freePlayerIndices.Count == 0)
            {
                throw new InvalidOperationException("No more free player indices!");
            }
            if (this.freeStartLocations.Count == 0)
            {
                throw new InvalidOperationException("No more free start locations!");
            }

            /// Determine the player index and start location randomly.
            PlayerEnum    index         = this.freePlayerIndices.ElementAt(RandomService.DefaultGenerator.Next(this.freePlayerIndices.Count));
            StartLocation startLocation = this.freeStartLocations.ElementAt(RandomService.DefaultGenerator.Next(this.freeStartLocations.Count));

            /// Create and add the new player to the target scenario.
            this.targetScenario.InitializePlayer((int)index, startLocation, race);
            Player createdPlayer = this.targetScenario.GetPlayer((int)index);

            /// Remove the determined player index and start location from the appropriate sets.
            this.freePlayerIndices.Remove(index);
            this.freeStartLocations.Remove(startLocation);
            return(createdPlayer);
        }
Esempio n. 23
0
    // Pretty Solid
    void DetermineTeamPositions()
    {
        int amountPositions = System.Enum.GetNames(typeof(StartLocation)).Length;
        int greenSector     = UnityEngine.Random.Range(0, amountPositions);
        int redSector       = 0;

        if (greenSector < 4)
        {
            redSector = greenSector + UnityEngine.Random.Range(2, 3);
        }
        if (greenSector > 3)
        {
            redSector = greenSector - UnityEngine.Random.Range(2, 3);
        }

        greenStart = (StartLocation)greenSector;
        redStart   = (StartLocation)redSector;
        //Debug.Log("Green sector: " + greenSector + "Red sector: " + redSector);

        greenPosition = DetermineCoordinates(greenStart);
        redPosition   = DetermineCoordinates(redStart);

        //Debug.Log("Green coord: " + greenPosition + "Red sector" + redPosition);
    }
Esempio n. 24
0
        public static bool TryLoad(string fileName)
        {
            XmlDocument doc;

            try
            {
                FileStream stream = File.OpenRead(fileName);
                doc = new XmlDocument();
                doc.Load(stream);
                stream.Dispose();
            }
            catch (Exception e)
            {
                MessageBox.Show("Error loading file: " + e);
                return(false);
            }

            try
            {
                xmlILPs = new List <ILP>();
                foreach (XmlNode node in doc.SelectNodes("randomizer/ilp"))
                {
                    string item     = null;
                    string location = null;
                    int    cost     = 0;
                    string costType = null;
                    foreach (XmlNode child in node.ChildNodes)
                    {
                        switch (child.Name)
                        {
                        case "item":
                            item = child.InnerText;
                            break;

                        case "location":
                            location = child.InnerText;
                            break;

                        case "cost":
                            cost = Int32.Parse(child.InnerText);
                            break;

                        case "costType":
                            costType = child.InnerText;
                            break;
                        }
                    }
                    if (string.IsNullOrEmpty(item) || string.IsNullOrEmpty(location))
                    {
                        continue;
                    }
                    xmlILPs.Add(new ILP(item, location, cost, costType));
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error reading placement data. Xml load aborted: " + e);
                return(false);
            }

            try
            {
                xmlDefaultShopPreset = string.Empty;
                foreach (XmlNode node in doc.SelectNodes("randomizer/defaultShopItems"))
                {
                    xmlDefaultShopPreset = node.InnerText;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error reading shop data. Xml load aborted: " + e);
                return(false);
            }

            try
            {
                xmlTitle = string.Empty;
                foreach (XmlNode node in doc.SelectNodes("randomizer/title"))
                {
                    xmlTitle = node.InnerText;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error reading title. Xml load aborted: " + e);
                return(false);
            }

            try
            {
                if (doc.SelectSingleNode("randomizer/startSceneName") is XmlNode startSceneNode &&
                    doc.SelectSingleNode("randomizer/startX") is XmlNode startXNode &&
                    doc.SelectSingleNode("randomizer/startY") is XmlNode startYNode)
                {
                    xmlChangeStart   = true;
                    xmlStartLocation = new StartLocation
                    {
                        startSceneName = startSceneNode.InnerText,
                        startX         = float.Parse(startXNode.InnerText),
                        startY         = float.Parse(startYNode.InnerText)
                    };
                }
                else
                {
                    xmlChangeStart = false;
                }
            }
Esempio n. 25
0
 public override void AddStartLocation(StartLocation sl)
 {
 }
Esempio n. 26
0
        /// <summary>
        /// Change location on character creation
        /// </summary>
        public static void CharacterCreation(DOLEvent ev, object sender, EventArgs args)
        {
            CharacterEventArgs chArgs = args as CharacterEventArgs;
            if (chArgs == null)
                return;
            DOLCharacters ch = chArgs.Character;
            try
            {
                StartLocation startLocation = null;
                GameClient client = chArgs.GameClient;
                StartupLocation dbStartupLocation = null;

                // do we have custom locations in the DB ?
                if (ServerProperties.Properties.USE_CUSTOM_START_LOCATIONS)
                {
                    // First try to find an ALL entry
                    var startupLocations = GameServer.Database.SelectObjects<StartupLocation>("ClassIDs = 'ALL'");
                    if (startupLocations.Count > 0)
                    {
                        dbStartupLocation = startupLocations[0];
                    }
                    else
                    {
                        // find realm-based SL
                        startupLocations = GameServer.Database.SelectObjects<StartupLocation>("ClassIDs LIKE '%" + GlobalConstants.RealmToName((eRealm)ch.Realm).Substring(0, 3) + "%'");
                        if (startupLocations.Count > 0)
                        {
                            dbStartupLocation = startupLocations[0];
                        }
                        else
                        {
                            // find class-based SL
                            startupLocations = GameServer.Database.SelectObjects<StartupLocation>("ClassIDs LIKE '%" + ch.Class + "%'");
                            foreach (var curSL in startupLocations)
                            {
                                foreach (var classID in curSL.ClassIDs.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
                                {
                                    int charClass = 0;
                                    int.TryParse(classID, out charClass);
                                    if (charClass == ch.Class)
                                    {
                                        dbStartupLocation = curSL;
                                        break;
                                    }
                                }
                                if (dbStartupLocation != null) break;
                            }
                        }
                    }

                    // fill loc with our found SL
                    if (dbStartupLocation != null)
                    {
                        startLocation = new StartLocation(dbStartupLocation.XPos, dbStartupLocation.YPos, dbStartupLocation.ZPos, dbStartupLocation.Heading);
                        ch.Region = dbStartupLocation.Region;
                    }
                }

                // no custom SL or custom SL not found
                if (dbStartupLocation == null)
                {
                    // tutorial all realms use the same region
                    // except if disabled in SP, v1.93+ start is in tutorial zone
                    if ((ch.Region == 27 || (int)client.Version >= (int)GameClient.eClientVersion.Version193) && !ServerProperties.Properties.DISABLE_TUTORIAL)
                    {
                        switch (ch.Realm)
                        {
                            case 1: // alb
                                startLocation = new StartLocation(97607, 92032, 5696, 446);
                                break;
                            case 2: // mid
                                startLocation = new StartLocation(226716, 232385, 5340, 1024);
                                break;
                            case 3: // hib
                                startLocation = new StartLocation(357788, 363457, 5340, 1024);
                                break;
                        }
                    }
                    else if ((int)client.Version >= (int)GameClient.eClientVersion.Version193)
                    {
                        // no base classes, so we choose a common startuplocation per realm
                        switch (ch.Realm)
                        {
                            case 1: // alb
                                startLocation = new StartLocation(562418, 512268, 2500, 2980);
                                break;
                            case 2: // mid
                                startLocation = new StartLocation(802869, 726016, 4699, 1399);
                                break;
                            case 3: // hib
                                startLocation = new StartLocation(347279, 489681, 5200, 2332);
                                break;
                        }
                    }
                    else if ((int)client.Version >= (int)GameClient.eClientVersion.Version180)
                    {
                        startLocation = (StartLocation)MainTownStartingLocations[ch.Class];
                    }
                    else if (ch.Region == 1 || ch.Region == 100 || ch.Region == 200) // all classic regions
                    {
                        startLocation = (StartLocation)ClassicLocations[ch.Race][ch.Class];
                    }
                    else if (ch.Region == 51 || ch.Region == 151 || ch.Region == 181) // all ShroudedIsles regions
                    {
                        startLocation = (StartLocation)ShroudedIslesLocations[ch.Race][ch.Class];
                    }
                    else
                    {
                        log.DebugFormat("tried to create char in unknown region {0}", ch.Region);
                        switch (ch.Realm)
                        {
                            default: ch.Region = 1; break;
                            case 2: ch.Region = 100; break;
                            case 3: ch.Region = 200; break;
                        }
                        startLocation = (StartLocation)ClassicLocations[ch.Race][ch.Class];
                    }
                }

                if (startLocation == null)
                {
                    log.Warn("startup location not found: account=" + ch.AccountName + "; char name=" + ch.Name + "; region=" + ch.Region + "; realm=" + ch.Realm + "; class=" + ch.Class + " (" + (eCharacterClass)ch.Class + "); race=" + ch.Race + " (" + (eRace)ch.Race + ")");
                }
                else
                {
                    ch.Xpos = startLocation.X;
                    ch.Ypos = startLocation.Y;
                    ch.Zpos = startLocation.Z;
                    ch.Direction = startLocation.Heading;
                }

                BindCharacter(ch);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("StartupLocations script: error changing location. account=" + ch.AccountName + "; char name=" + ch.Name + "; region=" + ch.Region + "; realm=" + ch.Realm + "; class=" + ch.Class + " (" + (eCharacterClass)ch.Class + "); race=" + ch.Race + " (" + (eRace)ch.Race + ")", e);
            }
        }
 public RemoveCommand(ObservableCollection<StartLocation> locationList, StartLocation location)
 {
     this.location = location;
     this.locationList = locationList;
 }
Esempio n. 28
0
        /// <summary>
        /// Change location on character creation
        /// </summary>
        public static void CharacterCreation(DOLEvent ev, object sender, EventArgs args)
        {
            CharacterEventArgs chArgs = args as CharacterEventArgs;

            if (chArgs == null)
            {
                return;
            }
            DOLCharacters ch = chArgs.Character;

            try
            {
                StartLocation   startLocation     = null;
                GameClient      client            = chArgs.GameClient;
                StartupLocation dbStartupLocation = null;

                // do we have custom locations in the DB ?
                if (ServerProperties.Properties.USE_CUSTOM_START_LOCATIONS)
                {
                    // First try to find an ALL entry
                    var startupLocations = GameServer.Database.SelectObjects <StartupLocation>("ClassIDs = 'ALL'");
                    if (startupLocations.Count > 0)
                    {
                        dbStartupLocation = startupLocations[0];
                    }
                    else
                    {
                        // find realm-based SL
                        startupLocations = GameServer.Database.SelectObjects <StartupLocation>("ClassIDs LIKE '%" + GlobalConstants.RealmToName((eRealm)ch.Realm).Substring(0, 3) + "%'");
                        if (startupLocations.Count > 0)
                        {
                            dbStartupLocation = startupLocations[0];
                        }
                        else
                        {
                            // find class-based SL
                            startupLocations = GameServer.Database.SelectObjects <StartupLocation>("ClassIDs LIKE '%" + ch.Class + "%'");
                            foreach (var curSL in startupLocations)
                            {
                                foreach (var classID in curSL.ClassIDs.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
                                {
                                    int charClass = 0;
                                    int.TryParse(classID, out charClass);
                                    if (charClass == ch.Class)
                                    {
                                        dbStartupLocation = curSL;
                                        break;
                                    }
                                }
                                if (dbStartupLocation != null)
                                {
                                    break;
                                }
                            }
                        }
                    }

                    // fill loc with our found SL
                    if (dbStartupLocation != null)
                    {
                        startLocation = new StartLocation(dbStartupLocation.XPos, dbStartupLocation.YPos, dbStartupLocation.ZPos, dbStartupLocation.Heading);
                        ch.Region     = dbStartupLocation.Region;
                    }
                }

                // no custom SL or custom SL not found
                if (dbStartupLocation == null)
                {
                    // tutorial all realms use the same region
                    // except if disabled in SP, v1.93+ start is in tutorial zone
                    if ((ch.Region == 27 || (int)client.Version >= (int)GameClient.eClientVersion.Version193) && !ServerProperties.Properties.DISABLE_TUTORIAL)
                    {
                        switch (ch.Realm)
                        {
                        case 1:                                 // alb
                            startLocation = new StartLocation(95638, 101322, 5340, 998);
                            break;

                        case 2:                                 // mid
                            startLocation = new StartLocation(226716, 232385, 5340, 1024);
                            break;

                        case 3:                                 // hib
                            startLocation = new StartLocation(357788, 363457, 5340, 1024);
                            break;
                        }
                    }
                    else if ((int)client.Version >= (int)GameClient.eClientVersion.Version193)
                    {
                        // no base classes, so we choose a common startuplocation per realm
                        switch (ch.Realm)
                        {
                        case 1:                                 // alb
                            startLocation = new StartLocation(562418, 512268, 2500, 2980);
                            break;

                        case 2:                                 // mid
                            startLocation = new StartLocation(802869, 726016, 4699, 1399);
                            break;

                        case 3:                                 // hib
                            startLocation = new StartLocation(347279, 489681, 5200, 2332);
                            break;
                        }
                    }
                    else if ((int)client.Version >= (int)GameClient.eClientVersion.Version180)
                    {
                        startLocation = (StartLocation)MainTownStartingLocations[ch.Class];
                    }
                    else if (ch.Region == 1 || ch.Region == 100 || ch.Region == 200)                     // all classic regions
                    {
                        startLocation = (StartLocation)ClassicLocations[ch.Race][ch.Class];
                    }
                    else if (ch.Region == 51 || ch.Region == 151 || ch.Region == 181)                     // all ShroudedIsles regions
                    {
                        startLocation = (StartLocation)ShroudedIslesLocations[ch.Race][ch.Class];
                    }
                    else
                    {
                        log.DebugFormat("tried to create char in unknown region {0}", ch.Region);
                        switch (ch.Realm)
                        {
                        default: ch.Region = 1; break;

                        case 2: ch.Region = 100; break;

                        case 3: ch.Region = 200; break;
                        }
                        startLocation = (StartLocation)ClassicLocations[ch.Race][ch.Class];
                    }
                }

                if (startLocation == null)
                {
                    log.Warn("startup location not found: account=" + ch.AccountName + "; char name=" + ch.Name + "; region=" + ch.Region + "; realm=" + ch.Realm + "; class=" + ch.Class + " (" + (eCharacterClass)ch.Class + "); race=" + ch.Race + " (" + (eRace)ch.Race + ")");
                }
                else
                {
                    ch.Xpos      = startLocation.X;
                    ch.Ypos      = startLocation.Y;
                    ch.Zpos      = startLocation.Z;
                    ch.Direction = startLocation.Heading;
                }

                BindCharacter(ch);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("StartupLocations script: error changing location. account=" + ch.AccountName + "; char name=" + ch.Name + "; region=" + ch.Region + "; realm=" + ch.Realm + "; class=" + ch.Class + " (" + (eCharacterClass)ch.Class + "); race=" + ch.Race + " (" + (eRace)ch.Race + ")", e);
                }
            }
        }
Esempio n. 29
0
    // Pretty Solid
    Vector2 DetermineCoordinates(StartLocation startLocation)
    {
        Vector2 finalPos2D = new Vector2(0f, 0f);

        switch (startLocation)
        {
        case StartLocation.N:
            finalPos2D = new Vector2(
                (float)mapRadius * UnityEngine.Random.Range(-0.15f, 0.15f),
                (float)mapRadius * UnityEngine.Random.Range(0.6f, 0.8f)
                );
            break;

        case StartLocation.NE:
            finalPos2D = new Vector2(
                (float)mapRadius * UnityEngine.Random.Range(0.6f, 0.8f),
                (float)mapRadius * UnityEngine.Random.Range(0.6f, 0.8f)
                );
            break;

        case StartLocation.E:
            finalPos2D = new Vector2(
                (float)mapRadius * UnityEngine.Random.Range(0.6f, 0.8f),
                (float)mapRadius * UnityEngine.Random.Range(-0.15f, 0.15f)
                );
            break;

        case StartLocation.SE:
            finalPos2D = new Vector2(
                (float)mapRadius * UnityEngine.Random.Range(0.6f, 0.8f),
                (float)mapRadius * UnityEngine.Random.Range(-0.6f, -0.8f)
                );
            break;

        case StartLocation.S:
            finalPos2D = new Vector2(
                (float)mapRadius * UnityEngine.Random.Range(-0.15f, 0.15f),
                (float)mapRadius * UnityEngine.Random.Range(-0.6f, -0.8f)
                );
            break;

        case StartLocation.SW:
            finalPos2D = new Vector2(
                (float)mapRadius * UnityEngine.Random.Range(-0.6f, -0.8f),
                (float)mapRadius * UnityEngine.Random.Range(-0.6f, -0.8f)
                );
            break;

        case StartLocation.W:
            finalPos2D = new Vector2(
                (float)mapRadius * UnityEngine.Random.Range(-0.6f, -0.8f),
                (float)mapRadius * UnityEngine.Random.Range(-0.15f, 0.15f)
                );
            break;

        case StartLocation.NW:
            finalPos2D = new Vector2(
                (float)mapRadius * UnityEngine.Random.Range(-0.6f, -0.8f),
                (float)mapRadius * UnityEngine.Random.Range(0.6f, 0.8f)
                );
            break;
        }
        return(finalPos2D);
    }
Esempio n. 30
0
 public bool Overlap(DataLocation location)
 {
     return(StartLocation.IsBefore(location) && EndLocation.IsAfter(location));
 }
 public RemoveCommand(ObservableCollection <StartLocation> locationList, StartLocation location)
 {
     this.location     = location;
     this.locationList = locationList;
 }
Esempio n. 32
0
        /// <summary>
        /// Update the position and size of the menu.
        /// </summary>
        /// <param name="bounds">Screen coordinates where the menu is allowed to be drawn in.</param>
        /// <param name="menuPredecessor">Predecessor menu (when available).</param>
        /// <param name="startLocation">Defines where the first menu is drawn (when no predecessor is set).</param>
        internal void AdjustSizeAndLocation(
            Rectangle bounds,
            Menu menuPredecessor,
            StartLocation startLocation)
        {
            if (menuPredecessor != null)
            {
                // Ignore start as we use predecessor
                startLocation = StartLocation.Predecessor;
            }

            // Update the height and width
            AdjustDataGridViewHeight(menuPredecessor, bounds.Height);
            AdjustDataGridViewWidth();

            // Calculate X position
            int x;

            switch (startLocation)
            {
            case StartLocation.Predecessor:
                int scaling = (int)Math.Round(Scaling.Factor, 0, MidpointRounding.AwayFromZero);
                directionToRight = menuPredecessor.directionToRight;     // try keeping same direction
                if (directionToRight)
                {
                    x = menuPredecessor.Location.X + menuPredecessor.Width - scaling;

                    // Change direction when out of bounds
                    if (bounds.X + bounds.Width <= x + Width - scaling)
                    {
                        x = menuPredecessor.Location.X - Width + scaling;
                        directionToRight = !directionToRight;
                    }
                }
                else
                {
                    x = menuPredecessor.Location.X - Width + scaling;

                    // Change direction when out of bounds
                    if (x < bounds.X)
                    {
                        x = menuPredecessor.Location.X + menuPredecessor.Width - scaling;
                        directionToRight = !directionToRight;
                    }
                }

                break;

            case StartLocation.BottomLeft:
                x = bounds.X;
                directionToRight = true;
                break;

            case StartLocation.TopRight:
            case StartLocation.BottomRight:
            default:
                x = bounds.Width - Width;
                directionToRight = false;
                break;
            }

            // Calculate Y position
            int y;

            switch (startLocation)
            {
            case StartLocation.Predecessor:
                RowData      trigger = (RowData)Tag;
                DataGridView dgv     = menuPredecessor.GetDataGridView();
                int          distanceFromItemToDgvTop = 0;

                // Get offset of selected row from predecessor
                if (dgv.Rows.Count > trigger.RowIndex)
                {
                    Rectangle cellRectangle = dgv.GetCellDisplayRectangle(0, trigger.RowIndex, false);
                    distanceFromItemToDgvTop = cellRectangle.Top;
                }

                // Set position on same height as the selected row from predecessor
                y = menuPredecessor.Location.Y + menuPredecessor.dgv.Location.Y + distanceFromItemToDgvTop;

                // Move vertically when out of bounds
                if (bounds.Y + bounds.Height < y + Height)
                {
                    y = bounds.Y + bounds.Height - Height;
                }

                break;

            case StartLocation.TopRight:
                y = bounds.Y;
                break;

            case StartLocation.BottomLeft:
            case StartLocation.BottomRight:
            default:
                y = bounds.Height - Height;
                break;
            }

            // Update position
            Location = new Point(x, y);
        }
Esempio n. 33
0
        public override void AddStartLocation(StartLocation sl)
        {
            Vector2 position = new Vector2(0, 0);

            Rectangle destSize = new Rectangle();

            int fX = sl.MapTile.ScreenXPos - (int)(64 * MapRendering.Scale);
            int fY = sl.MapTile.ScreenYPos - (int)(32 * MapRendering.Scale);

            position.X = fX;
            position.Y = fY;

            destSize.Width = (int)(128 * MapRendering.Scale);
            destSize.Height = (int)(64 * MapRendering.Scale);

            MapRendering.AddStartLocationBatch(sl.MapTile, position, new Rectangle(0, 0, 128, 64));
        }
Esempio n. 34
0
 protected override void DrawGhost(CanvasControl sender, CanvasDrawEventArgs args)
 {
     args.DrawingSession.DrawLine(StartLocation.ToVector2(), EndLocation.ToVector2(), ShapeColor, 1);
 }