FindTile() публичный статический Метод

Finds the tile or wall at the specified coordinates.
public static FindTile ( int x, int y, int surface ) : GameObject
x int The x coordinate.
y int The y coordinate.
surface int Surface.
Результат GameObject
Пример #1
0
    public override void ExecuteTrap(int triggerX, int triggerY, int State)
    {
        Vector3 Dist = new Vector3(-64 * 1.2f, 0, 0);

        for (int i = 0; i <= X; i++)
        {
            for (int j = 0; j <= Y; j++)
            {
                //Find the tile at the location.
                GameObject ExistingTile = GameWorldController.FindTile(triggerX + i, triggerY + j, 1);
                //string Tilename = GameWorldController.GetTileName(TileX+i,TileY+j,1); //Var.GetTileName (TileX+i,TileY+j,1); //ExistingTile.name;
                //Find the tile that becomes the tile at that location.
                GameObject CTTile          = GameWorldController.FindTileByName(this.name + "_" + (i).ToString("D2") + "_" + (j).ToString("D2"));
                GameObject ReplacementTile = Instantiate(CTTile, CTTile.transform.position, CTTile.transform.rotation) as GameObject;
                ReplacementTile.transform.parent = CTTile.transform.parent;
                ReplacementTile.name             = ExistingTile.name;
                if (ExistingTile != null)
                {
                    //Debug.Log ("Destroying " + ExistingTile.name );
                    Destroy(ExistingTile);
                }
                if (ReplacementTile != null)
                {
                    //Debug.Log ("Moving " + ReplacementTile.name );
                    //ReplacementTile.name = Tilename;
                    Vector3 StartPos = ReplacementTile.transform.position;
                    Vector3 EndPos   = StartPos + Dist;
                    ReplacementTile.transform.position = Vector3.Lerp(StartPos, EndPos, 1.0f);
                }
                //Change the tile type for the automap
                GameWorldController.instance.Tilemap.tileType[triggerX + i, triggerY + j] = objInt.Quality & 0x1;
                GameWorldController.instance.Tilemap.Render[triggerX + i, triggerY + j]   = 1;
            }
        }
    }
/*
 * Moves a tile up and down.
 *
 * State is controlled by the triggering objects (eg switches)
 *
 * Usage example
 * The platform puzzle on Level 1 leading to the grave of Korianus.
 */

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        Debug.Log(this.name);
        GameObject platformTile = GameWorldController.FindTile(triggerX, triggerY, TileMap.SURFACE_FLOOR);//Var.FindTile (Var.triggerX,Var.triggerY,1);

        //Get the height of the tile


        //if (objInt().flags==7)
        if (GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight >= 18)
        {
            //Move the tile to the bottom
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, -0.3f * 7f, 0f), 0.7f));
            objInt().flags = (short)State;
            //state = 1;
            GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight = 2;
        }
        else
        {
            //Go up a step.
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, 0.3f, 0f), 0.1f));
            //objInt().flags=State;
            GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight += 2;
        }
        objInt().flags = (short)State;
    }
Пример #3
0
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        TileXToWatch = triggerX;
        TileYToWatch = triggerY;
        TileVector   = CurrentTileMap().getTileVector(TileXToWatch, TileYToWatch);

        if (platformTile == null)
        {
            platformTile = GameWorldController.FindTile(triggerX, triggerY, TileMap.SURFACE_FLOOR);
        }
        if (platformTile == null)
        {
            return;
        }
        if (CurrentTileMap().Tiles[triggerX, triggerY].floorHeight / 2 >= owner)
        {
            xpos = 0;
        }
        else if (CurrentTileMap().Tiles[triggerX, triggerY].floorHeight / 2 <= quality)
        {
            xpos = 1;
        }

        if (xpos == 1)
        {//moving up
            MoveTileUp(triggerX, triggerY);
        }
        else
        {//moving down
            CurrentTileMap().Tiles[triggerX, triggerY].floorHeight -= 2;
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, -0.3f, 0f), 0.1f));
        }
    }
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        if (platformTile == null)
        {
            platformTile = GameWorldController.FindTile(triggerX, triggerY, TileMap.SURFACE_FLOOR);
        }
        if (platformTile == null)
        {
            return;
        }
        if (GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight / 2 >= objInt().owner)
        {
            objInt().x = 0;
        }
        else if (GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight / 2 <= objInt().quality)
        {
            objInt().x = 1;
        }

        if (objInt().x == 1)
        {        //moving up
            GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight += 2;
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, 0.3f, 0f), 0.1f));
        }
        else
        {        //moving down
            GameWorldController.instance.currentTileMap().Tiles[triggerX, triggerY].floorHeight -= 2;
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, -0.3f, 0f), 0.1f));
        }
    }
