public Boolean buildMaterialAt(int materialKey, int cx, int cy) { Boolean canBuildThere = false; if (map[cy, cx] == null) { map[cy, cx] = new MapObject(); } MapObject mb = map[cy, cx]; // check if it can be placed there if (mb.floorLevelObjects[2] == null) { // no wall on this cell therefore is safe to place anything MaterialObject mob = materialManager.getMaterialObject(materialKey); int floorLvl = mob.floorLevel; if (mb.floorLevelObjects[floorLvl] == null) { mb.floorLevelObjects[floorLvl] = new TileObject(cx, cy, mob); canBuildThere = true; } else { // occupied by something else } } else { // wall is in the way } return(canBuildThere); }
public TileObject(int column, int rowx, MaterialObject mob) { col = column; row = rowx; tileType = mob; x = col * GameMain.gridSize; y = row * GameMain.gridSize; width = tileType.texture.Width; height = tileType.texture.Height; }
public void addBuildTask(int materialKey, int cx, int cy) { MaterialObject mo = materialsManager.getMaterialObject(materialKey); Task t = new Task(cx, cy); t.taskType = Task.TaskType.BUILD; t.materialKey = materialKey; t.taskTimeLength = mo.secondsToBuild * 60; builderTaskList.Enqueue(t); }
private void addMaterial(int materialKey, string srcstr, int xx, int yy, int floorLevel, int secondsToBuild) { /* xx/yy tells where on the layout to rip the texture2d out of - assuming size is gridSize * * floorLevel - 0 : ground pavement - can have things on top of them * - 1 : objects - eg tables/chairs * - 2 : walls - nothing else can go on that tile cell * - 3 : underground cables? * - 4 : overhanging lights? * * */ MaterialObject mb = new MaterialObject(); mb.key = materialKey; mb.texture = gameMain.Content.Load <Texture2D>(srcstr); mb.floorLevel = floorLevel; mb.secondsToBuild = secondsToBuild; materialLib.Add(materialKey, mb); }