Changeset 0c6b92a for imaps-frontend/src/scripts/util/Factory.js
- Timestamp:
- 12/12/24 17:06:06 (5 weeks ago)
- Branches:
- main
- Parents:
- d565449
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/src/scripts/util/Factory.js
rd565449 r0c6b92a 6 6 import RenderedEntrance from "../rendered_shapes/RenderedEntrance"; 7 7 import RenderedWall from "../rendered_shapes/RenderedWall.js"; 8 import Stairs from "../shapes/Stairs.js"; 9 import RenderedStairs from "../rendered_shapes/RenderedStairs.js"; 10 import {updateShapeCount, getShapeCount} from "./ShapeCount.js"; 8 11 export default class Factory { 12 // BUG KO KE NAPRES REFRESH SA RESETVAT COUNTS! 9 13 10 static infoPinCount = 0; 11 static wallCount = 0; 12 static entranceCount = 0; 13 static roomCount = 0; 14 static createShape(shapeType,attrs) { 15 console.log(attrs,"attrs in factory") 16 console.log("position in factory: " + attrs.position.x) 14 17 15 static createShape(shapeType, position, blockSize, layer, rotation,scaleX = 1, scaleY = 1, increment = false) { 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; 23 16 24 switch (shapeType) { 17 25 case "Entrance": 18 if( increment) this.entranceCount++;19 return new Entrance( position, blockSize, layer, rotation,true,this.entranceCount,scaleX,scaleY);26 if(attrs.increment) updateShapeCount("entrance") 27 return new Entrance(attrs,getShapeCount("entrance")); 20 28 case "Room": 21 if(increment) this.roomCount++; 22 return new Room(position, blockSize, layer, rotation,true, this.roomCount,scaleX,scaleY); 23 case "Wall": 24 return new Wall(position, blockSize, layer, rotation,true,scaleX,scaleY); 25 case "InfoPin": 26 if(increment) this.infoPinCount++; 27 return new InfoPin(position, blockSize, layer, false,this.infoPinCount); 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")) 28 39 default: 29 40 throw new Error("Invalid shape type: " + shapeType); … … 41 52 case "Wall": 42 53 return new RenderedWall(attrs,scaleX,scaleY); 54 case "Stairs": 55 return new RenderedStairs(attrs,scaleX,scaleY) 43 56 default: 44 57 throw new Error("Invalid shape type." + shapeType);
Note:
See TracChangeset
for help on using the changeset viewer.