Ignore:
Timestamp:
12/12/24 17:06:06 (5 weeks ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
d565449
Message:

Pred finalna verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/src/scripts/util/Factory.js

    rd565449 r0c6b92a  
    66import RenderedEntrance from "../rendered_shapes/RenderedEntrance";
    77import RenderedWall from "../rendered_shapes/RenderedWall.js";
     8import Stairs from "../shapes/Stairs.js";
     9import RenderedStairs from "../rendered_shapes/RenderedStairs.js";
     10import {updateShapeCount, getShapeCount} from "./ShapeCount.js";
    811export default class Factory {
     12  // BUG KO KE NAPRES REFRESH SA RESETVAT COUNTS!
    913
    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)
    1417
    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
    1624    switch (shapeType) {
    1725      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"));
    2028      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"))
    2839      default:
    2940        throw new Error("Invalid shape type: " + shapeType);
     
    4152      case "Wall":
    4253        return new RenderedWall(attrs,scaleX,scaleY);
     54      case "Stairs":
     55        return new RenderedStairs(attrs,scaleX,scaleY)
    4356      default:
    4457        throw new Error("Invalid shape type." + shapeType);
Note: See TracChangeset for help on using the changeset viewer.