Пример #5
0
    public void ChangeColumn(int baseX, int baseY, int column, int bitfield)
    {
        int tileX = baseX + (column * 3);     //every column of tiles

        for (int i = 0; i < 3; i++)
        {
            int tileFlag = (bitfield >> i) & 0x1;
            if (tileFlag == 1)          //This tile will change
            {
                int tileY = baseY + (i * 3);
                if (GameWorldController.instance.currentTileMap().Tiles[tileX, tileY].floorHeight / 2 == objInt().owner - 2)
                {
                    GameWorldController.instance.currentTileMap().Tiles[tileX, tileY].floorHeight = 4;
                }
                else
                {
                    GameWorldController.instance.currentTileMap().Tiles[tileX, tileY].floorHeight = (short)((objInt().owner - 2) * 2);
                    if ((TileMap.visitTileX == tileX) && (TileMap.visitTileY == tileY))
                    {
                        UWCharacter.Instance.transform.position = GameWorldController.instance.currentTileMap().getTileVector(tileX, tileY);
                    }
                }
                GameWorldController.instance.currentTileMap().Tiles[tileX, tileY].TileNeedsUpdate();
                GameObject tileToDestroy = GameWorldController.FindTile(tileX, tileY, TileMap.SURFACE_FLOOR);
                if (tileToDestroy != null)
                {
                    Destroy(tileToDestroy);
                }
            }
        }
    }
Пример #6
0
    void DestroyTile(int tileX, int tileY)
    {
        GameWorldController.instance.currentTileMap().Tiles[tileX, tileY].TileNeedsUpdate();
        GameObject tile = GameWorldController.FindTile(tileX, tileY, TileMap.SURFACE_FLOOR);

        if (tile != null)
        {
            Destroy(tile);
        }
    }
Пример #7
0
    void UpdateTile(int tileXToChange, int tileYToChange, short newFloorTexture)
    {
        TileInfo tileToChange = CurrentTileMap().Tiles[tileXToChange, tileYToChange];

        if (tileToChange.floorTexture != newFloorTexture)
        {
            GameObject tile = GameWorldController.FindTile(tileXToChange, tileYToChange, TileMap.SURFACE_FLOOR);
            tileToChange.TileNeedsUpdate();
            //Water xtileToChange.isWater = false;
            TileMapRenderer.UpdateTile(tileXToChange, tileYToChange, tileToChange.tileType, 18, newFloorTexture, tileToChange.wallTexture, false);
            Destroy(tile);
        }
    }
Пример #8
0
 public void ResetBullFrog()
 {    //TODO:Move player and all objects within area to a safe spot when resetting.
     //000~001~193~A voice utters the words "Reset Activated."
     ml.Add(playerUW.StringControl.GetString(1, 193));
     for (int x = 0; x < 8; x++)
     {
         for (int y = 0; y < 8; y++)
         {
             GameObject platformTile = GameWorldController.FindTile((BaseX + x), (BaseY + y), 1);
             heights[x, y] = 0;
             StartCoroutine(MoveTile(platformTile.transform, -platformTile.transform.position, 0.1f));
             //platformTile.transform.position = Vector3.zero;
         }
     }
 }
 public void ResetBullFrog()
 {//TODO:Move player and all objects within area to a safe spot when resetting.
  //000~001~193~A voice utters the words "Reset Activated."
     UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 193));
     for (int x = 0; x < 8; x++)
     {
         for (int y = 0; y < 8; y++)
         {
             GameObject platformTile = GameWorldController.FindTile((BaseX + x), (BaseY + y), TileMap.SURFACE_FLOOR);
             CurrentTileMap().Tiles[BaseX + x, BaseY + y].floorHeight = 8;//heights[targetX+x,targetY+y];
             CurrentTileMap().Tiles[BaseX + targetX + x, BaseY + targetY + y].TileNeedsUpdate();
             Destroy(platformTile);
         }
     }
 }
