findDoor() public static method

inds a door in the tile pointed to by the two coordinates.
public static findDoor ( int x, int y ) : GameObject
x int The x coordinate.
y int The y coordinate.
return GameObject
Exemplo n.º 1
0
/*
 * Opens the door that is in the targeted tile.
 */

    public override void ExecuteTrap(int triggerX, int triggerY, int State)
    {
        GameObject door = GameWorldController.findDoor(triggerX, triggerY);

        if (door != null)
        {
            DoorControl DC = door.GetComponent <DoorControl>();

            switch (objInt.Quality)
            {
            case 1:            //try open
                DC.UnlockDoor();
                DC.OpenDoor();
                break;

            case 2:            //try close
                DC.CloseDoor();
                DC.LockDoor();
                break;

            case 3:            //try toggle
                //TODO:check if toggle respects unlocked status. (door trap 1001 on level 3)
                DC.ToggleDoor();
                break;
            }
        }
        else
        {
            Debug.Log("Door not found!");
        }
    }
Exemplo n.º 2
0
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        GameObject door = GameWorldController.findDoor(triggerX, triggerY);

        if (door != null)
        {
            DoorControl DC = door.GetComponent <DoorControl>();

            switch (quality)
            {
            case 0:            //Just lock
                //Copy the lock object at the link to use on this door
                if (link != 0)
                {                //link to a lock
                    if (ObjectLoader.GetItemTypeAt(link) == ObjectInteraction.LOCK)
                    {
                        ObjectInteraction lockToCopy = ObjectLoader.getObjectIntAt(link);
                        ObjectLoaderInfo  newobjt    = ObjectLoader.newObject(lockToCopy.item_id, lockToCopy.quality, lockToCopy.owner, lockToCopy.link, 256);
                        newobjt.flags       = lockToCopy.flags;
                        newobjt.doordir     = lockToCopy.doordir;
                        newobjt.invis       = lockToCopy.invis;
                        newobjt.enchantment = lockToCopy.enchantment;
                        newobjt.zpos        = lockToCopy.zpos;
                        newobjt.xpos        = lockToCopy.xpos;
                        newobjt.ypos        = lockToCopy.ypos;
                        newobjt.next        = DC.link;               //To allow proper triggering of traps
                        newobjt.InUseFlag   = 1;
                        GameObject Created = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject;
                        DC.link = newobjt.index;                        //Point the lock at this new lock
                    }
                }
                else
                {                //unlink the lock and tie the locks next back to the door as it's link
                    ObjectInteraction linkedObj = ObjectLoader.getObjectIntAt(DC.link);
                    if (linkedObj != null)
                    {
                        DC.link = linkedObj.next;
                        linkedObj.objectloaderinfo.InUseFlag = 0;
                        Destroy(linkedObj);
                    }
                }
                break;

            case 1:            //try open
                if (TriggerInstantly)
                {
                    DC.UnlockDoor(false);
                    DC.OpenDoor(0f);
                }
                else
                {
                    DC.UnlockDoor(false);
                    DC.OpenDoor(DoorControl.DefaultDoorTravelTime);
                }

                break;

            case 2:            //try close
                if (TriggerInstantly)
                {
                    DC.CloseDoor(0f);
                    DC.LockDoor();
                }
                else
                {
                    DC.CloseDoor(DoorControl.DefaultDoorTravelTime);
                    DC.LockDoor();
                }

                break;

            case 3:            //try toggle
                //TODO:check if toggle respects unlocked status. (door trap 1001 on level 3)
                if (TriggerInstantly)
                {
                    DC.ToggleDoor(0, false);
                }
                else
                {
                    DC.ToggleDoor(DoorControl.DefaultDoorTravelTime, false);
                }
                break;
            }
        }
        else
        {
            Debug.Log("Door not found!");
        }
    }
