public bool IsInsideCube(VectorDto volumeCenter, float sideEdgeLength) { float halfSideLength = sideEdgeLength / 2.0f; if (Position.x < volumeCenter.x - halfSideLength) { return(false); } if (Position.x > volumeCenter.x + halfSideLength) { return(false); } if (Position.y < volumeCenter.y - halfSideLength) { return(false); } if (Position.y > volumeCenter.y + halfSideLength) { return(false); } if (Position.z < volumeCenter.z - halfSideLength) { return(false); } if (Position.z > volumeCenter.z + halfSideLength) { return(false); } return(true); }
public static CharacterPositions GetAllInVolume(VectorDto volumeCenter, TargetVolume volume, float dimensionFeet1, float dimensionFeet2 = 0, float dimensionFeet3 = 0) { float dimensionTiles1 = Convert.FeetToTiles(dimensionFeet1); float dimensionTiles2 = Convert.FeetToTiles(dimensionFeet2); float dimensionTiles3 = Convert.FeetToTiles(dimensionFeet3); List <CharacterPosition> characterPositions = GetAll().ToList().ConvertAll(x => x.GetCharacterPosition()); switch (volume) { case TargetVolume.Sphere: return(GetAllInSphere(characterPositions, volumeCenter, dimensionTiles1)); case TargetVolume.Cube: return(GetAllInCube(characterPositions, volumeCenter, dimensionTiles1)); case TargetVolume.Circle: return(GetAllInCircle(characterPositions, volumeCenter, dimensionTiles1)); case TargetVolume.Cylinder: return(GetAllInCylinder(characterPositions, volumeCenter, dimensionTiles1, dimensionTiles2)); case TargetVolume.Cone: return(GetAllInCone(characterPositions, volumeCenter, dimensionTiles1, dimensionTiles2)); case TargetVolume.Square: return(GetAllInSquare(characterPositions, volumeCenter, dimensionTiles1)); } return(null); }
public bool IsInsideSquare(VectorDto volumeCenter, float sideEdgeLength) { float halfSideLength = sideEdgeLength / 2.0f; if (!OnSameLevel(volumeCenter)) { return(false); } if (Position.x < volumeCenter.x - halfSideLength) { return(false); } if (Position.x > volumeCenter.x + halfSideLength) { return(false); } if (Position.z < volumeCenter.z - halfSideLength) { return(false); } if (Position.z > volumeCenter.z + halfSideLength) { return(false); } return(true); }
public bool IsInsideCircle(VectorDto volumeCenter, float radius) { if (!OnSameLevel(volumeCenter)) { return(false); } float distance = (float)Math.Sqrt(volumeCenter.x * volumeCenter.x + volumeCenter.z * volumeCenter.z); return(distance < radius); }
public static CharacterPositions GetAllCreaturesInVolume(VectorDto vectorDto, string shape, string dimensionStr, string whatSide = "All") { whatSide = whatSide.Replace(',', '|'); ApiResponse response = Invoke("GetAllCreaturesInVolume", new string[] { vectorDto.GetXyzStr(), shape, dimensionStr, whatSide }); if (response == null || response.Result == ResponseType.Failure) { return(null); } return(response.GetData <CharacterPositions>()); }
public static VectorDto GetTargetedPoint() { FlashLight flashLight = Flashlight.Get(); if (flashLight != null) { if (TargetingVolume != null) { MoveTargetingPrefabToWorld(flashLight); } Vector3 position = flashLight.transform.position; VectorDto result = new VectorDto(position.x, position.y, position.z); Off(); InteractiveTargetingMode = InteractiveTargetingMode.None; return(result); } return(null); }
void SetOriginalScale() { OriginalScale = new VectorDto(1, 1, 1); if (GameObject == null) { return; } Transform transform = GameObject.transform; if (transform == null) { return; } Vector3 localScale = transform.localScale; if (localScale == null) { return; } OriginalScale = localScale.GetVectorDto(); }
public static void LookAtPoint(VectorDto point) { Invoke("LookAtPoint", point.GetXyzStr()); }
static CharacterPositions GetAllInCircle(List <CharacterPosition> characterPositions, VectorDto volumeCenter, float diameter) { CharacterPositions result = new CharacterPositions(); foreach (CharacterPosition characterPosition in characterPositions) { if (characterPosition.IsInsideCircle(volumeCenter, diameter / 2.0f)) { result.Characters.Add(characterPosition); } } return(result); }
public static void BuildRingedWall(string effectName, string spellId, float wallLength, float distanceBetweenWallEffectsFeet, float lifeTime, float enlargeTime, float secondsDelayStart, float shrinkTime, float rotationDegrees, VectorDto targetPoint, float ringDiameter) { Invoke("BuildRingedWall", new string[] { effectName, spellId, wallLength.ToString(), distanceBetweenWallEffectsFeet.ToString(), lifeTime.ToString(), enlargeTime.ToString(), secondsDelayStart.ToString(), shrinkTime.ToString(), rotationDegrees.ToString(), targetPoint.GetXyzStr(), ringDiameter.ToString() }); }
public static void PlayEffectAtPosition(string effectName, string spellId, VectorDto vector, float lifeTime = 0, float enlargeTime = 0, float secondsDelayStart = 0, float shrinkTime = 0, float rotation = 0, bool isMoveable = false) { Invoke("PlayEffectAtPosition", new string[] { effectName, spellId, vector.GetXyzStr(), lifeTime.ToString(), enlargeTime.ToString(), secondsDelayStart.ToString(), shrinkTime.ToString(), rotation.ToString(), isMoveable.ToString() }); }
static CharacterPositions GetAllInCylinder(List <CharacterPosition> characterPositions, VectorDto volumeFloorCenter, float diameter, float height) { CharacterPositions result = new CharacterPositions(); Vector3 floorCenter = volumeFloorCenter.GetVector3(); Vector3 floorCenter2d = new Vector3(floorCenter.x, 0, floorCenter.z); float verticalSlop = 0.5f; // Amount above/below cylinder to include in the target. float floorY = volumeFloorCenter.y - verticalSlop; float ceilingY = floorY + height + verticalSlop; float radius = diameter / 2f; foreach (CharacterPosition characterPosition in characterPositions) { // TODO: Thinking about adding a "slop" to take creature size (radius & height) into account. bool inVerticalRange = characterPosition.Position.y >= floorY && characterPosition.Position.y <= ceilingY; if (inVerticalRange) { Vector3 position = characterPosition.Position.GetVector3(); Vector3 position2d = new Vector3(position.x, 0, position.z); Vector3 delta = position2d - floorCenter2d; float distanceFromCenter = delta.magnitude; if (distanceFromCenter < radius) { result.Characters.Add(characterPosition); } } } return(result); }
static CharacterPositions GetAllInCone(List <CharacterPosition> characterPositions, VectorDto volumeCenter, float dimension1, float dimension2) { // TODO: Implement this. return(null); }
public bool IsInsideSphere(VectorDto volumeCenter, float radius) { float distance = (float)Math.Sqrt(volumeCenter.x * volumeCenter.x + volumeCenter.y * volumeCenter.y + volumeCenter.z * volumeCenter.z); return(distance < radius); }
static CharacterPositions GetAllInSquare(List <CharacterPosition> characterPositions, VectorDto volumeCenter, float sideEdgeLength) { CharacterPositions result = new CharacterPositions(); foreach (CharacterPosition characterPosition in characterPositions) { if (characterPosition.IsInsideSquare(volumeCenter, sideEdgeLength)) { result.Characters.Add(characterPosition); } } return(result); }
public static void SpinAroundPoint(VectorDto point) { Invoke("SpinAroundPoint", point.GetXyzStr()); }
public static CharacterPositions GetAllInCircle(VectorDto volumeCenter, float diameterFeet) { float diameterTiles = Convert.FeetToTiles(diameterFeet); return(GetAllInCircle(GetAllCharacterPositions(), volumeCenter, diameterTiles)); }
public static CharacterPositions GetAllInSquare(VectorDto volumeCenter, float sideEdgeLengthFeet) { float sideEdgeLengthTiles = Convert.FeetToTiles(sideEdgeLengthFeet); return(GetAllInSquare(GetAllCharacterPositions(), volumeCenter, sideEdgeLengthTiles)); }
public static Vector3 ToVector3(string vectorStr) { VectorDto vectorDto = ToVectorDto(vectorStr); return(vectorDto.GetVector3()); }
private bool OnSameLevel(VectorDto volumeCenter) { float distanceFromY = Math.Abs(volumeCenter.y - Position.y); return(distanceFromY <= 3); }