Пример #10
0
    /// <summary>
    /// Updates the tile texture of the floor.
    /// </summary>
    /// <param name="newTexture">New texture.</param>
    public void UpdateTileTexture(int newTexture)
    {     //Question. Is the texture map always 7 & 8??
        if (xpos == 3)
        { //TODO:confirm this behaviour is consistent
            return;
        }
        CurrentTileMap().Tiles[TileXToWatch, TileYToWatch].floorTexture = (short)newTexture;
        CurrentTileMap().Tiles[TileXToWatch, TileYToWatch].TileNeedsUpdate();
        GameObject tileToDestroy = GameWorldController.FindTile(TileXToWatch, TileYToWatch, TileMap.SURFACE_FLOOR);

        if (tileToDestroy != null)
        {
            Destroy(tileToDestroy);
        }
    }
/*
 * Moves a tile up and down.
 *
 * State is controlled by the triggering objects (eg switches)
 *
 * Usage example
 * The platform puzzle on Level 1 leading to the grave of Korianus.
 */

    public override void ExecuteTrap(int triggerX, int triggerY, int State)
    {
        GameObject platformTile = GameWorldController.FindTile(triggerX, triggerY, 1);      //Var.FindTile (Var.triggerX,Var.triggerY,1);

        if (State == 7)
        {
            //Move the tile to the bottom
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, -0.3f * 7f, 0f), 0.7f));
            //state = 1;
        }
        else
        {
            //Go up a step.
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, 0.3f, 0f), 0.1f));
            //state++;
        }
    }
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        TileXToWatch=triggerX;
        TileYToWatch=triggerY;
        TileVector=GameWorldController.instance.currentTileMap().getTileVector(TileXToWatch,TileYToWatch);

        if  (platformTile ==  null)
        {
            platformTile =	GameWorldController.FindTile (triggerX,triggerY,TileMap.SURFACE_FLOOR);
        }
        if  (platformTile ==  null)
        {
                return;
        }
        if (GameWorldController.instance.currentTileMap().Tiles[triggerX,triggerY].floorHeight/2>=objInt().owner)
        {
            objInt().x=0;
        }
        else if (GameWorldController.instance.currentTileMap().Tiles[triggerX,triggerY].floorHeight/2<= objInt().quality )
        {
            objInt().x=1;
        }

        if (objInt().x==1)
        {//moving up
            GameWorldController.instance.currentTileMap().Tiles[triggerX,triggerY].floorHeight+=2;
            StartCoroutine(MoveTile (platformTile.transform, new Vector3(0f,0.3f,0f) ,0.1f));
            if (GameWorldController.instance.currentTileMap().Tiles[triggerX,triggerY].floorHeight>=30)
                {
                    if (
                            (TileMap.visitTileX==triggerX)
                            &&
                            (TileMap.visitTileY==triggerY)
                    )
                                {//Kill the player if they are in the tile  (ouch my head)
                            UWCharacter.Instance.CurVIT -= 1000;
                    }
                }
        }
        else
        {//moving down
            GameWorldController.instance.currentTileMap().Tiles[triggerX,triggerY].floorHeight-=2;
            StartCoroutine(MoveTile (platformTile.transform, new Vector3(0f,-0.3f,0f) ,0.1f));
        }
    }
    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        //Check if the player is in range of the trap
        if
        (
            (TileMap.visitedTileX >= triggerX - range)
            &&
            (TileMap.visitedTileY >= triggerY - range)
            &&
            (TileMap.visitedTileX <= triggerX + range)
            &&
            (TileMap.visitedTileY <= triggerY + range)
        )
        {
            //get the texture map of the floor the player is on.

            if (UWCharacter.Instance.Grounded)
            {
                int texture = CurrentTileMap().Tiles[TileMap.visitTileX, TileMap.visitTileY].floorTexture;
                if (texture == owner)
                {
                    TileInfo tileToChange = CurrentTileMap().Tiles[TileMap.visitTileX, TileMap.visitTileY];
                    if (tileToChange.floorHeight >= 2)
                    {
                        tileToChange.floorTexture = (short)((ypos << 3) | xpos);
                        tileToChange.floorHeight -= 2;
                        tileToChange.Render       = true;
                        for (int v = 0; v < 6; v++)
                        {
                            tileToChange.VisibleFaces[v] = true;
                        }
                        //water x tileToChange.isWater = TileMap.isTextureWater(CurrentTileMap().texture_map[tileToChange.floorTexture]);
                        //Water x tileToChange.terrain= GameWorldController.instance.terrainData.Terrain[CurrentTileMap().texture_map[tileToChange.floorTexture]];
                        GameObject tile = GameWorldController.FindTile(TileMap.visitTileX, TileMap.visitTileY, TileMap.SURFACE_FLOOR);
                        if (tile != null)
                        {
                            Destroy(tile);
                        }
                        tileToChange.TileNeedsUpdate();
                    }
                }
            }
        }
    }
    public void RaiseLowerBullfrog(int dir)
    {    //TODO:Add a check for tiles at max/min height
        for (int x = -1; x <= 1; x++)
        {
            for (int y = -1; y <= 1; y++)
            {
                if ((x == 0) && (y == 0))
                {
                    //Center tile raise or lower by 2

                    if (((tm.Tiles[BaseX + targetX + x, BaseY + targetY + y].floorHeight < 20) && (dir == +1)) || ((tm.Tiles[BaseX + targetX + x, BaseY + targetY + y].floorHeight > 2) && (dir == -1)))
                    {
                        GameObject platformTile = GameWorldController.FindTile((BaseX + targetX + x), (BaseY + targetY + y), TileMap.SURFACE_FLOOR);
                        //StartCoroutine(MoveTile (platformTile.transform, new Vector3(0f,(float)(2*dir) * (0.3f),0f) ,0.1f));
                        //heights[targetX+x,targetY+y]+=dir*2;
                        GameWorldController.instance.currentTileMap().Tiles[BaseX + targetX + x, BaseY + targetY + y].floorHeight += (short)(dir * 2);
                        GameWorldController.instance.currentTileMap().Tiles[BaseX + targetX + x, BaseY + targetY + y].TileNeedsUpdate();
                        Destroy(platformTile);
                    }
                }
                else
                {
                    //raise by 1 if within bounds
                    if (
                        (targetX + x >= 0) && (targetX + x < +8)
                        &&
                        (targetY + y >= 0) && (targetY + y < +8)
                        )
                    {
                        if (((tm.Tiles[BaseX + targetX + x, BaseY + targetY + y].floorHeight < 20) && (dir == +1)) || ((tm.Tiles[BaseX + targetX + x, BaseY + targetY + y].floorHeight > 1) && (dir == -1)))
                        {
                            //Raise or lower by 1
                            GameObject platformTile = GameWorldController.FindTile((BaseX + targetX + x), (BaseY + targetY + y), TileMap.SURFACE_FLOOR);
                            //StartCoroutine(MoveTile (platformTile.transform, new Vector3(0f,(float)(1*dir) * (0.3f),0f) ,0.1f));
                            //heights[targetX+x,targetY+y]+=dir*1;
                            GameWorldController.instance.currentTileMap().Tiles[BaseX + targetX + x, BaseY + targetY + y].floorHeight += (short)dir;
                            GameWorldController.instance.currentTileMap().Tiles[BaseX + targetX + x, BaseY + targetY + y].TileNeedsUpdate();
                            Destroy(platformTile);
                        }
                    }
                }
            }
        }
    }
