示例#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);
        }
示例#2
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);
        }