Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
            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);
            }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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>());
        }
Ejemplo n.º 6
0
            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);
            }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
 public static void LookAtPoint(VectorDto point)
 {
     Invoke("LookAtPoint", point.GetXyzStr());
 }
Ejemplo n.º 9
0
            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);
            }
Ejemplo n.º 10
0
 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() });
 }
Ejemplo n.º 11
0
 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() });
 }
Ejemplo n.º 12
0
            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);
            }
Ejemplo n.º 13
0
 static CharacterPositions GetAllInCone(List <CharacterPosition> characterPositions, VectorDto volumeCenter, float dimension1, float dimension2)
 {
     // TODO: Implement this.
     return(null);
 }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
            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);
            }
Ejemplo n.º 16
0
 public static void SpinAroundPoint(VectorDto point)
 {
     Invoke("SpinAroundPoint", point.GetXyzStr());
 }
Ejemplo n.º 17
0
            public static CharacterPositions GetAllInCircle(VectorDto volumeCenter, float diameterFeet)
            {
                float diameterTiles = Convert.FeetToTiles(diameterFeet);

                return(GetAllInCircle(GetAllCharacterPositions(), volumeCenter, diameterTiles));
            }
Ejemplo n.º 18
0
            public static CharacterPositions GetAllInSquare(VectorDto volumeCenter, float sideEdgeLengthFeet)
            {
                float sideEdgeLengthTiles = Convert.FeetToTiles(sideEdgeLengthFeet);

                return(GetAllInSquare(GetAllCharacterPositions(), volumeCenter, sideEdgeLengthTiles));
            }
Ejemplo n.º 19
0
            public static Vector3 ToVector3(string vectorStr)
            {
                VectorDto vectorDto = ToVectorDto(vectorStr);

                return(vectorDto.GetVector3());
            }
Ejemplo n.º 20
0
        private bool OnSameLevel(VectorDto volumeCenter)
        {
            float distanceFromY = Math.Abs(volumeCenter.y - Position.y);

            return(distanceFromY <= 3);
        }