Пример #15
0
    void ChangeTileHeight(int tileX, int tileY, int newHeight)
    {
        TileInfo t = CurrentTileMap().Tiles[tileX, tileY];

        //int curHeight = CurrentTileMap().Tiles[tileX, tileX].floorHeight;
        //Debug.Log("Changing height from " + curHeight + " to " + newHeight  + " at " + owner);
        //int diff = newHeight - curHeight;
        t.floorHeight = (short)newHeight;
        GameObject platformTile = GameWorldController.FindTile(tileX, tileY, TileMap.SURFACE_FLOOR);

        TileVector = CurrentTileMap().getTileVector(tileX, tileY);
        Collider[] colliders = Physics.OverlapBox(TileVector, ContactArea);

        MoveObjectsInContact((float)(newHeight) * 0.15f, colliders);

        //CurrentTileMap().Tiles[tileX, tileX].TileNeedsUpdate();
        DestroyImmediate(platformTile);
        TileMapRenderer.RenderTile(GameWorldController.instance.LevelModel, t.tileX, t.tileY, t, false, false, false, true);
        //MoveTile(platformTile.transform, new Vector3(0f, (float)(diff) * 0.3f, 0f), 0.1f, tileX, tileY);
    }
/*
 * Moves a tile up and down.
 *
 * State is controlled by the triggering objects (eg switches)
 *
 * Usage example
 * The platform puzzle on Level 1 leading to the grave of Korianus.
 */

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        GameObject platformTile = GameWorldController.FindTile(triggerX, triggerY, TileMap.SURFACE_FLOOR);  //Var.FindTile (Var.triggerX,Var.triggerY,1);

        if (CurrentTileMap().Tiles[triggerX, triggerY].floorHeight >= 18)
        {
            //Move the tile to the bottom
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, -0.3f * 7f, 0f), 0.7f));
            flags = (short)State;
            //state = 1;
            CurrentTileMap().Tiles[triggerX, triggerY].floorHeight = 2;
        }
        else
        {
            //Go up a step.
            StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, 0.3f, 0f), 0.1f));
            //flags=State;
            CurrentTileMap().Tiles[triggerX, triggerY].floorHeight += 2;
        }
        flags = (short)State;
    }
 public void RaiseLowerBullfrog(int dir)
 {//TODO:Add a check for tiles at max/min height
     for (int x = -1; x <= 1; x++)
     {
         for (int y = -1; y <= 1; y++)
         {
             if ((x == 0) && (y == 0))
             {
                 //Center tile raise or lower by 2
                 if (((tm.Tiles[BaseX + targetX + x, BaseY + targetY + y].floorHeight < 20) && (dir == +1)) || ((tm.Tiles[BaseX + targetX + x, BaseY + targetY + y].floorHeight > 2) && (dir == -1)))
                 {
                     GameObject platformTile = GameWorldController.FindTile((BaseX + targetX + x), (BaseY + targetY + y), TileMap.SURFACE_FLOOR);
                     CurrentTileMap().Tiles[BaseX + targetX + x, BaseY + targetY + y].floorHeight += (short)(dir * 2);
                     CurrentTileMap().Tiles[BaseX + targetX + x, BaseY + targetY + y].TileNeedsUpdate();
                     Destroy(platformTile);
                 }
             }
             else
             {
                 //raise by 1 if within bounds
                 if (
                     (targetX + x >= 0) && (targetX + x < +8)
                     &&
                     (targetY + y >= 0) && (targetY + y < +8)
                     )
                 {
                     if (((tm.Tiles[BaseX + targetX + x, BaseY + targetY + y].floorHeight < 20) && (dir == +1)) || ((tm.Tiles[BaseX + targetX + x, BaseY + targetY + y].floorHeight > 1) && (dir == -1)))
                     {
                         //Raise or lower by 1
                         GameObject platformTile = GameWorldController.FindTile((BaseX + targetX + x), (BaseY + targetY + y), TileMap.SURFACE_FLOOR);
                         CurrentTileMap().Tiles[BaseX + targetX + x, BaseY + targetY + y].floorHeight += (short)dir;
                         CurrentTileMap().Tiles[BaseX + targetX + x, BaseY + targetY + y].TileNeedsUpdate();
                         Destroy(platformTile);
                     }
                 }
             }
         }
     }
 }
