RoomManager.placePath C# (CSharp) 메소드

placePath() 공개 메소드

public placePath ( float current, float next, float moveX, float moveY ) : void
current float
next float
moveX float
moveY float
리턴 void
    void placePath(float[] current, float[] next, float moveX, float moveY)
    {
        float currentX = current [0];
        float currentY = current [1];
        float nextX = next [0];
        float nextY = next [1];

        if (currentX > 1 && currentX < this.roomSide * this.rows - 1 && currentY > 1 && currentY < this.roomSide * this.columns - 1) {

            while (((int)Mathf.Floor(currentX) != (int)Mathf.Floor(nextX) &&
               (int)Mathf.Floor(currentY) != (int)Mathf.Floor(nextY)) ||

                ((int)Mathf.Floor(currentX) == (int)Mathf.Floor(nextX) &&
                (int)Mathf.Floor(currentY) != (int)Mathf.Floor(nextY))) {

                Tile tile = this.tileMap [(int)Mathf.Floor (currentX), (int)Mathf.Floor (currentY)];
                //DONT TOUCH MY MAGIC IF BLOCK - IAN
                if (currentX - 1 > 3) {
                    Tile westTile = this.tileMap [(int)Mathf.Floor (currentX) - 1, (int)Mathf.Floor (currentY)];
                    westTile.path = true;
                    westTile.blocking = true;
                }
                if (currentX + 1 < (this.roomSide * this.rows) - 3) {
                    Tile eastTile = this.tileMap [(int)Mathf.Floor (currentX) + 1, (int)Mathf.Floor (currentY)];
                    eastTile.path = true;
                    eastTile.blocking = true;
                }
                if (currentY + 1 < (this.roomSide * this.columns) - 3) {
                    Tile northTile = this.tileMap [(int)Mathf.Floor (currentX), (int)Mathf.Floor (currentY) + 1];
                    northTile.path = true;
                    northTile.blocking = true;
                }
                if (currentY - 1 > 3) {
                    Tile southTile = this.tileMap [(int)Mathf.Floor (currentX), (int)Mathf.Floor (currentY) - 1];
                    southTile.path = true;
                    southTile.blocking = true;
                }

                tile.path = true;
                currentX = currentX + moveX;
                if (currentX > 1 && currentX < this.roomSide * this.rows - 1 && currentY > 1 && currentY < this.roomSide * this.columns - 1) {
                    tile = this.tileMap [(int)Mathf.Floor (currentX), (int)Mathf.Floor (currentY)];
                    tile.path = true;
                    tile.blocking = true;
                }
                currentY = currentY + moveY;

            }
        }
    }