public void NeighborDistances( out int outStartingDistance, out int outEndingDistance) { outStartingDistance = StartingPoint.PrevDistance(); outEndingDistance = EndingPoint.NextDistance(); }
public override int GetHashCode() { unchecked { return(17 * StartingPoint.GetHashCode() + 23 * Offset.GetHashCode()); } }
public void ChangeWorld(World world, StartingPoint startingPoint) { this.RotationAxis = startingPoint.RotationAxis; this.RotationW = startingPoint.RotationW; this.ChangeWorld(world, startingPoint.Position); }
public IPlayer Initialize(StartingPoint initialPos) { this.Direction = initialPos.Direction; this.Position = new Position(); this.Position.X = initialPos.X; this.Position.Y = initialPos.Y; return(this); }
/// <summary> /// Initial Map constructor /// </summary> /// <param name="name"></param> /// <param name="w"></param> /// <param name="h"></param> public Map(string name, int w, int h) { this.name = name; width = w; height = h; cells = new List <Cell>(); startingPoint = null; endingPoints = new List <EndingPoint>(); }
void Start() { grad = new Gradient(); c_green = new Color32(0xB3, 0xFF, 0x10, 0xFF); c_lightBlue = new Color32(0x10, 0xA4, 0xFF, 0xFF); p = gameObject.GetComponent <ParticleSystem>(); instance = this; stopCoroutine = false; }
// Move direction. // Change the starting position on a direction. public override R1CircularDirection translate(int coordinateSystemDirection, float amount) { float finalX = StartingPoint.GetAxisAt(0); R1Direction <R1CircularDirection, CircularLinkedList <R1Point>, CircularDirection <R1CircularDirection, R1Point> > .Translate(coordinateSystemDirection, amount, ref finalX); return(new R1CircularDirection(new R1Point(finalX), Direction, SharedDirection.DirectionLength, SharedDirection.Divisor, Duration, numberOfRotations)); }
// Rotate about the x-axis or y-axis a certatin number of times, and return the result. // Rotate around the x-axis or the y-axis. public override R2CircularDirection RotateAroundAxis(int indexOfAxis, int numberOfTimes) { R2CircularDirection direction = this; R2Direction <R2CircularDirection, CircularLinkedList <R2Point>, CircularDirection <R2CircularDirection, R2Point> > .RotateAroundAxis(indexOfAxis, numberOfTimes, this); return(new R2CircularDirection(new R2Point(StartingPoint.GetAxisAt(0), StartingPoint.GetAxisAt(1), StartingPoint.CanShoot), Direction, SharedDirection.DirectionLength, SharedDirection.Divisor, CanShoot, Duration)); }
private void AlgoList_SelectionChangeCommitted(object sender, EventArgs e) { if (AlgoList.SelectedIndex == 4) { StartingPoint.Hide(); panel4.Hide(); } else { StartingPoint.Show(); panel4.Show(); } }
public Cell GetStartCell(Area area) { StartingPoint st = map.StartPoint; List <Cell> unvisited = map.WalkableCells; Cell firstCell = unvisited.FirstOrDefault(x => x.X == st.x && x.Y == st.y); unvisited.RemoveAll(x => x.X == st.x && x.Y == st.y); Cell c = IterativeFlood(firstCell, area, unvisited); return(c); }
public override string ToString() { var result = StartingPoint.ToString(); if (Offset != 0) { result += $" with offset {Offset}"; } if (CPU != null) { result += $" for core {CPU}"; } return(result); }
private void DrawStartEndPoints(StartingPoint start, List <EndingPoint> endPoints) { if (start != null) { cellPanelGraphics.DrawString("S", new Font("ArialBold", 12), new SolidBrush(Color.Yellow), new RectangleF(new PointF(start.x * cellWidth, start.y * cellHeight), new SizeF(cellWidth, cellHeight)), StringFormat.GenericDefault); } if (endPoints != null) { foreach (var e in endPoints) { cellPanelGraphics.DrawString("E", new Font("ArialBold", 12), new SolidBrush(Color.Yellow), new RectangleF(new PointF(e.x * cellWidth, e.y * cellHeight), new SizeF(cellWidth, cellHeight)), StringFormat.GenericDefault); } } }
public override int CompareTo(R2CircularDirection comparableInstance) { int result = 0; if (GetDirectionLength() < comparableInstance.GetDirectionLength()) { result = -1; } else if (GetDirectionLength() > comparableInstance.GetDirectionLength()) { result = 1; } else { if (GetDirectionDivisor() < comparableInstance.GetDirectionDivisor()) { result = -1; } else if (GetDirectionDivisor() > comparableInstance.GetDirectionDivisor()) { result = 1; } else { if (Direction < comparableInstance.Direction) { result = -1; } else if (Direction > comparableInstance.Direction) { result = 1; } else { result = StartingPoint.CompareTo(comparableInstance.StartingPoint); } } } return(result); }
///Sauvegarde les nouvelles dates d'analyse public static void SaveConfig() { String configfilepath = Path.Combine(_GenotikPath, ConfigPath); //update date interval for (int i = 0; i < configContent.Count; i++) { if (configContent[i].StartsWith("startTimePoint")) { configContent[i] = String.Concat("startTimePoint " + StartingPoint.ToString("yyyyMMddHHmmss")); } if (configContent[i].StartsWith("endTimePoint")) { configContent[i] = String.Concat("endTimePoint " + NextEndingPoint.ToString("yyyyMMddHHmmss")); } } File.WriteAllLines(configfilepath, configContent); }
public bool WasInjured() { var theResult = StartingPoint.IsHunted() || EndingPoint.IsHunted(); if (StartingPoint.IsHunted() && !_injuryRegistry[0]) { _distance += StartingPoint.PrevDistance(); _injuryRegistry[0] = true; } if (EndingPoint.IsHunted() && !_injuryRegistry[1]) { _distance += EndingPoint.NextDistance(); _injuryRegistry[1] = true; } return(theResult); }
public override int GetHashCode() { int hash = 1; if (NodeSize != 0) { hash ^= NodeSize.GetHashCode(); } if (startingPoint_ != null) { hash ^= StartingPoint.GetHashCode(); } if (goalPoint_ != null) { hash ^= GoalPoint.GetHashCode(); } hash ^= prefab_.GetHashCode(); return(hash); }
/// <summary> /// Check wether the dungeon can be completed. /// </summary> /// <param name="start">StartPoint gameobject.</param> /// <param name="end">EndPoint gameobject.</param> private void CheckPath(GameObject start, GameObject end) { StartingPoint startPoint = start.GetComponent <StartingPoint>(); EndingPoint endPoint = end.GetComponent <EndingPoint>(); RoomNode startRoom = startPoint.room; RoomNode endRoom = endPoint.room; int connections = 0; //Search for connections between the start and end point //Due to my lack of knowledge of AI in unity as well as issues with the visualisation I was unable to use //AI agnets to check if the path is able to be completed like I wanted foreach (Hallway hallway in hallwayList) { if (hallway.ConnectedRooms.Contains(startRoom) && hallway.ConnectedRooms.Contains(endRoom)) { connections++; Debug.Log("Connection found"); } } }
/// <summary> /// Checks if a node source is ready. /// </summary> /// <param name="node">The node for which the value is checked.</param> /// <param name="data">Optional data returned to the caller.</param> public override bool IsReady(TSource node, out object data) { data = null; bool Result = false; INodeWithResult EmbeddingNode = StartingPoint.GetStart(node) as INodeWithResult; if (EmbeddingNode != null) { OnceReference <TRef> Value = TemplateHelper.GetPropertyPathValue <INodeWithResult, OnceReference <TRef> >(EmbeddingNode, TemplateNodeStart <INodeWithResult> .Default, PropertyPath, out bool IsInterrupted); if (!IsInterrupted && Value.IsAssigned) { data = Value.Item; Result = true; } } else { Result = true; } return(Result); }
public Vector3 GetRandomStartingPosition() { Vector3 startingPos = new Vector3(); StartingPoint sp = (StartingPoint)UnityEngine.Random.Range(0, 4); if (sp == StartingPoint.bottom) { startingPos = new Vector3(UnityEngine.Random.Range(-96, 28), 0, -28); } else if (sp == StartingPoint.top) { startingPos = new Vector3(UnityEngine.Random.Range(-96, 28), 0, 96); } else if (sp == StartingPoint.left) { startingPos = new Vector3(-96, 0, UnityEngine.Random.Range(-28, 96)); } else if (sp == StartingPoint.right) { startingPos = new Vector3(28, 0, UnityEngine.Random.Range(-28, 96)); } return(startingPos); }
public CPoint Injure( CSegmentPool inOwningPool, int inPoolIdx) { CPoint thePointToHunt = null, thePointToInfect = null; int whichEndToHunt = 0; // Init to 'no end'. 1: starting, 2: ending // Prefere to depart, so first check if there is any touched points? // It's NOT good, because we need to look forward and if there is the possiblility // for moving forward, then try to avoid the point, which was shared by the // prev injured segment!! // So if we can move forward ? How we can check about this fact? // (use index to see if this is the last point //just check the prev segment and // NO No NO!!!! // We need to introduce a new concept: InfectedPoint // In a segment, when we haunt an end_point then the other point is 'Infected' // and when we are checking for touch_points, then we choose them only if // it is NOT infected if (StartingPoint.IsTouched() && !StartingPoint.IsInfected()) { thePointToHunt = StartingPoint; thePointToInfect = EndingPoint; whichEndToHunt = 1; } else if (EndingPoint.IsTouched()) { thePointToHunt = EndingPoint; whichEndToHunt = 2; thePointToInfect = StartingPoint; } else { // Do the wounding process // Look at the neighbors: NeighborDistances(out var theStartPrevDist, out var theEndNextDist); if (theStartPrevDist == theEndNextDist) { // Since the points are sorted, so the starting_point < ending (always!) thePointToHunt = StartingPoint; whichEndToHunt = 1; thePointToInfect = EndingPoint; } else if (theStartPrevDist < theEndNextDist) { thePointToHunt = EndingPoint; whichEndToHunt = 2; thePointToInfect = StartingPoint; } else // theStartPrevDist > theEndNextDist { thePointToHunt = StartingPoint; whichEndToHunt = 1; thePointToInfect = EndingPoint; } } thePointToHunt?.Hunt(); thePointToInfect?.Infect(); // Now recalculate the distance, considering the hunted point // But what if all two points was haunted?! Hey: The Distance = PrevDist + ThisDist + NextDist // Determine the most recently hunted point and then add its relevant neighbor to the distance switch (whichEndToHunt) { case 1: _distance += StartingPoint.PrevDistance(); _injuryRegistry[0] = true; break; case 2: _distance += EndingPoint.NextDistance(); _injuryRegistry[1] = true; break; } return(thePointToHunt); }
public override string ToString() { return(RouteName + ", " + StartingPoint.ToString() + ", " + RouteLength + " km"); }
public override R2NonCircularDirection ReflectAboutEqualAxis(int[] axisIndeces, int numberOfTimes) { R2Direction <R2NonCircularDirection, DoubleLinkedList <R2Point>, NonCircularDirection <R2NonCircularDirection, R2Point> > .ReflectAroundEqualAxis(new List <int>(axisIndeces), numberOfTimes, ref direction); return(new R2NonCircularDirection(new R2Point(StartingPoint.GetAxisAt(0), StartingPoint.GetAxisAt(1), StartingPoint.CanShoot), Direction, SharedDirection.DirectionLength, SharedDirection.Divisor, CanShoot, Duration)); }
public override string ToString() { return($"Start: {StartingPoint.ToString()}, End: {EndingPoint.ToString()}"); }
private void StartingPoint_Click(object sender, EventArgs e) { StartingPoint.Clear(); }
public void HandleCustomProperties(GameObject gameObject, IDictionary <string, string> keyValuePairs) { if (keyValuePairs.ContainsKey("PortalTo")) { MapPortal portal = gameObject.AddComponent <MapPortal>(); string[] parts = keyValuePairs["PortalTo"].Split(new char[] { ':' }, 2); portal.target = new MapPath(parts[0], parts.Length > 1 ? parts[1] : "default"); gameObject.GetComponent <Collider2D>().isTrigger = true; } if (keyValuePairs.ContainsKey("PortalFrom")) { StartingPoint portal = gameObject.AddComponent <StartingPoint>(); portal.locationName = keyValuePairs["PortalFrom"]; Collider2D collider = gameObject.GetComponent <Collider2D>(); gameObject.transform.position = collider.bounds.center; GameObject.DestroyImmediate(collider); } if (keyValuePairs.ContainsKey("ObjectName")) { PrefabSpawner spawner = gameObject.AddComponent <PrefabSpawner>(); PrefabNames names = getPrefabMapping(); if (names != null) { spawner.toSpawn = names.GetEntry(keyValuePairs["ObjectName"]).prefab; spawner.condition = keyValuePairs.ContainsKey("When") ? keyValuePairs["When"] : ""; spawner.properties = keyValuePairs; } Debug.Log(gameObject.transform.rotation); BoxCollider2D collider = gameObject.GetComponent <BoxCollider2D>(); if (collider != null) { spawner.size += new Vector3(collider.offset.x, collider.offset.y, 0.0f); Object.DestroyImmediate(collider); } Tiled2Unity.TileObject tileObject = gameObject.GetComponent <Tiled2Unity.TileObject>(); if (tileObject != null) { spawner.size += new Vector3(tileObject.TileWidth * 0.5f, tileObject.TileHeight * 0.5f, 0.0f); Object.DestroyImmediate(tileObject); } while (gameObject.transform.childCount > 0) { Object.DestroyImmediate(gameObject.transform.GetChild(0).gameObject); } } if (sideAttributes.Any((key) => keyValuePairs.ContainsKey(key))) { MapAttachements attatchments = gameObject.AddComponent <MapAttachements>(); attatchments.attachments = sideAttributes.Select((name) => { if (keyValuePairs.ContainsKey(name)) { return(keyValuePairs[name]); } else { return(null); } }).ToArray(); } Tiled2Unity.TiledMap map = gameObject.GetComponent <Tiled2Unity.TiledMap>(); if (map != null) { if (keyValuePairs.ContainsKey("Name")) { mapName = keyValuePairs["Name"]; } else { mapName = null; } Pathfinding pathfinding = gameObject.AddComponent <Pathfinding>(); pathfinding.width = map.NumTilesWide; pathfinding.height = map.NumTilesHigh; pathfinding.tileSize = new Vector2(map.TileWidth, map.TileHeight) * map.ExportScale; pathfinding.layers = new List <PathfindingLayer> { new PathfindingLayer(PathingTypes.Walking, (1 << LayerMask.NameToLayer("L1: Barrier")) | (1 << LayerMask.NameToLayer("L1: ProjectilePassible")) | (1 << LayerMask.NameToLayer("L1: Water"))), new PathfindingLayer(PathingTypes.Flying, 1 << LayerMask.NameToLayer("L1: Barrier")), }; } }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { Graphics graphics = e.Graphics; Font drawFont = new Font("monaco", 12); string drawString = ""; sentences = ThisFile.GetText(); int L = 0, C = 0; int count = 0; startline = (Line > 31) ? Line - 31 : 0; for (int i = startline; i < startline + (((sentences.Count - startline) < 33)? (sentences.Count - startline):33); i++) { bool searchpoint = false; bool isInstruction = false; for (int j = 0; j < sentences[i].Length; j++) { drawString = sentences[i][j].ToString(); PointF drawPoint = new PointF(C * 10, L * 20); if (j == 11) { isInstruction = true; } if (sentences[i][j] == ' ') { isInstruction = searchpoint = false; } if (count == searchLength) { searchpoint = false; } SolidBrush drawBrush; if (isUCO && j < 10) { drawBrush = new SolidBrush(Color.FromArgb(221, 215, 95)); } else if (isUCO && isInstruction) { drawBrush = new SolidBrush(Color.FromArgb(175, 255, 85)); } else { drawBrush = new SolidBrush(Color.FromArgb(240, 240, 240)); } if (isSearchMode) { LC temp = new LC(L, C); if (StartingPoint.Any(x => x.L == temp.L && x.C == temp.C)) { count = 0; searchpoint = true; } if (searchpoint) { count++; Point point = new Point((int)drawPoint.X + 2, (int)drawPoint.Y + 1); Size sz = new Size(10, 18); Pen drawPen = new Pen(Color.FromArgb(215, 95, 0)); SolidBrush sb = new SolidBrush(Color.FromArgb(215, 95, 0)); Rectangle rectangle = new Rectangle(point, sz); graphics.DrawRectangle(drawPen, rectangle); graphics.FillRectangle(sb, rectangle); } } C++; graphics.DrawString(drawString, drawFont, drawBrush, drawPoint); } L++; C = 0; //drawString += (sentences[i] + "\n"); } cursorShow(e.Graphics); }
public void InitializePlayer(IPlayer player, StartingPoint initialPos) { Console.WriteLine($"Turtle Initial Position - X:{initialPos.X}, Y:{initialPos.Y}, Direction:{initialPos.Direction}"); this.Turtle = player.Initialize(initialPos); }
/// <summary> /// Parses the dungeon.lua file in the current project directory /// </summary> /// <returns> A Map object representing the current dungeon.lua file contents </returns> public static Map ParseMapFile() { Char[] delimiters = { '=', ' ', ',', '"', '{', '}', '\r', '\n', '\t', ')', '(' }; Char[] delimitersAttributes = { '.', ':', ',', '"', '(', ')', '\r', '\n', '\t' }; Char[] delimitersAttributes2 = { '.', ':', ',', '"', '(', ')', '\r', '\n', '\t', ' ' }; Dictionary <string, MapElement> elements = new Dictionary <string, MapElement>(); Monster.MonsterType tmpMonstertype; Text.TextType tmpTextType; Door.DoorType tmpDoorType; Lever.LeverType tmpLeverType; Lock.LockType tmpLockType; ButtonE.ButtonType tmpButtonType; Alcove.AlcoveType tmpAlcoveType; PressurePlate.PressurePlateType tmpPressurePlateType; TrapDoor.TrapDoorType tmpTrapDoorType; TorchHolder.TorchHolderType tmpTorchHolderType; Lantern.LanternType tmpLanternType; Altar.AltarType tmpAltarType; WallEffect.WallEffectType tmpWallEffectType; Weapon.WeaponType tmpWeaponType; Armor.ArmorType tmpArmorType; Food.FoodType tmpFoodType; Potion.PotionType tmpPotionType; string fileText = System.IO.File.ReadAllText(DirectoryManager.DungeonFilePath); string patternSpawn = @"spawn\(.*\)"; string patternAttributes = @"\w+\.\w+\:\w+\(.*\)"; string patternLoadLayer = @"loadLayer\(([^)]+)\)"; string patternParameters = @"\w+ = .*,"; string patternTiles = @"tiles = {(\n|\t|[^{])*(?=})"; MatchCollection matchsSpawn = Regex.Matches(fileText, patternSpawn, RegexOptions.IgnoreCase); MatchCollection matchsAttribute = Regex.Matches(fileText, patternAttributes, RegexOptions.IgnoreCase); MatchCollection matchsParameters = Regex.Matches(fileText, patternParameters, RegexOptions.IgnoreCase); Match matchLayer = Regex.Match(fileText, patternLoadLayer, RegexOptions.IgnoreCase); Match matchTiles = Regex.Match(fileText, patternTiles, RegexOptions.IgnoreCase); string name = "", ambientTrack = ""; int width = 0, height = 0; int[] levelCoord = null; List <string> tiles = new List <string>(); List <Cell> cells = new List <Cell>(); List <EndingPoint> endingPoints = new List <EndingPoint>(); StartingPoint startingPoint = null; foreach (Match m in matchsParameters) { string[] split = m.Value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); if (split[0].Contains("name")) { name = split[1]; } else if (split[0].Contains("width")) { width = Convert.ToInt32(split[1]); } else if (split[0].Contains("height")) { height = Convert.ToInt32(split[1]); } else if (split[0].Contains("levelCoord")) { levelCoord = new int[] { Convert.ToInt32(split[1]), Convert.ToInt32(split[2]), Convert.ToInt32(split[3]) }; } else if (split[0].Contains("ambientTrack")) { ambientTrack = split[1]; } } string[] splitTiles = matchTiles.Value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); for (int i = 1; i < splitTiles.Length; i++) { tiles.Add(splitTiles[i]); } string[] splitLayer = matchLayer.Value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); for (int i = 2; i < splitLayer.Length; i++) { int x = (i - 2) % width; int y = (i - 2) / width; int type = Convert.ToInt32(splitLayer[i]); Cell c = new Cell(x, y, type); if (type == 1) { c.IsWalkable = true; } else if (type == 2) { c.IsWalkable = false; //FIXME: Se houverem mais tipos esta comparação pode não chegar. } cells.Add(c); } foreach (Match m in matchsSpawn) { string[] splitString = m.Value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); string id = splitString[1]; int x = Convert.ToInt32(splitString[2]); int y = Convert.ToInt32(splitString[3]); int o = Convert.ToInt32(splitString[4]); int h = Convert.ToInt32(splitString[5]); string uniqueId = splitString[6]; Cell tmpCell = cells.Where(c => c.X == x && c.Y == y).First(); MapElement tmpElement = null; if (id.Contains("starting_location")) { startingPoint = new StartingPoint(id, x, y, o, h, uniqueId); tmpCell.IsStartingPoint = true; tmpCell.StartPoint = startingPoint; elements.Add(uniqueId, startingPoint); } else if (id.Contains("exit") || id.Contains("stairs") || id.Contains("healing_crystal")) { var newEndingPoint = new EndingPoint(id, x, y, o, h, uniqueId); tmpCell.IsEndingPoint = true; tmpCell.EndPoint = newEndingPoint; endingPoints.Add(newEndingPoint); elements.Add(uniqueId, newEndingPoint); } else if (Enum.TryParse(id, true, out tmpTorchHolderType)) { tmpElement = new TorchHolder(id, x, y, o, h, uniqueId); } else if (id.Equals("scroll")) { tmpElement = new Scroll(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpAlcoveType)) { tmpElement = new Alcove(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpButtonType)) { tmpElement = new ButtonE(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpDoorType)) { tmpElement = new Door(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpLeverType)) { tmpElement = new Lever(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpLockType)) { tmpElement = new Lock(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpMonstertype)) { var newMonster = new Monster(id, x, y, o, h, uniqueId); tmpCell.Monster = newMonster; elements.Add(uniqueId, newMonster); } else if (Enum.TryParse(id, true, out tmpPressurePlateType)) { tmpElement = new PressurePlate(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpTextType)) { tmpElement = new Text(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpTrapDoorType)) { tmpElement = new TrapDoor(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpLanternType)) { tmpElement = new Lantern(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpAltarType)) { tmpElement = new Altar(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpWallEffectType)) { tmpElement = new WallEffect(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpWeaponType)) { tmpElement = new Weapon(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpArmorType)) { tmpElement = new Armor(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpFoodType)) { tmpElement = new Food(id, x, y, o, h, uniqueId); } else if (Enum.TryParse(id, true, out tmpPotionType)) { tmpElement = new Potion(id, x, y, o, h, uniqueId); } else { tmpElement = new Item(id, x, y, o, h, uniqueId); } if (tmpElement != null) { tmpCell.AddElement(tmpElement); elements.Add(uniqueId, tmpElement); } } foreach (Match m in matchsAttribute) { Char[] delimit = delimitersAttributes; if (m.Value.Contains("addConnector")) { delimit = delimitersAttributes2; } string[] split = m.Value.Split(delimit, StringSplitOptions.RemoveEmptyEntries); MapElement tmpElement = null; if (elements.TryGetValue(split[0], out tmpElement)) { if (split[2].Contains("addConnector")) { tmpElement.addConnector(split[3], split[4], split[5]); } else if (split[2].Contains("addItem") || split[2].Contains("setWallText") || split[2].Contains("setOpenedBy") || split[2].Contains("setState") || split[2].Contains("setDoorState") || split[2].Contains("setScrollText")) { tmpElement.setAttribute(split[2], split[3]); } else if (split[2].Contains("disable")) { tmpElement.setAttribute(split[2], ""); } else // True or false { tmpElement.setAttribute(split[2], split[3].Contains("true") ? true : false); } } } Map map = new Map(name, width, height) { StartPoint = startingPoint, EndPointList = endingPoints, AmbientTrack = ambientTrack, LevelCoord = levelCoord, Cells = cells, Tiles = new ArrayList(tiles), //FIXME Elements = elements, }; CurrentMap = map; return(map); }
public override void OnTargeted(Player player, TargetMessage message) { Logger.Debug("(OnTargeted) Portal has been activated "); var world = this.World.Game.GetWorld(this.Destination.WorldSNO); var startingPoint = world.GetStartingPointById(this.Destination.StartingPointActorTag); #region События //Подвал Адрии if (this.Destination.WorldSNO == 62751) { //Enter в Adrian's Hut bool QuestEnter = false; var Cauldron = world.GetActorBySNO(131123); if (player.PlayerIndex == 0) { if (player.Toon.ActiveQuest == 72095) { player.Toon.ActiveQuest = 72095; if (player.Toon.StepOfQuest == 5) { player.Toon.StepOfQuest = 6; player.Toon.StepIDofQuest = 51; QuestEnter = true; } var Leah_Cellar = world.GetActorBySNO(203030); Leah_Cellar.Position = new Vector3D(-200f, -200f, 3.051758E-05f); } } if (QuestEnter == true) { world.Game.Quests.NotifyQuest(72095, NullD.Common.MPQ.FileFormats.QuestStepObjectiveType.EventReceived, -1); //world.Game.Quests.Advance(72095); } } #endregion #region Авто-Учёт перехода для Квест-Менеджера world.Game.Quests.NotifyQuest(player.Toon.ActiveQuest, NullD.Common.MPQ.FileFormats.QuestStepObjectiveType.EnterWorld, this.Destination.WorldSNO); #endregion if (world == null) { Logger.Warn("Portal's destination world does not exist (WorldSNO = {0})", this.Destination.WorldSNO); return; } #region Не санкционированные порталы) if (this.Destination.StartingPointActorTag == -100) { Vector3D ToPortal = new Vector3D(2985.6241f, 2795.627f, 24.04532f); Vector3D ToPortal2Act = new Vector3D(310.739f, 275.8123f, 0.09997072f); Vector3D ToPortal3Act = new Vector3D(390f, 402f, 0f); Vector3D ToPortal4Act = new Vector3D(390f, 402f, 0f); //Сохраняем в базу координаты для обратного портала. var dbPortalOfToon = DBSessions.AccountSession.Get <DBPortalOfToon>(player.Toon.PersistentID); var dbQuestProgress = DBSessions.AccountSession.Get <DBProgressToon>(player.Toon.PersistentID); dbPortalOfToon.WorldDest = player.World.WorldSNO.Id; dbPortalOfToon.X = this.Position.X; dbPortalOfToon.Y = this.Position.Y; dbPortalOfToon.Z = this.Position.Z; dbPortalOfToon.PlayerIndex = player.PlayerIndex; DBSessions.AccountSession.SaveOrUpdate(dbPortalOfToon); Logger.Warn("Data for back portal Saved."); if (dbQuestProgress.ActiveAct == 0) { var TristramHome = player.World.Game.GetWorld(71150); var OldPortal = TristramHome.GetActorsBySNO(5648); foreach (var OldP in OldPortal) { OldP.Destroy(); } var ToHome = new Portal(player.World.Game.GetWorld(71150), 5648, player.World.Game.GetWorld(71150).StartingPoints[0].Tags); ToHome.Destination = new ResolvedPortalDestination { WorldSNO = dbPortalOfToon.WorldDest, DestLevelAreaSNO = player.CurrentScene.Specification.SNOLevelAreas[0], StartingPointActorTag = -101 }; ToHome.EnterWorld(ToPortal); if (PlayerBackPortalID == 0xFFFFFFFFFFFF) { ToHome.PlayerBackPortalID = player.Toon.PersistentID; } if (player.World.Game.GetWorld(71150) != player.World) { /* * if (dbQuestProgress.ActiveQuest == 72221 & dbQuestProgress.StepOfQuest == 10 & player.PlayerIndex == 0) * { * player.World.Game.Quests.NotifyQuest(72221, DiIiS.Common.MPQ.FileFormats.QuestStepObjectiveType.EventReceived, -1); * dbQuestProgress.StepOfQuest = 11; * }*/ player.ChangeWorld(player.World.Game.GetWorld(71150), ToPortal); if (dbQuestProgress.ActiveQuest == 72738 && dbQuestProgress.StepOfQuest == 18) { //player.World.Game.Quests.NotifyQuest(72738, DiIiS.Common.MPQ.FileFormats.QuestStepObjectiveType.EventReceived, -1); dbQuestProgress.ActiveQuest = 73236; dbQuestProgress.StepOfQuest = -1; } player.ChangeWorld(player.World.Game.GetWorld(71150), ToPortal); if (player.ActiveHireling != null) { player.ActiveHireling.ChangeWorld(world, ToPortal); player.InGameClient.SendMessage(new PetMessage() { Field0 = 0, Field1 = 0, PetId = player.ActiveHireling.DynamicID, Field3 = 0, }); } } else { player.Teleport(ToPortal); if (player.ActiveHireling != null) { player.ActiveHireling.Teleport(ToPortal); } } } else if (dbQuestProgress.ActiveAct == 100) { var CaldeumHome = player.World.Game.GetWorld(161472); var OldPortal = CaldeumHome.GetActorsBySNO(5648); foreach (var OldP in OldPortal) { OldP.Destroy(); } var ToHome = new Portal(player.World.Game.GetWorld(161472), 5648, player.World.Game.GetWorld(161472).StartingPoints[0].Tags); ToHome.Destination = new ResolvedPortalDestination { WorldSNO = dbPortalOfToon.WorldDest, DestLevelAreaSNO = player.CurrentScene.Specification.SNOLevelAreas[0], StartingPointActorTag = -101 }; ToHome.EnterWorld(ToPortal2Act); if (PlayerBackPortalID == 0xFFFFFFFFFFFF) { ToHome.PlayerBackPortalID = player.Toon.PersistentID; } if (player.World.Game.GetWorld(161472) != player.World) { player.ChangeWorld(player.World.Game.GetWorld(161472), ToPortal2Act); if (player.ActiveHireling != null) { player.ActiveHireling.ChangeWorld(world, ToPortal2Act); player.InGameClient.SendMessage(new PetMessage() { Field0 = 0, Field1 = 0, PetId = player.ActiveHireling.DynamicID, Field3 = 0, }); } } } else if (dbQuestProgress.ActiveAct == 200) { var BastionHome = player.World.Game.GetWorld(172909); var OldPortal = BastionHome.GetActorsBySNO(5648); foreach (var OldP in OldPortal) { OldP.Destroy(); } var ToHome = new Portal(player.World.Game.GetWorld(172909), 5648, player.World.Game.GetWorld(172909).StartingPoints[0].Tags); ToHome.Destination = new ResolvedPortalDestination { WorldSNO = dbPortalOfToon.WorldDest, DestLevelAreaSNO = player.CurrentScene.Specification.SNOLevelAreas[0], StartingPointActorTag = -101 }; ToHome.EnterWorld(ToPortal3Act); if (PlayerBackPortalID == 0xFFFFFFFFFFFF) { ToHome.PlayerBackPortalID = player.Toon.PersistentID; } if (player.World.Game.GetWorld(172909) != player.World) { player.ChangeWorld(player.World.Game.GetWorld(172909), ToPortal3Act); } else { player.Teleport(ToPortal3Act); } } else if (dbQuestProgress.ActiveAct == 300) { var BastionHome = player.World.Game.GetWorld(178152); var OldPortal = BastionHome.GetActorsBySNO(5648); foreach (var OldP in OldPortal) { OldP.Destroy(); } var ToHome = new Portal(player.World.Game.GetWorld(178152), 5648, player.World.Game.GetWorld(178152).StartingPoints[0].Tags); ToHome.Destination = new ResolvedPortalDestination { WorldSNO = dbPortalOfToon.WorldDest, DestLevelAreaSNO = player.CurrentScene.Specification.SNOLevelAreas[0], StartingPointActorTag = -101 }; ToHome.EnterWorld(ToPortal4Act); if (PlayerBackPortalID == 0xFFFFFFFFFFFF) { ToHome.PlayerBackPortalID = player.Toon.PersistentID; } if (player.World.Game.GetWorld(178152) != player.World) { player.ChangeWorld(player.World.Game.GetWorld(178152), ToPortal4Act); } else { player.Teleport(ToPortal4Act); } } DBSessions.AccountSession.Flush(); } //Портал из Города else if (this.Destination.StartingPointActorTag == -101) { if (PlayerBackPortalID == player.Toon.PersistentID) { this.Destroy(); } var dbPortalOfToon = DBSessions.AccountSession.Get <DBPortalOfToon>(PlayerBackPortalID); Vector3D ToPortal = new Vector3D(dbPortalOfToon.X, dbPortalOfToon.Y, dbPortalOfToon.Z); var DestWorld = player.World.Game.GetWorld(dbPortalOfToon.WorldDest); var oldPortals = DestWorld.GetActorsBySNO(5648); foreach (var OldP in oldPortals) { OldP.Destroy(); } if (player.World.Game.GetWorld(dbPortalOfToon.WorldDest) != player.World) { player.ChangeWorld(player.World.Game.GetWorld(dbPortalOfToon.WorldDest), ToPortal); if (player.ActiveHireling != null) { player.ActiveHireling.ChangeWorld(world, ToPortal); player.InGameClient.SendMessage(new PetMessage() { Field0 = 0, Field1 = 0, PetId = player.ActiveHireling.DynamicID, Field3 = 0, }); } } else { player.Teleport(ToPortal); if (player.ActiveHireling != null) { player.ActiveHireling.Teleport(ToPortal); player.InGameClient.SendMessage(new PetMessage() { Field0 = 0, Field1 = 0, PetId = player.ActiveHireling.DynamicID, Field3 = 0, }); } } } else { #endregion if (startingPoint != null) { player.ChangeWorld(world, startingPoint); } else { #region Использование умного телепорта if (this.Destination.StartingPointActorTag != 0) { StartingPoint NeededStartingPoint = world.GetStartingPointById(this.Destination.StartingPointActorTag); var DestWorld = world.Game.GetWorld(this.Destination.WorldSNO); var StartingPoints = DestWorld.GetActorsBySNO(5502); foreach (var ST in StartingPoints) { if (ST.CurrentScene.SceneSNO.Id == this.Destination.StartingPointActorTag) { NeededStartingPoint = (ST as StartingPoint); } } player.ChangeWorld(DestWorld, NeededStartingPoint); } #endregion else { Logger.Warn("Portal's tagged starting point does not exist (Tag = {0})", this.Destination.StartingPointActorTag); } } } }