/*
 * A change terrain trap changes a tile from one type to another. It works over a range of tiles that are set by the traps
 * x,y values. In Underworld these are set by the the relative position of the trap within the tile.
 * The tile it acts on is controlled by the trigger.
 *
 * Examples of it's usage
 * The Moonstone room on Level2
 * The path to the sword hilt on Level3
 *
 */

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        Debug.Log(this.name);
        int textureQuality = (objInt().quality >> 1) & 0xf;

        for (short x = 0; x <= objInt().x; x++)
        {
            for (short y = 0; y <= objInt().y; y++)
            {
                short      tileXToChange = (short)(x + triggerX);
                short      tileYToChange = (short)(y + triggerY);
                GameObject tile          = GameWorldController.FindTile(tileXToChange, tileYToChange, TileMap.SURFACE_FLOOR);
                if (tile != null)
                {
                    TileInfo tileToChange = GameWorldController.instance.currentTileMap().Tiles[tileXToChange, tileYToChange];
                    //Destroy (tile);

                    switch (_RES)
                    {                            //I will probably have to change this again!
                    //case GAME_UW2:
                    //	tileToChange.floorTexture=textureQuality;
                    //	break;
                    default:
                        if (textureQuality < 10)
                        {
                            tileToChange.floorTexture = (short)textureQuality;                                  //+48;
                            //tileToChange.floorTexture=GameWorldController.instance.currentTileMap().texture_map[textureQuality+48];
                        }
                        break;
                    }

                    //currobj.zpos >> 2
                    //(objList[k].zpos >> 2);
                    tileToChange.Render = true;
                    for (int v = 0; v < 6; v++)
                    {
                        tileToChange.VisibleFaces[v] = true;
                    }
                    short tileTypeToChangeTo = (short)(objInt().quality & 0x01);
                    short newTileHeight      = (short)(objInt().zpos >> 2);
                    short newWallTexture     = tileToChange.wallTexture;
                    if (_RES == GAME_UW2)
                    {                            //Also the owner can be used to change wall texture. This means changing it's neighours.
                        if (objInt().owner < 63)
                        {
                            newWallTexture = objInt().owner;
                        }
                    }

                    //tileToChange.tileType=tileTypeToChangeTo;
                    tileToChange.DimX = 1;
                    tileToChange.DimY = 1;

                    ////tileToChange.floorHeight=newTileHeight;
                    //tileToChange.floorHeight=tileToChange.floorHeight;//DOUBLE CHECK THIS
                    tileToChange.isWater = TileMap.isTextureWater(GameWorldController.instance.currentTileMap().texture_map[tileToChange.floorTexture]);
                    //TileMapRenderer.RenderTile(GameWorldController.instance.LevelModel,tileXToChange,tileYToChange,tileToChange,tileToChange.isWater,false,false,true);
                    tileToChange.TileNeedsUpdate();
                    TileMapRenderer.UpdateTile(tileXToChange, tileYToChange, tileTypeToChangeTo, newTileHeight, tileToChange.floorTexture, newWallTexture, false);
                    Destroy(tile);

                    if (tileToChange.isDoor)
                    {                            //The door may be rendered
                        GameObject door = GameWorldController.findDoor(tileToChange.tileX, tileToChange.tileY);
                        if (door != null)
                        {
                            string doorname = ObjectLoader.UniqueObjectName(door.GetComponent <ObjectInteraction>().objectloaderinfo);
                            DestroyDoorPortion("front_leftside_" + doorname);
                            DestroyDoorPortion("front_over_" + doorname);
                            DestroyDoorPortion("front_rightside_" + doorname);
                            DestroyDoorPortion("side1_filler_" + doorname);
                            DestroyDoorPortion("over_filler_" + doorname);
                            DestroyDoorPortion("side2_filler_" + doorname);
                            DestroyDoorPortion("front_filler_" + doorname);
                            DestroyDoorPortion("rear_leftside_" + doorname);
                            DestroyDoorPortion("rear_over_" + doorname);
                            DestroyDoorPortion("rear_rightside_" + doorname);
                            DestroyDoorPortion(doorname);
                            TileMapRenderer.RenderDoorwayFront(
                                GameWorldController.instance.LevelModel,
                                GameWorldController.instance.currentTileMap(),
                                GameWorldController.instance.CurrentObjectList(),
                                door.GetComponent <ObjectInteraction>().objectloaderinfo
                                );
                            TileMapRenderer.RenderDoorwayRear(
                                GameWorldController.instance.LevelModel,
                                GameWorldController.instance.currentTileMap(),
                                GameWorldController.instance.CurrentObjectList(),
                                door.GetComponent <ObjectInteraction>().objectloaderinfo
                                );
                            Vector3 objPos = door.transform.position;
                            ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(),
                                                              door.GetComponent <ObjectInteraction>().objectloaderinfo,
                                                              GameWorldController.instance.LevelModel, objPos
                                                              );
                        }
                    }
                }
                else
                {
                    Debug.Log(this.name + " Unable to find tile for change terrain trap " + tileXToChange + " " + tileYToChange);
                }
            }
        }

        GameWorldController.WorldReRenderPending = true;

        //	if ((objInt().owner<63) && (_RES==GAME_UW2))
        //	{
        //Now force re-render the tiles and their neighbours
        for (int x = -1; x <= objInt().x + 1; x++)
        {
            for (int y = -1; y <= objInt().y + 1; y++)
            {
                int tileXToChange = x + triggerX;
                int tileYToChange = y + triggerY;

                GameObject tile = GameWorldController.FindTile(tileXToChange, tileYToChange, TileMap.SURFACE_FLOOR);
                if (tile != null)
                {
                    Destroy(tile);
                }
                if ((tileXToChange >= 0) && (tileXToChange <= 63) && (tileYToChange >= 0) && (tileYToChange <= 63))
                {
                    TileInfo tileToChange = GameWorldController.instance.currentTileMap().Tiles[tileXToChange, tileYToChange];
                    tileToChange.Render = true;
                    for (int v = 0; v < 6; v++)
                    {
                        tileToChange.VisibleFaces[v] = true;
                    }
                    tileToChange.isWater = TileMap.isTextureWater(GameWorldController.instance.currentTileMap().texture_map[tileToChange.floorTexture]);
                    //TileMapRenderer.RenderTile(GameWorldController.instance.LevelModel,tileXToChange,tileYToChange,tileToChange,tileToChange.isWater,false,false,true);
                    tileToChange.TileNeedsUpdate();
                }
            }
        }
        //}
    }