Пример #18
0
    //Quality or some portion of it appears (first 4 bits?) to define the texture of the tile to create at the base.
    //Owner does the same for the top??
    //ZPos is likely the height of the floor.


    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        int        tileXToChange = triggerX;
        int        tileYToChange = triggerY;
        GameObject tile          = GameWorldController.FindTile(tileXToChange, tileYToChange, TileMap.SURFACE_FLOOR);

        if (tile != null)
        {
            TileInfo tileToChange = CurrentTileMap().Tiles[tileXToChange, tileYToChange];
            if (tileToChange.floorHeight == 0)
            {            //create a tile at the floor height
                tileToChange.floorHeight  = (short)(zpos >> 2);
                tileToChange.floorTexture = (short)(owner & 0xf);
            }
            else
            {
                tileToChange.floorHeight  = 0;
                tileToChange.floorTexture = (short)(quality & 0xf);
            }
            tileToChange.TileNeedsUpdate();
            Destroy(tile);
        }
    }
Пример #19
0
 public void RaiseLowerBullfrog(int dir)
 {    //TODO:Add a check for tiles at max/min height
     for (int x = -1; x <= 1; x++)
     {
         for (int y = -1; y <= 1; y++)
         {
             if ((x == 0) && (y == 0))
             {
                 //raise or lower by 2
                 if (((heights[targetX + x, targetY + y] < 8) && (dir == +1)) || ((heights[targetX + x, targetY + y] > -4) && (dir == -1)))
                 {
                     GameObject platformTile = GameWorldController.FindTile((BaseX + targetX + x), (BaseY + targetY + y), 1);
                     StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, (float)(2 * dir) * (0.3f), 0f), 0.1f));
                     heights[targetX + x, targetY + y] += dir * 2;
                 }
             }
             else
             {
                 //raise by 1 if within bounds
                 if (
                     (targetX + x >= 0) && (targetX + x < +8)
                     &&
                     (targetY + y >= 0) && (targetY + y < +8)
                     )
                 {
                     if (((heights[targetX + x, targetY + y] < 8) && (dir == +1)) || ((heights[targetX + x, targetY + y] > -4) && (dir == -1)))
                     {
                         //Raise or lower by 1
                         GameObject platformTile = GameWorldController.FindTile((BaseX + targetX + x), (BaseY + targetY + y), 1);
                         StartCoroutine(MoveTile(platformTile.transform, new Vector3(0f, (float)(1 * dir) * (0.3f), 0f), 0.1f));
                         heights[targetX + x, targetY + y] += dir;
                     }
                 }
             }
         }
     }
 }
