Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }