Beispiel #1
0
        public static HouseObject fromXMLString(string str)
        {
            int    x         = HouseEditorObject.readXMLAttribInt(str, "x");
            int    y         = HouseEditorObject.readXMLAttribInt(str, "y");
            string idStr     = HouseEditorObject.readXMLAttribStr(str, "type").Substring("OBJECT_".Length);
            int    type      = HouseEditorObject.idLookup(GlobalConstants.LOOKUP_OBJECT, GlobalConstants.LOOKUP_OBJECT.Length, idStr);
            int    facingInt = HouseObject.getFacingInt(HouseEditorObject.readXMLAttribStr(str, "facingDir"));

            return(new HouseObject(x, y, type, facingInt));
        }
Beispiel #2
0
        public void setTypeAndFacing(int type, int facing)
        {
            HouseObject.requireVaildType(type);
            HouseObject.requireValidFacing(facing);
            SimWorld simWorld = AppEngine.getCanvas().getSimWorld();

            this.setSize(simWorld.getObjectFootprintWidth(type), simWorld.getObjectFootprintHeight(type));
            this.m_type   = type;
            this.m_facing = facing;
        }
Beispiel #3
0
        public HouseObject getHouseObjectAt(int x, int y)
        {
            int num = this.m_objects.size();

            for (int index = 0; index < num; ++index)
            {
                HouseObject houseObject = (HouseObject)this.m_objects.elementAt(index);
                if (houseObject.getX() == x && houseObject.getY() == y)
                {
                    return(houseObject);
                }
            }
            return((HouseObject)null);
        }
Beispiel #4
0
        public override void writexml(OutputStream @out)
        {
            string       str1         = GlobalConstants.LOOKUP_OBJECT[this.getType()];
            string       facingCstr   = HouseObject.getFacingCStr(this.getFacing());
            StringBuffer stringBuffer = new StringBuffer();

            stringBuffer.append("    <object ").append("x=\"").append(this.getX()).append("\" ").append("y=\"").append(this.getY()).append("\" ").append("type=\"OBJECT_").append(str1).append("\" ").append("facingDir=\"").append(facingCstr).append("\" ").append("/>\n");
            string str2 = stringBuffer.toString();

            sbyte[] b = new sbyte[str2.Length];
            for (int index = 0; index < str2.Length; ++index)
            {
                b[index] = (sbyte)str2[index];
            }
            @out.write(b, 0, b.Length);
        }
Beispiel #5
0
        public static House fromXMLStream(DataInputStream @is, string houseName, int houseId)
        {
            int length1 = @is.available();

            sbyte[] b       = new sbyte[length1];
            char[]  chArray = new char[length1];
            @is.readFully(b);
            for (int index = 0; index < length1; ++index)
            {
                chArray[index] = (char)b[index];
            }
            string str1       = new string(chArray);
            string str2       = "<room ";
            string str3       = "<door ";
            string str4       = "<window ";
            string str5       = "<object ";
            House  house      = new House(houseName, houseId);
            int    startIndex = 0;

            do
            {
                int    length2 = str1.IndexOf('\n', startIndex);
                string str6    = str1.Substring(startIndex, length2);
                if (str6.IndexOf(str2) != -1)
                {
                    house.addRoom(Room.fromXMLString(str6));
                }
                else if (str6.IndexOf(str3) != -1)
                {
                    house.addDoor(Door.fromXMLString(str6));
                }
                else if (str6.IndexOf(str4) != -1)
                {
                    house.addWindow(Window.fromXMLString(str6));
                }
                else if (str6.IndexOf(str5) != -1)
                {
                    house.addHouseObject(HouseObject.fromXMLString(str6));
                }
                startIndex = length2 + 1;
            }while (startIndex < str1.Length);
            return(house);
        }
Beispiel #6
0
 public void addHouseObject(HouseObject @object)
 {
     this.m_objects.addElement((object)@object);
 }
Beispiel #7
0
 public void deleteHouseObject(HouseObject houseObject)
 {
     this.m_objects.removeElement((object)houseObject);
 }