private void SetPath() { int step; int x = endX; int y = endY; List <GameObject> tempList = new List <GameObject>(); //Path.Clear(); if (gridArray[endX, endY]) { GridStats gridStats = gridArray[endX, endY].GetComponent <GridStats>(); if (gridStats.visited > 0) { path.Push(gridArray[x, y]); } step = gridStats.visited - 1; } else { print("Can't reach the desired location"); return; } for (int i = step; step > -1; step--) { if (TestDirection(x, y, step, 1)) { tempList.Add(gridArray[x, y + 1]); } if (TestDirection(x, y, step, 2)) { tempList.Add(gridArray[x + 1, y]); } if (TestDirection(x, y, step, 3)) { tempList.Add(gridArray[x, y - 1]); } if (TestDirection(x, y, step, 4)) { tempList.Add(gridArray[x - 1, y]); } GameObject tempObj = FindClosest(gridArray[endX, endY].transform, tempList); path.Push(tempObj); GridStats gridStats = tempObj.GetComponent <GridStats>(); x = gridStats.x; y = gridStats.y; tempList.Clear(); } }
public void Repaint(PlayerDamageDealt playerDamageDealt, PlayerHealDealt playerHealDealt, EntityInformation entityInformation, Database.Structures.Skills skills, PlayerAbnormals buffs, bool timedEncounter) { PlayerHealDealt = playerHealDealt; EntityInformation = entityInformation; PlayerDamageDealt = playerDamageDealt; _buffs = buffs; _timedEncounter = timedEncounter; Skills = skills; LabelDps.Content = GlobalDps; LabelDps.ToolTip = $"{LP.Individual_dps}: {Dps}"; LabelCritRate.Content = PlayerDamageDealt.Source.IsHealer && BasicTeraData.Instance.WindowData.ShowHealCrit ? CritRateHeal : BasicTeraData.Instance.WindowData.ShowCritDamageRate ? CritDamageRate : CritRate; var intervalTimespan = TimeSpan.FromSeconds(PlayerDamageDealt.Interval / TimeSpan.TicksPerSecond); LabelCritRate.ToolTip = $"{LP.Fight_Duration}: {intervalTimespan.ToString(@"mm\:ss")}"; LabelCritRate.Foreground = PlayerDamageDealt.Source.IsHealer && BasicTeraData.Instance.WindowData.ShowHealCrit ? Brushes.LawnGreen : BasicTeraData.Instance.WindowData.ShowCritDamageRate ? Brushes.Orange : Brushes.LightCoral; LabelDamagePart.Content = DamagePart; LabelDamagePart.ToolTip = $"{LP.Damage_done}: {Damage}"; _windowSkill?.Update(PlayerDamageDealt, EntityInformation, Skills, _buffs, _timedEncounter); Spacer.Width = 0; GridStats.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); var SGrid = ((MainWindow)((FrameworkElement)((FrameworkElement)((FrameworkElement)Parent).Parent).Parent).Parent).SGrid; var EGrid = ((MainWindow)((FrameworkElement)((FrameworkElement)((FrameworkElement)Parent).Parent).Parent).Parent).EGrid; SGrid.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); var mainWidth = SGrid.DesiredSize.Width; Spacer.Width = mainWidth > GridStats.DesiredSize.Width ? mainWidth - GridStats.DesiredSize.Width : 0; var an = new DoubleAnimation(DpsIndicator.ActualWidth, EntityInformation.TotalDamage == 0 ? mainWidth : mainWidth * PlayerDamageDealt.Amount / EntityInformation.TotalDamage, TimeSpan.FromMilliseconds(400)) { EasingFunction = new QuadraticEase() }; DpsIndicator.BeginAnimation(WidthProperty, an); EGrid.MaxWidth = Math.Max(mainWidth, GridStats.DesiredSize.Width); }
private void Update() { if (Input.GetMouseButtonUp(0)) { RaycastHit hit; Ray ray = _mainCamera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { startX = movingPlayer.PositionX; startY = movingPlayer.PositionY; GridStats gridStats = hit.collider.gameObject.GetComponent <GridStats>(); endX = gridStats.x; endY = gridStats.y; SetDistance(); SetPath(); StartCoroutine(MovePlayer()); } } }
private void SetDistance() { InitialSetUp(); int x = startX; int y = startY; int[] testArray = new int[rows * columns]; for (int step = 1; step < rows * columns; step++) { foreach (GameObject obj in gridArray) { if (obj) { GridStats gridStats = obj.GetComponent <GridStats>(); if (gridStats.visited == step - 1 && !gridStats.isBlocked) { TestFourDirection(gridStats.x, gridStats.y, step); } } } } }