// Token: 0x06000286 RID: 646 RVA: 0x0001562C File Offset: 0x0001382C public virtual void AddDrawableAbility(List <IDrawableAbility> drawableAbilities, Unit unit, INotificator notificator) { Entity owner = unit.Owner; if (owner == null) { return; } string name = owner.Name; Vector3 position = unit.Position; DrawableUnitAbility drawableUnitAbility = new DrawableUnitAbility { AbilityTexture = this.AbilityId + "_rounded", HeroTexture = name + "_rounded", MinimapHeroTexture = name + "_icon", Position = position.SetZ(new float?(Math.Min(position.Z, 350f))), Unit = unit, IsShowingRange = this.ShowRange, RangeColor = this.RangeColor, Range = this.Range, Duration = this.Duration, ShowUntil = Game.RawGameTime + this.Duration, ShowHeroUntil = Game.RawGameTime + this.TimeToShow, ShowTimer = this.ShowTimer, Owner = owner }; drawableUnitAbility.DrawRange(); drawableAbilities.Add(drawableUnitAbility); if (this.ShowNotification && notificator != null) { notificator.PushNotification(new AbilityNotification(name, this.AbilityId.ToString())); } }
// Token: 0x06000316 RID: 790 RVA: 0x0001B808 File Offset: 0x00019A08 public override void AddDrawableAbility(List <IDrawableAbility> drawableAbilities, ParticleEffect particle, Team allyTeam, INotificator notificator) { Unit9 unit = EntityManager9.GetUnit(particle.Owner.Handle); if (unit == null || unit.IsVisible) { return; } Vector3 v = base.RawParticlePosition ? particle.Position : particle.GetControlPoint(base.ControlPoint); if (v.Distance2D(unit.BaseUnit.Position, false) < 50f) { return; } string name = unit.Name; DrawableAbility drawableAbility = new DrawableAbility { AbilityTexture = base.AbilityId + "_rounded", HeroTexture = name + "_rounded", MinimapHeroTexture = name + "_icon", ShowUntil = Game.RawGameTime + base.TimeToShow, Position = v.SetZ(new float?((float)350)) }; if (base.Replace) { IDrawableAbility drawableAbility2 = drawableAbilities.LastOrDefault((IDrawableAbility x) => x.AbilityTexture == drawableAbility.AbilityTexture && x.HeroTexture == drawableAbility.HeroTexture); if (drawableAbility2 != null) { drawableAbilities.Remove(drawableAbility2); } } drawableAbilities.Add(drawableAbility); }
public static Vector3 SnapToGridCenter(Vector3 position) { Vector3 newPosition = position; newPosition = newPosition.SetY(0.0f); int clampedX = MathUtil.Clamp((int)newPosition.x, (int)-LevelEditorConstants.kArenaHalfWidth + 1, (int)LevelEditorConstants.kArenaHalfWidth - 1); int clampedZ = MathUtil.Clamp((int)newPosition.z, (int)-LevelEditorConstants.kArenaHalfHeight + 1, (int)LevelEditorConstants.kArenaHalfHeight - 1); float newX = clampedX; float newZ = clampedZ; if (clampedX != 0) { newX += (clampedX > 0.0f) ? LevelEditorConstants.kHalfGridSize : -LevelEditorConstants.kHalfGridSize; } else { newX = position.x >= 0.0f ? LevelEditorConstants.kHalfGridSize : -LevelEditorConstants.kHalfGridSize; } if (clampedZ != 0) { newZ += (clampedZ > 0.0f) ? LevelEditorConstants.kHalfGridSize : -LevelEditorConstants.kHalfGridSize; } else { newZ = position.z >= 0.0f ? LevelEditorConstants.kHalfGridSize : -LevelEditorConstants.kHalfGridSize; } newPosition = newPosition.SetX(newX); newPosition = newPosition.SetZ(newZ); return(newPosition); }
private void Update() { if (inputDevice_ == null) { return; } if (locked_) { return; } Vector3 newPosition = this.transform.position + (inputDevice_.LeftStick.Value.Vector3XZValue() * kCursorSpeed); newPosition = newPosition.SetX(Mathf.Clamp(newPosition.x, -LevelEditorConstants.kArenaHalfWidth, LevelEditorConstants.kArenaHalfWidth)); newPosition = newPosition.SetZ(Mathf.Clamp(newPosition.z, -LevelEditorConstants.kArenaHalfHeight, LevelEditorConstants.kArenaHalfHeight)); Vector3 oldPosition = this.transform.position; this.transform.position = newPosition; if (oldPosition != this.transform.position) { OnMoved.Invoke(); } }
public static Vector3 SnapToVertex(Vector3 position) { Vector3 newPosition = position; newPosition = newPosition.SetY(0.0f); newPosition = newPosition.SetX(Mathf.Round(newPosition.x)); newPosition = newPosition.SetZ(Mathf.Round(newPosition.z)); return(newPosition); }
public uint? AddObstacle(Vector3 position, float radius, uint? obstacle = null, int forceZ = 600) { if (obstacle != null) { RemoveObstacle(obstacle.Value); } //todo delete setz after intersection fix return Pathfinding.AddObstacle(position.SetZ(forceZ), radius); }
public void set_z_test() { //Arrange Vector3 input = Vector3.zero; //Act input = input.SetZ(1); //Assert Assert.AreEqual(0, input.x); Assert.AreEqual(0, input.y); Assert.AreEqual(1, input.z); }
// Token: 0x0600030D RID: 781 RVA: 0x0001B590 File Offset: 0x00019790 public override void AddDrawableAbility(List <IDrawableAbility> drawableAbilities, ParticleEffect particle, Team allyTeam, INotificator notificator) { if (particle.Name.Contains("dash")) { drawableAbilities.RemoveAll((IDrawableAbility x) => x is DrawableFireRemnantAbility); return; } Unit9 unit = EntityManager9.GetUnit(particle.Owner.Owner.Handle); if (unit == null) { return; } Vector3 startPosition = particle.GetControlPoint(this.StartControlPoint); if (!unit.IsVisible) { DrawableAbility item = new DrawableAbility { AbilityTexture = base.AbilityId + "_rounded", HeroTexture = unit.Name + "_rounded", MinimapHeroTexture = unit.Name + "_icon", ShowUntil = Game.RawGameTime + base.TimeToShow, Position = startPosition.SetZ(new float?((float)350)) }; drawableAbilities.Add(item); } DrawableFireRemnantAbility[] remnants = drawableAbilities.OfType <DrawableFireRemnantAbility>().ToArray <DrawableFireRemnantAbility>(); Unit unit2 = ObjectManager.GetEntitiesFast <Unit>().Concat(ObjectManager.GetDormantEntities <Unit>()).FirstOrDefault((Unit x) => x.IsAlive && x.Name == "npc_dota_ember_spirit_remnant" && x.Distance2D(startPosition) < 1500f && remnants.All((DrawableFireRemnantAbility z) => z.Unit != x)); if (unit2 == null) { return; } DrawableFireRemnantAbility item2 = new DrawableFireRemnantAbility { AbilityTexture = base.AbilityId + "_rounded", HeroTexture = unit.Name + "_rounded", MinimapHeroTexture = unit.Name + "_icon", Position = particle.GetControlPoint(base.ControlPoint).SetZ(new float?((float)350)), Duration = base.Duration, ShowUntil = Game.RawGameTime + base.Duration, ShowHeroUntil = Game.RawGameTime + base.TimeToShow, Owner = unit.BaseEntity, Unit = unit2 }; drawableAbilities.Add(item2); }
private Vector3 SnappedToHintedVertex(Vector3 position, Vector3 hintVector) { // NOTE (darren): this doesn't respect grid size - would need to scale vectors by grid size first Vector3 snapped = position; if (!Mathf.Approximately(hintVector.x, 0.0f)) { snapped = snapped.SetX(hintVector.x > 0.0f ? Mathf.Ceil(snapped.x) : Mathf.Floor(snapped.x)); } if (!Mathf.Approximately(hintVector.z, 0.0f)) { snapped = snapped.SetZ(hintVector.z > 0.0f ? Mathf.Ceil(snapped.z) : Mathf.Floor(snapped.z)); } return(snapped); }
public uint? AddObstacle( Vector3 startPosition, Vector3 endPosition, float width, uint? obstacle = null, int forceZ = 600) { if (obstacle != null) { RemoveObstacle(obstacle.Value); } //todo delete setz after intersection fix return Pathfinding.AddObstacle(startPosition.SetZ(forceZ), endPosition.SetZ(forceZ), width); }
// Token: 0x060002F8 RID: 760 RVA: 0x0001B2C0 File Offset: 0x000194C0 public override void AddDrawableAbility(List <IDrawableAbility> drawableAbilities, ParticleEffect particle, Team allyTeam, INotificator notificator) { Vector3 position = base.RawParticlePosition ? particle.Position : particle.GetControlPoint(base.ControlPoint); if (position.IsZero) { Logger.Error("ParticleZero", particle.Name); return; } Ability9 ability = (from x in EntityManager9.Abilities where x.Id == this.AbilityId && x.Owner.CanUseAbilities orderby x.Owner.Position.Distance2D(position, false) select x).FirstOrDefault <Ability9>(); Unit9 unit = (ability != null) ? ability.Owner : null; if (unit == null || unit.IsVisible || unit.Team == allyTeam) { return; } string name = unit.Name; DrawableAbility drawableAbility = new DrawableAbility { AbilityTexture = base.AbilityId + "_rounded", HeroTexture = name + "_rounded", MinimapHeroTexture = name + "_icon", ShowUntil = Game.RawGameTime + base.TimeToShow, Position = position.SetZ(new float?((float)350)) }; if (base.Replace) { IDrawableAbility drawableAbility2 = drawableAbilities.LastOrDefault((IDrawableAbility x) => x.AbilityTexture == drawableAbility.AbilityTexture && x.HeroTexture == drawableAbility.HeroTexture); if (drawableAbility2 != null) { drawableAbilities.Remove(drawableAbility2); } } drawableAbilities.Add(drawableAbility); if (base.ShowNotification && notificator != null) { notificator.PushNotification(new AbilityNotification(name, base.AbilityId.ToString())); } }
private void RefreshPreviewObjectValidity() { if (PreviewObject_ == null) { return; } Vector3 halfExtents = this.transform.localScale / 2.0f; halfExtents = halfExtents.SetX(halfExtents.x - 0.1f); halfExtents = halfExtents.SetZ(halfExtents.z - 0.1f); bool hit = Physics.BoxCast(this.transform.position + Vector3.up, halfExtents: halfExtents, direction: -Vector3.up, orientation: Quaternion.identity, maxDistance: Mathf.Infinity, layerMask: InGameConstants.PlatformsLayerMask); foreach (var renderer in PreviewObject_.GetComponentsInChildren <Renderer>()) { renderer.material.color = hit ? Color.red : Color.green; } }
void Update() { if (!dragEnable) { return; } if (Input.GetMouseButtonDown(0)) { startRatate = true; lastMousePos = Input.mousePosition; startTime = Time.time; return; } else if (Input.GetMouseButtonUp(0)) { startRatate = false; return; } if (startRatate) { Vector3 offset = Input.mousePosition - lastMousePos; lastMousePos = Input.mousePosition; objRotY += Vector3.Cross(offset, Vector3.forward).normalized.y *Mathf.Abs(offset.x) * hSpeed; objRotY %= 360f; if (float.IsNaN(curRotYVel)) { curRotYVel = 0.0f; } } else { objRotY += 0.03f; objRotY %= 360f; } float newCameraRotSide = Mathf.SmoothDampAngle(targetRotation.z, objRotY, ref curRotYVel, rotDampingDuration); newCameraRotSide = newCameraRotSide == 0 ? 0.1f : newCameraRotSide; targetRotation = targetRotation.SetZ(newCameraRotSide); this.transform.localEulerAngles = targetRotation; targetRotation = this.transform.localEulerAngles; }
public static bool IsPositionOnScreen(Vector3 position) { if (position.Z == 0) { //todo get proper Z if (Drawing.WorldToScreen(position.SetZ(128), out _) && Drawing.WorldToScreen(position.SetZ(384), out _)) { return(true); } } else { if (Drawing.WorldToScreen(position, out _)) { return(true); } } return(false); }
Vector3 ApplyTransform(Vector3 v, string dir, float value, bool clamp = false) { string axis = dir.Substring(dir.Length - 1); value = dir.Length == 1 ? value : -value; if (axis == "x") { float x = Angle.ToStardard(v.x) + value; return(v.SetX(clamp? Mathf.Clamp(x, -80, 80): x)); } else if (axis == "y") { float y = Angle.ToStardard(v.y) + value; return(v.SetY(clamp? Mathf.Clamp(y, -80, 80): y)); } else { float z = Angle.ToStardard(v.z) + value; return(v.SetZ(clamp? Mathf.Clamp(z, -80, 80): z)); } }
private void RefreshGuideLines() { // assumption is 1x1 block still Vector3 minPoint = this.transform.position - (this.transform.localScale / 2.0f); Vector3 maxPoint = this.transform.position + (this.transform.localScale / 2.0f); minPoint = minPoint.SetY(0.0f); maxPoint = maxPoint.SetY(0.0f); Vector3 topRightPoint = maxPoint; Vector3 topLeftPoint = maxPoint.SetX(minPoint.x); Vector3 bottomLeftPoint = minPoint; Vector3 bottomRightPoint = minPoint.SetX(maxPoint.x); Vector3 gridTopRightPoint = topRightPoint.SetZ(LevelEditorConstants.kArenaHalfHeight); Vector3 gridRightTopPoint = topRightPoint.SetX(LevelEditorConstants.kArenaHalfWidth); topRightLineRenderer_.positionCount = 4; topRightLineRenderer_.SetPositions(new Vector3[] { topRightPoint, gridTopRightPoint, topRightPoint, gridRightTopPoint }); Vector3 gridTopLeftPoint = topLeftPoint.SetZ(LevelEditorConstants.kArenaHalfHeight); Vector3 gridLeftTopPoint = topLeftPoint.SetX(-LevelEditorConstants.kArenaHalfWidth); topLeftLineRenderer_.positionCount = 4; topLeftLineRenderer_.SetPositions(new Vector3[] { topLeftPoint, gridTopLeftPoint, topLeftPoint, gridLeftTopPoint }); Vector3 gridBottomRightPoint = bottomRightPoint.SetZ(-LevelEditorConstants.kArenaHalfHeight); Vector3 gridRightBottomPoint = bottomRightPoint.SetX(LevelEditorConstants.kArenaHalfWidth); bottomRightLineRenderer_.positionCount = 4; bottomRightLineRenderer_.SetPositions(new Vector3[] { bottomRightPoint, gridBottomRightPoint, bottomRightPoint, gridRightBottomPoint }); Vector3 gridBottomLeftPoint = bottomLeftPoint.SetZ(-LevelEditorConstants.kArenaHalfHeight); Vector3 gridLeftBottomPoint = bottomLeftPoint.SetX(-LevelEditorConstants.kArenaHalfWidth); bottomLeftLineRenderer_.positionCount = 4; bottomLeftLineRenderer_.SetPositions(new Vector3[] { bottomLeftPoint, gridBottomLeftPoint, bottomLeftPoint, gridLeftBottomPoint }); }
public void UpdateObstacle(uint id, Vector3 startPosition, Vector3 endPosition, int forceZ = 600) { //todo delete setz after intersection fix Pathfinding.UpdateObstacle(id, startPosition.SetZ(forceZ), endPosition.SetZ(600)); }
public void UpdateObstacle(uint id, Vector3 position, float startWidth, float endWidth, int forceZ = 600) { // FAIL // Pathfinding.UpdateObstacle(id, position, startWidth, endWidth); //todo delete setz after intersection fix Pathfinding.UpdateObstacle(id, position.SetZ(forceZ), endWidth, endWidth); }
public void UpdateObstacle(uint id, Vector3 position, float radius, int forceZ = 600) { //todo delete setz after intersection fix Pathfinding.UpdateObstacle(id, position.SetZ(forceZ), radius); }
void Update() { if(playerCards == null || opponentCards == null) return; //set up card cost glowing material first time if (cardGlowMat == null && playerCards.Count > 1) { cardOutlineMat = playerCards[0].cardView.costText.fontSharedMaterial; cardGlowMat = new Material(cardOutlineMat); cardGlowMat.SetFloat(ShaderUtilities.ID_GlowPower, 0.4f); cardGlowMat.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.0f); } //position opponents cards //might need to DRY it up sometime but rule of three still holds cardAngleSpread = -13f + (0.8f * opponentCards.Count); for(int c = 0; c < opponentCards.Count; c++) { var card = opponentCards[c]; if(card.activated) continue; var rectTransform = card.rectTransform; var cardCountOffset = 0 - ((opponentCards.Count - 1) / 2) + c; rectTransform.rotation = Quaternion.Euler(new Vector3(0, 0, 180f + cardCountOffset * cardAngleSpread)); rectTransform.Rotate(Vector3.up, 180f, Space.Self); dest = PointOnCircle(cardCircleRadius, 270f + cardCountOffset * cardAngleSpread, opponentCardCircleCenter); dest = dest.SetZ(dest.z + (-1.0f * c)); rectTransform.anchorMax = opponentAnchorPosition; rectTransform.anchorMin = opponentAnchorPosition; rectTransform.pivot = opponentAnchorPosition; rectTransform.anchoredPosition3D = iTween.Vector3Update(rectTransform.anchoredPosition3D, dest, 10.0f); } //and now players cards cardAngleSpread = -16f + (1.2f * playerCards.Count); for(int c = 0; c < playerCards.Count; c++) { var card = playerCards[c]; if(card.activated) continue; var rectTransform = card.rectTransform; var cardCountOffset = 0 - ((playerCards.Count - 1) / 2) + c; rectTransform.rotation = Quaternion.Euler(new Vector3(0, 0, cardCountOffset * cardAngleSpread)); dest = PointOnCircle(cardCircleRadius, 90f + cardCountOffset * cardAngleSpread, cardCircleCenter); dest = dest.SetZ(dest.z + (-1.0f * c)); //drag the selected card with the cursor if (selectedCard != null && card.id == selectedCard.card.id) { var mouseWorld = cardCanvasHelper.MouseToWorld(dest.z); var dragPos = new Vector3(mouseWorld.x + selectedCard.point.x, mouseWorld.y + selectedCard.point.y, mouseWorld.z); dragPos = dragPos.SetY(dragPos.y + cardDimensions.y * canvas.scaleFactor); var dragDist = Vector3.Distance(dragPos, dest); if (dragDist < maxDragDistance || !selectedNeedsArrow) { rectTransform.rotation = Quaternion.Euler(new Vector3(0, 0, 0)); rectTransform.anchoredPosition3D = dragPos; continue; } else { dest = dest.SetY(dest.y + 30f); } } //show the hover card on top of where the actual card is after a delay if (hoveredCard != null && card == hoveredCard && (selectedCard == null || hoveredCard != selectedCard.card)) { dest = dest.SetY(dest.y + 30f); hoverAccumulator += Time.deltaTime; if (hoverAccumulator > CardView.HOVER_DELAY) { card.cardView.displayWrapper.SetActive(false); } } rectTransform.anchorMax = anchorPosition; rectTransform.anchorMin = anchorPosition; rectTransform.pivot = anchorPosition; rectTransform.anchoredPosition3D = iTween.Vector3Update(rectTransform.anchoredPosition3D, dest, 10.0f); if (card.playable && cardGlowMat != null) { card.cardView.costText.fontMaterial = cardGlowMat; } else if(cardOutlineMat != null) { card.cardView.costText.fontMaterial = cardOutlineMat; } } }