Пример #1
0
    //Erases a particular type of ability within range of the desired position.
    public static void EraseRange(this GridCS GridScript, Vector2 Position, Tile.OverlayType DesiredErase, int MaxRange, int LayerNumber)
    {
        int MinPosX = ((int)Position.x) - MaxRange;
        int MinPosZ = ((int)Position.y) - MaxRange;

        for (int thisPositionX = 0; thisPositionX <= 2 * MaxRange + 1; thisPositionX++)
        {
            for (int thisPositionZ = 0; thisPositionZ <= 2 * MaxRange + 1; thisPositionZ++)
            {
                for (int layer = 0; layer <= GridCS.Instance.grid.GetLength(2) - 1; layer++)
                {
                    Vector2 TileLocation = new Vector2(MinPosX + thisPositionX, MinPosZ + thisPositionZ);
                    if (CheckIfRangeIsInBounds(GridScript, TileLocation, layer))
                    {
                        Tile ThisTile = GetTile(GridScript, TileLocation, layer);
                        if (ThisTile != null)
                        {
                            if (ThisTile.TileSelectionType == DesiredErase)
                            {
                                ThisTile.TileSelectionType = Tile.OverlayType.Unselected;
                            }
                        }
                    }
                }
            }
        }
    }
Пример #2
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //Finds all enemies in a circular range of a space, sets the tiles to be selectable in the desired way.
    public static void CalculateCircularRange(this GridCS GridScript, Vector2 Position, Tile.OverlayType DesiredOverlay, int MinRange, int MaxRange, GridCS.PlayerNumber CurrentPlayer, bool FindEnemies, bool findAllies, bool findEmptyTiles, int LayerNumber)
    {
        int MinPosX = ((int)Position.x) - MaxRange;
        int MinPosZ = ((int)Position.y) - MaxRange;

        for (int thisPositionX = 0; thisPositionX <= 2 * MaxRange + 1; thisPositionX++)
        {
            for (int thisPositionZ = 0; thisPositionZ <= 2 * MaxRange + 1; thisPositionZ++)
            {
                Vector2 ThisPosition = new Vector2(MinPosX + thisPositionX, MinPosZ + thisPositionZ);
                double  hypotenuse   = CalculateTwoDiminsionalDistance(Position, ThisPosition);
                if (hypotenuse <= MaxRange && hypotenuse >= MinRange)
                {
                    if (CheckIfRangeIsInBounds(GridScript, ThisPosition, LayerNumber))
                    {
                        Tile ThisTile = GetTile(GridScript, ThisPosition, LayerNumber);
                        if (ThisTile != null)
                        {
                            if (FindEnemies)
                            {
                                if (ThisTile.LoadedUnitScript != null && ThisTile.LoadedUnitScript.Owner != CurrentPlayer)
                                {
                                    ThisTile.TileSelectionType = DesiredOverlay;
                                }
                            }
                            else if (findAllies)
                            {
                                if (ThisTile.LoadedUnitScript != null && ThisTile.LoadedUnitScript.Owner == CurrentPlayer)
                                {
                                    ThisTile.TileSelectionType = DesiredOverlay;
                                }
                            }
                            else if (findEmptyTiles)
                            {
                                ThisTile.TileSelectionType = DesiredOverlay;
                            }
                        }
                    }
                }
            }
        }
    }