コード例 #1
0
 public RestoreMagicPotion(PotionDef def, int x, int y) : base(def, x, y)
 {
 }
コード例 #2
0
ファイル: Potion.cs プロジェクト: merthsoft/MooseLib
 public Potion(PotionDef def, int x, int y) : base(def, x, y)
 {
     MiniMapTile = MiniMapTile.Potion;
     DrawIndex   = (int)def.item;
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: gbsphenx/skproject
        private int convertObject(MapDef mapdef, int oid, byte tile)
        {
            Debug.Assert(already.Add(oid));
            Debug.Assert(oid != oidFree);
            Debug.Assert(oid != oidEnd);
            int    dir    = (oid >> 14) & 3;
            int    cat    = (oid >> 10) & 15;
            int    num    = (oid) & 1023;
            int    objRef = d.objs.Count;
            ObjDef newObj = null;

            si.Position = offsetsToDatabase[cat] + dbSizes[cat] * num;
            int  nextOid = br.ReadUInt16();
            bool isWall  = ((tileTypeIndex)(tile >> 5)) == tileTypeIndex.ttWall;

            switch ((dbIndex)cat)
            {
            case dbIndex.dbDoor: {
                int  attr        = br.ReadUInt16();
                bool doorType1   = 0 != (attr & 1);
                int  ornateIndex = (attr >> 1) & 15;

                d.objs.Add(newObj = new DoorDef {
                        doorType              = doorType1 ? mapdef.doorType1 : mapdef.doorType0,
                        doorOrnate            = mapdef.doorDecorationGraphics[ornateIndex],
                        openVertical          = 0 != ((attr >> 5) & 1),
                        button                = 0 != ((attr >> 6) & 1),
                        destroyablebyFireball = 0 != ((attr >> 7) & 1),
                        bashablebyChopping    = 0 != ((attr >> 8) & 1),
                        //9
                        //10
                        //11
                        buttonState = 0 != ((attr >> 12) & 1),
                        //13
                        //14
                        //15
                    });
                break;
            }

            case dbIndex.dbTeleporter: {
                int attr  = br.ReadUInt16();
                int attr2 = br.ReadUInt16();
                d.objs.Add(newObj = new TeleporterDef {
                        destMap          = (attr2 >> 8) & 255,
                        destX            = (attr >> 0) & 31,
                        destY            = (attr >> 5) & 31,
                        rotation         = (attr >> 10) & 3,
                        absoluteRotation = 0 != ((attr >> 12) & 1),
                        scope            = (attr >> 13) & 3,
                        sound            = 0 != ((attr >> 15) & 1),
                    });
                break;
            }

            case dbIndex.dbText: {
                int attr = br.ReadUInt16();
                d.objs.Add(newObj = new TextDef {
                        textVisibility = 0 != ((attr >> 0) & 1),
                        textMode       = (attr >> 1) & 3,
                        textIndex      = (attr >> 3) & 0x1fff,
                    });
                break;
            }

            case dbIndex.dbActuator: {
                int attr  = br.ReadUInt16();
                int attr2 = br.ReadUInt16();
                int attr3 = br.ReadUInt16();
                d.objs.Add(newObj = new ActuatorDef {
                        actuatorType = (attr >> 0) & 127,
                        actuatorData = (attr >> 7) & 511,

                        onceOnlyActuator = 0 != ((attr2 >> 2) & 1),
                        actionType       = (attr2 >> 3) & 3,
                        inversion        = 0 != ((attr2 >> 5) & 1),
                        sound            = 0 != ((attr2 >> 6) & 1),
                        delay            = (attr2 >> 7) & 15,
                        floorOrnate      = isWall ? -1 : (attr2 >> 12) & 15,
                        wallOrnate       = isWall ? (attr2 >> 12) & 15 : -1,

                        newDirection = (attr3 >> 4) & 3,
                        xCoord       = (attr3 >> 6) & 31,
                        yCoord       = (attr3 >> 11) & 31,
                    });
                break;
            }

            case dbIndex.dbCreature: {
                int         childOid     = br.ReadUInt16();
                int         creatureType = br.ReadByte();
                int         position     = br.ReadByte();
                int         hp1          = br.ReadUInt16();
                int         hp2          = br.ReadUInt16();
                int         hp3          = br.ReadUInt16();
                int         hp4          = br.ReadUInt16();
                CreatureDef me;
                d.objs.Add(newObj = me = new CreatureDef {
                        creatureType = creatureType,
                        position     = position,
                        hp1          = hp1,
                        hp2          = hp2,
                        hp3          = hp3,
                        hp4          = hp4,
                    });
                if (childOid != oidEnd)
                {
                    me.childObjRef = convertObject(mapdef, childOid, tile);
                }

                break;
            }

            case dbIndex.dbWeapon: {
                int attr = br.ReadUInt16();
                d.objs.Add(newObj = new WeaponDef {
                        itemType  = (attr >> 0) & 127,
                        important = 0 != ((attr >> 7) & 1),
                        charges   = (attr >> 10) & 15,
                    });
                break;
            }

            case dbIndex.dbCloth: {
                int attr = br.ReadUInt16();
                d.objs.Add(newObj = new ClothDef {
                        itemType  = (attr >> 0) & 127,
                        important = 0 != ((attr >> 7) & 1),
                        charges   = (attr >> 10) & 15,
                    });
                break;
            }

            case dbIndex.dbScroll: {
                int attr = br.ReadUInt16();
                d.objs.Add(newObj = new ScrollDef {
                        referredText = attr & 0x3ff,
                    });
                break;
            }

            case dbIndex.dbPotion: {
                int attr = br.ReadUInt16();
                d.objs.Add(newObj = new PotionDef {
                        potionPower  = (attr >> 0) & 255,
                        potionType   = (attr >> 8) & 127,
                        visiblePower = 0 != ((attr >> 15) & 1),
                    });
                break;
            }

            case dbIndex.dbContainer: {
                int          childOid = br.ReadUInt16();
                int          attr     = br.ReadByte();
                int          attr2    = br.ReadByte();
                int          attr3    = br.ReadUInt16();
                ContainerDef me;
                d.objs.Add(newObj = me = new ContainerDef {
                        isOpened      = 0 != ((attr >> 0) & 1),
                        containerType = (attr >> 1) & 3,
                        destX         = (attr3 >> 0) & 31,
                        destY         = (attr3 >> 5) & 31,
                        destMap       = (attr >> 10) & 63,
                    });
                if (childOid != oidEnd)
                {
                    me.childObjRef = convertObject(mapdef, childOid, tile);
                }
                break;
            }

            case dbIndex.dbMiscellaneous_item: {
                int attr = br.ReadUInt16();
                d.objs.Add(newObj = new MiscItemDef {
                        itemType  = (attr >> 0) & 127,
                        important = 0 != ((attr >> 7) & 1),
                        charges   = (attr >> 8) & 0x3f,
                    });
                break;
            }

            case dbIndex.dbMissile: {
                int        childOid = br.ReadUInt16();
                MissileDef me;
                d.objs.Add(newObj = me = new MissileDef {
                    });
                if (childOid != oidEnd)
                {
                    me.childObjRef = convertObject(mapdef, childOid, tile);
                }
                break;
            }

            case dbIndex.dbCloud: {
                d.objs.Add(newObj = new CloudDef {
                    });
                break;
            }

            default:
                throw new NotSupportedException();
            }
            newObj.direction = dir;
            if (nextOid != oidEnd)
            {
                newObj.nextObjRef = convertObject(mapdef, nextOid, tile);
            }
            return(objRef);
        }