Пример #20
0
    /// <summary>
    /// Code for handling steping on the pyramid
    /// </summary>
    /// <param name="tileX">Tile x.</param>
    /// <param name="tileY">Tile y.</param>
    void StepOnPyramid(int tileX, int tileY)
    {
        int previousTileX = 0;
        int previousTileY = 0;

        getPreviousTileXY(out previousTileX, out previousTileY);
        if ((tileX == previousTileX) && (tileY == previousTileY))
        {
            return;
        }
        setPreviousTileXY(tileX, tileY);
        int nextColour = getNextColour(tileX, tileY);

        GameWorldController.instance.currentTileMap().Tiles[tileX, tileY].floorTexture = (short)nextColour;
        GameWorldController.instance.currentTileMap().Tiles[tileX, tileY].TileNeedsUpdate();
        GameObject tile = GameWorldController.FindTile(tileX, tileY, TileMap.SURFACE_FLOOR);

        Destroy(tile);

        int [] ColourSequence   = getColourSequence();
        int    ColourTestPassed = -1;

        for (int i = 0; i <= ColourSequence.GetUpperBound(0); i++)
        {
            if (CheckTileColours(ColourSequence[i]))
            {
                ColourTestPassed = ColourSequence[i];

                break;
            }
        }
        if (ColourTestPassed != -1)
        {                //Set the pyramid to the colour and spawn the moongate
            //TODO:Update the walls of the pyramid here!
            SetPyramidWallColour(ColourTestPassed);
            Debug.Log("Moongate spawned");
            GameWorldController.instance.CurrentObjectList().objInfo[974].instance.setInvis(0);
            //Change the owner and quality of the telport trap at 973 based on the colour
            switch (ColourTestPassed)
            {
            case QbertColourBlue:
                GameWorldController.instance.CurrentObjectList().objInfo[973].instance.quality = 4;
                GameWorldController.instance.CurrentObjectList().objInfo[973].instance.owner   = 16;
                break;

            case QbertColourYellow:
                GameWorldController.instance.CurrentObjectList().objInfo[973].instance.quality = 4;
                GameWorldController.instance.CurrentObjectList().objInfo[973].instance.owner   = 28;
                break;

            case QbertColourPurple:
                GameWorldController.instance.CurrentObjectList().objInfo[973].instance.quality = 4;
                GameWorldController.instance.CurrentObjectList().objInfo[973].instance.owner   = 22;
                break;

            case QbertColourRed:
                GameWorldController.instance.CurrentObjectList().objInfo[973].instance.quality = 4;
                GameWorldController.instance.CurrentObjectList().objInfo[973].instance.owner   = 4;
                break;

            case QbertColourWhite:
                GameWorldController.instance.CurrentObjectList().objInfo[973].instance.quality = 4;
                GameWorldController.instance.CurrentObjectList().objInfo[973].instance.owner   = 40;
                break;

            case QbertColourOrange:                    //Takes you to shrine.
                GameWorldController.instance.CurrentObjectList().objInfo[973].instance.quality = 32;
                GameWorldController.instance.CurrentObjectList().objInfo[973].instance.owner   = 25;
                break;
            }
            if (ColourSequence.GetUpperBound(0) >= 4)
            {                                                                                       //All normal sequences found and the pyramid has been solved at least once. Allow access to the orange pyramid
                Quest.instance.variables[105] = 5;
                GameWorldController.instance.CurrentObjectList().objInfo[666].instance.setInvis(0); //my code is evil...
            }
        }
        else
        {
            GameWorldController.instance.CurrentObjectList().objInfo[974].instance.setInvis(1);
            Debug.Log("Moongate despawned");
        }
        //}
    }
