[d565449] | 1 | import Entrance from "../shapes/Entrance";
|
---|
| 2 | import Wall from "../shapes/Wall";
|
---|
| 3 | import Room from "../shapes/Room";
|
---|
| 4 | import InfoPin from "../shapes/InfoPin";
|
---|
| 5 | import RenderedRoom from "../rendered_shapes/RenderedRoom";
|
---|
| 6 | import RenderedEntrance from "../rendered_shapes/RenderedEntrance";
|
---|
| 7 | import RenderedWall from "../rendered_shapes/RenderedWall.js";
|
---|
[0c6b92a] | 8 | import Stairs from "../shapes/Stairs.js";
|
---|
| 9 | import RenderedStairs from "../rendered_shapes/RenderedStairs.js";
|
---|
| 10 | import {updateShapeCount, getShapeCount} from "./ShapeCount.js";
|
---|
[d565449] | 11 | export default class Factory {
|
---|
[0c6b92a] | 12 | // BUG KO KE NAPRES REFRESH SA RESETVAT COUNTS!
|
---|
[d565449] | 13 |
|
---|
[0c6b92a] | 14 | static createShape(shapeType,attrs) {
|
---|
| 15 | console.log(attrs,"attrs in factory")
|
---|
| 16 | console.log("position in factory: " + attrs.position.x)
|
---|
| 17 |
|
---|
| 18 | let scaleX = (attrs.scaleX ? parseFloat(attrs.scaleX) : 1);
|
---|
| 19 | let scaleY = (attrs.scaleY ? parseFloat(attrs.scaleY) : 1);
|
---|
| 20 |
|
---|
| 21 | attrs.scaleX = scaleX;
|
---|
| 22 | attrs.scaleY = scaleY;
|
---|
[d565449] | 23 |
|
---|
| 24 | switch (shapeType) {
|
---|
| 25 | case "Entrance":
|
---|
[0c6b92a] | 26 | if(attrs.increment) updateShapeCount("entrance")
|
---|
| 27 | return new Entrance(attrs,getShapeCount("entrance"));
|
---|
[d565449] | 28 | case "Room":
|
---|
[0c6b92a] | 29 | if(attrs.increment) updateShapeCount("room");
|
---|
| 30 | return new Room(attrs,getShapeCount("room"));
|
---|
| 31 | case "Wall":
|
---|
| 32 | return new Wall(attrs);
|
---|
| 33 | case "InfoPin":
|
---|
| 34 | if(attrs.increment) updateShapeCount("infoPin")
|
---|
| 35 | return new InfoPin(attrs,getShapeCount("infoPin"));
|
---|
| 36 | case "Stairs":
|
---|
| 37 | if(attrs.increment) updateShapeCount("stairs")
|
---|
| 38 | return new Stairs(attrs,getShapeCount("stairs"))
|
---|
[d565449] | 39 | default:
|
---|
| 40 | throw new Error("Invalid shape type: " + shapeType);
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | static createRenderedShape(shapeType,attrs){
|
---|
| 45 | let scaleX = (attrs.scaleX ? parseFloat(attrs.scaleX) : 1);
|
---|
| 46 | let scaleY = (attrs.scaleY ? parseFloat(attrs.scaleY) : 1);
|
---|
| 47 | switch (shapeType) {
|
---|
| 48 | case "Entrance":
|
---|
| 49 | return new RenderedEntrance(attrs,scaleX,scaleY);
|
---|
| 50 | case "Room":
|
---|
| 51 | return new RenderedRoom(attrs,scaleX,scaleY);
|
---|
| 52 | case "Wall":
|
---|
| 53 | return new RenderedWall(attrs,scaleX,scaleY);
|
---|
[0c6b92a] | 54 | case "Stairs":
|
---|
| 55 | return new RenderedStairs(attrs,scaleX,scaleY)
|
---|
[d565449] | 56 | default:
|
---|
| 57 | throw new Error("Invalid shape type." + shapeType);
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 | }
|
---|