Example #1
0
    private void FillMatrixRectangle(int iXStart, int iZStart, int XSize, int ZSize, BSEnums.TileType tile, int iNumberOfTraps = BSConstants.NUMBER_OF_TRAPS_PER_RECTANGLE)
    {
        Debug.Log("FillMatrixRectangle()");

/*
 *      for (int x = iXStart; x < (iXStart + XSize) && x < iMatrixTerrain.GetLength(0); x++)
 *      {
 *          for (int z = iZStart; z < (iZStart + ZSize) && z < iMatrixTerrain.GetLength(2); z++)
 *          {
 *
 *              iMatrixTerrain[x, BSConstants.Y_SIZE - 1, z] = (int)tile;
 *              for(int y = 0; y < BSConstants.Y_SIZE - 1; y++)
 *              {
 *                  iMatrixTerrain[x, y, z] = (int)BSEnums.TileType.FIXED;
 *
 *              }
 *          }
 *      }
 *      //Place Entrance
 *      iMatrixTerrain[0, 0, Random.Range(0, BSConstants.Z_SIZE - 1)] = (int)BSEnums.TileType.ENTRANCE;
 *
 *      //Place Exit
 *      iMatrixTerrain[BSConstants.X_SIZE-1, 0, Random.Range(0, BSConstants.Z_SIZE - 1)] = (int)BSEnums.TileType.EXIT;
 */
    }
Example #2
0
 // Use this for initialization
 void Start()
 {
     bPrevBOnTop     = bOnTop;
     prevTopTileType = topTileType;
     prevBotTileType = botTileType;
     tgs             = GetComponentInParent <TileGroupSave>();
     goTopTile       = GetComponentsInChildren <MeshRenderer>()[0];
     goBotTile       = GetComponentsInChildren <MeshRenderer>()[1];
 }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        //if(bPrevBOnTop != bOnTop)
        {
            if (bOnTop)
            {
                transform.rotation = Quaternion.Euler(Vector3.zero);
            }
            else
            {
                transform.rotation = Quaternion.Euler(0, 0, 180);
            }
            bPrevBOnTop = bOnTop;
        }

        if (prevTopTileType != topTileType)
        {
            goTopTile.enabled = true;
            if (goOnTop != null)
            {
                DestroyImmediate(goOnTop);
            }
            //goBotTile.enabled = true;

            if (topTileType == BSEnums.TileType.AIR)
            {
                goTopTile.enabled = false;
                goBotTile.enabled = false;
                if (goOnBot != null)
                {
                    DestroyImmediate(goOnBot);
                }
                prevBotTileType = botTileType = BSEnums.TileType.AIR;
            }
            else if (topTileType == BSEnums.TileType.FIXED)
            {
                goTopTile.material = tgs.fixedMaterial;
            }
            else if (topTileType == BSEnums.TileType.TRAP)
            {
                goTopTile.material              = tgs.trapMaterial;
                goOnTop                         = Instantiate(tgs.prefTrap, goTopTile.transform);
                goOnTop.transform.localScale    = BSConstants.V3_SPIKE_SCALE;
                goOnTop.transform.localPosition = BSConstants.V3_SPIKE_POSITION_IN_TILE;
            }
            else if (topTileType == BSEnums.TileType.ROTATING)
            {
                goTopTile.material = tgs.rotatingMaterialTop;
            }
            else if (topTileType == BSEnums.TileType.ENEMY)
            {
                goOnTop            = Instantiate(tgs.prefEnemy, goTopTile.transform);
                goTopTile.material = tgs.rotatingMaterialTop;

                goOnTop.transform.localScale    = BSConstants.V3_ENEMY_SCALE;
                goOnTop.transform.localPosition = BSConstants.V3_ENEMY_POSITION_IN_TILE;
            }
            else if (topTileType == BSEnums.TileType.ENTRANCE ||
                     topTileType == BSEnums.TileType.EXIT)
            {
                goOnTop            = Instantiate(tgs.prefEntrance, goTopTile.transform);
                goTopTile.material = tgs.rotatingMaterialTop;

                goOnTop.transform.localScale    = BSConstants.V3_ENTRANCE_SCALE;
                goOnTop.transform.localPosition = BSConstants.V3_ENTRANCE_POSITION_IN_TILE;
            }

            prevTopTileType = topTileType;
        }

        if (prevBotTileType != botTileType)
        {
            goBotTile.enabled = true;
            //goTopTile.enabled = true;
            if (goOnBot != null)
            {
                DestroyImmediate(goOnBot);
            }
            if (botTileType == BSEnums.TileType.AIR)
            {
                goTopTile.enabled = false;
                goBotTile.enabled = false;
                if (goOnTop != null)
                {
                    DestroyImmediate(goOnTop);
                }

                prevTopTileType = topTileType = BSEnums.TileType.AIR;
            }
            else if (botTileType == BSEnums.TileType.FIXED)
            {
                goBotTile.material = tgs.fixedMaterial;
            }
            else if (botTileType == BSEnums.TileType.TRAP)
            {
                goBotTile.material              = tgs.trapMaterial;
                goOnBot                         = Instantiate(tgs.prefTrap, goBotTile.transform);
                goOnBot.transform.localScale    = BSConstants.V3_SPIKE_SCALE;
                goOnBot.transform.localPosition = BSConstants.V3_SPIKE_POSITION_IN_TILE;
            }
            else if (botTileType == BSEnums.TileType.ROTATING)
            {
                goBotTile.material = tgs.rotatingMaterialBot;
            }

            else if (botTileType == BSEnums.TileType.ENEMY)
            {
                goOnBot                         = Instantiate(tgs.prefEnemy, goBotTile.transform);
                goBotTile.material              = tgs.rotatingMaterialBot;
                goOnBot.transform.localScale    = BSConstants.V3_ENEMY_SCALE;
                goOnBot.transform.localPosition = BSConstants.V3_ENEMY_POSITION_IN_TILE;
            }
            else if (botTileType == BSEnums.TileType.ENTRANCE ||
                     botTileType == BSEnums.TileType.EXIT)
            {
                goOnBot            = Instantiate(tgs.prefEntrance, goBotTile.transform);
                goBotTile.material = tgs.rotatingMaterialBot;

                goOnBot.transform.localScale    = BSConstants.V3_ENTRANCE_SCALE;
                goOnBot.transform.localPosition = BSConstants.V3_ENTRANCE_POSITION_IN_TILE;
            }

            prevBotTileType = botTileType;
        }
    }
Example #4
0
 public void SetBotTileType(BSEnums.TileType tt)
 {
     tileBotType = tt;
 }
Example #5
0
 public void SetTopTileType(BSEnums.TileType tt)
 {
     tileTopType = tt;
 }