/*
 * 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();
                }
            }
        }
        //}
    }
Пример #22
0
    //cycles the tile textures between owner and quality. Mainly used in Talorus

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        TileMap tm         = CurrentTileMap();
        short   maxTexture = quality;
        short   minTexture = owner;

        for (int x = triggerX; x <= triggerX + 4; x++)
        {
            for (int y = triggerY; y <= triggerY + 4; y++)
            {
                if (TileMap.ValidTile(x, y))
                {
                    tm.Tiles[x, y].floorTexture++;
                    if (tm.Tiles[x, y].floorTexture > maxTexture)
                    {
                        tm.Tiles[x, y].floorTexture = minTexture;
                    }
                    tm.Tiles[x, y].wallTexture++;
                    if (tm.Tiles[x, y].wallTexture > maxTexture)
                    {
                        tm.Tiles[x, y].wallTexture = minTexture;
                    }
                }
            }
        }
        CurrentTileMap().SetTileMapWallFacesUW();
        //Tell the tells and their neighbours to rerender.
        for (int x = triggerX - 1; x <= triggerX + 5; x++)
        {
            for (int y = triggerY - 1; y <= triggerY + 5; y++)
            {
                if (TileMap.ValidTile(x, y))
                {
                    tm.Tiles[x, y].TileNeedsUpdate();
                    GameObject tile     = null;
                    GameObject tileWall = null;
                    switch (tm.Tiles[x, y].tileType)
                    {
                    case TileMap.TILE_DIAG_NE:
                    case TileMap.TILE_DIAG_SE:
                    case TileMap.TILE_DIAG_NW:
                    case TileMap.TILE_DIAG_SW:
                        tile     = GameWorldController.FindTile(x, y, TileMap.SURFACE_FLOOR);
                        tileWall = GameWorldController.FindTile(x, y, TileMap.SURFACE_WALL);
                        break;

                    default:
                        tile = GameWorldController.FindTile(x, y, TileMap.SURFACE_FLOOR); break;
                        //default:
                    }
                    if (tile != null)
                    {
                        Destroy(tile);
                    }
                    if (tileWall != null)
                    {
                        Destroy(tileWall);
                    }
                }
            }
        }
    }