Beispiel #1
0
    public Brick(string rawBrickType, int id)
    {
        this.id        = id;
        this.brickType = parseBrickType(rawBrickType);

        setHealth();
    }
Beispiel #2
0
    public Brick(BrickType brickType, int id)
    {
        this.id        = id;
        this.brickType = brickType;

        setHealth();
    }
    private void OnCollisionEnter(Collision other)
    {
        if (other.collider.CompareTag("Ball"))
        {
            switch (brickType)
            {
            case BrickType.Invincible:
                break;

            case BrickType.OneHit:
                cam.gameObject.GetComponent <CameraShake>().ShakeCamera();
                audioSource.PlayOneShot(glassBreak);
                GameManager.instance.bricksAmount--;

                if (isPowerup)
                {
                    SpawnPowerup();
                }

                Destroy(gameObject);
                break;

            case BrickType.TwoHit:
                cam.gameObject.GetComponent <CameraShake>().ShakeCamera();
                brickType           = BrickType.OneHit;
                rend.material.color = GameManager.instance.oneHitColor;
                break;
            }
        }
    }
Beispiel #4
0
        private void ExecuteAdditionalEffect(BrickType type)
        {
            switch (type)
            {
            case BrickType.ThreeBalls:
            {
                IPad pad = padManager.GetFirst();

                IBall ball1 = new Ball(randomGenerator);
                ball1.SetSize(15, 15);
                SetBallStartPosition(pad, ball1);
                ballManager.Add(ball1);

                IBall ball2 = new Ball(randomGenerator);
                ball2.SetSize(15, 15);
                SetBallStartPosition(pad, ball2);
                ballManager.Add(ball2);
                break;
            }

            case BrickType.DestroyerBall:
            {
                foreach (IBall ball in ballManager)
                {
                    tailManager.Add(ball);
                }
                break;
            }

            default:
                break;
            }
        }
Beispiel #5
0
    private BrickBase TryGetFromPool(BrickType type)
    {
        if (poolObjects == null)
        {
            poolObjects = new List <BrickBase>();
        }

        foreach (var poolObject in poolObjects)
        {
            if (poolObject == null)
            {
                continue;
            }

            if (poolObject.brickType != type)
            {
                continue;
            }

            if (!poolObject.poolInUse)
            {
                return(poolObject);
            }
        }

        return(null);
    }
Beispiel #6
0
    private BrickType GetBrickType(GameObject tmpObj, int r, int c)
    {
        BrickType ret = BrickType.NONE;

        //TODO: Add a call to the bricks script to set it's type and possibly move this into the brick
        switch (m_playField[r, c])
        {
        case "E":                 // Grey
            tmpObj.GetComponent <MeshRenderer>().material.color = Color.grey;
            ret = BrickType.SILVER;
            break;

        case "R":                 // Red
            tmpObj.GetComponent <MeshRenderer>().material.color = Color.red;
            ret = BrickType.RED;
            break;

        case "Y":                 // Yellow
            tmpObj.GetComponent <MeshRenderer>().material.color = Color.yellow;
            ret = BrickType.YELLOW;
            break;

        case "C":                 // Cyan
            tmpObj.GetComponent <MeshRenderer>().material.color = Color.cyan;
            ret = BrickType.CYAN;
            break;

        case "M":                 // Magenta
            tmpObj.GetComponent <MeshRenderer>().material.color = Color.magenta;
            ret = BrickType.MAGENTA;
            break;

        case "G":                 // Green
            tmpObj.GetComponent <MeshRenderer>().material.color = Color.green;
            ret = BrickType.GREEN;
            break;

        case "W":                 // White
            tmpObj.GetComponent <MeshRenderer>().material.color = Color.white;
            ret = BrickType.WHITE;
            break;
            // ... etc ..
        }


        // White    - 50 points
        // Orange   - 60 points
        // Cyan     - 70 points
        // Green    - 80 points
        // Red      - 90 points
        // Blue     - 100 points
        // MAgenta  - 110 points
        // Yellow   - 120 points
        // Silver   -
        // Gold		- Indestructible



        return(ret);
    }
Beispiel #7
0
 public Brick(BrickType type, int breakCount, int width, int height)
 {
     Type       = type;
     BreakCount = breakCount;
     Width      = width;
     Height     = height;
 }
Beispiel #8
0
        public void Create(IBall ball, BrickType type)
        {
            switch (type)
            {
            case BrickType.ThreeBalls:
            {
                IPad pad = ballManager.GetPadAssignedToBall(ball);
                ballBuilder.Create(pad);
                ballBuilder.Create(pad);
                break;
            }

            case BrickType.DestroyerBall:
            {
                ITail tail = new Tail {
                    FireBallTimerCallback = fireBallCounter.FireBallTimerHandler
                };
                tailManager.Add(ball, tail);
                break;
            }

            default:
                break;
            }
        }
Beispiel #9
0
    public void setBrickType(BrickType brickType)
    {
        this.brickType = brickType;
        Renderer renderer = gameObject.GetComponent <Renderer> ();

        {
            valuableParticleSystem.gameObject.SetActive(false);
        }

        Color mainColor = Color.cyan;

        switch (brickType)
        {
        case BrickType.DoubleScore:
            mainColor = new Color(0x2b / 255.0f, 0x9e / 255.0f, 0xb3 / 255.0f);
            break;

        case BrickType.TribbleScore:
            mainColor = new Color(0x44 / 255.0f, 0xaf / 255.0f, 0x69 / 255.0f);
            break;

        case BrickType.GatlinGun:
            mainColor = new Color(0xfc / 255.0f, 0xab / 255.0f, 0x10 / 255.0f);
            break;

        case BrickType.PowerGun:
            mainColor = new Color(0xf8 / 255.0f, 0x33 / 255.0f, 0x3c / 255.0f);
            break;
        }
        ParticleSystem.MainModule main = valuableParticleSystem.main;
        main.startColor = mainColor;
        renderer.material.SetColor("_MainColor", mainColor);
    }
Beispiel #10
0
        /// <summary>
        /// Spawnol egy téglát.
        /// </summary>
        ///


        public Brick CreateBrick(Point position, BrickType type, ParticleType particleType = ParticleType.DefaultBrick, byte hitsNeeded = 1)
        {
            Brick brick = new Brick(position.X, position.Y, type, particleType, hitsNeeded);

            this.EntityList.Add(brick);
            return(brick);
        }
Beispiel #11
0
    public GameObject GetBrickBasedOnType(BrickType type)
    {
        switch (type)
        {
        case BrickType.NORMAL:
            return(GenerateNormalBrick());

        case BrickType.BOMB:
            return(GenerateBombBrick());

        case BrickType.END:
            return(GeneratePortalBrick());

        case BrickType.UNBREAKABLE:
            return(GenerateUnbreakableBrick());

        case BrickType.BOOM_BOT:
            return(GenerateBoomBot());

        case BrickType.RANDOM_BLOW:
            return(GenerateRadomBlowBrick());

        default:
            Debug.LogWarning("Could not find brick gameobject for type : " + type.ToString() + "\n Returning normal type");
            return(GenerateNormalBrick());
        }
    }
Beispiel #12
0
    private void AddModel()
    {
        GameObject model;
        BrickType  brickType = data.brickTypes.Find(x => (x.brickTypeKey == type));

        if (brickType != null)
        {
            model = GameObject.Instantiate(brickType.brickObject);
        }
        else
        {
            Debug.LogError("Could not find model key matching " + type + " to set for this bricks model, Set to fall back model");
            model = GameObject.Instantiate(fallBackModel);
        }

        // Initialise position
        model.transform.parent        = modelHolder.transform;
        model.transform.localScale    = Vector3.one;
        model.transform.localPosition = Vector3.zero;

        // Set Texture
        BrickTexture textureObject = data.textureData.Find(x => (x.textureKey == colour));

        if (textureObject != null)
        {
            model.GetComponentInChildren <Renderer>().material.SetTexture("_BaseMap", textureObject.texture);
        }
        else
        {
            Debug.LogError("Could not find texture key matching " + colour + " to apply to this bricks model, Set to fall back texture");
            model.GetComponentInChildren <Renderer>().material.SetTexture("_BaseMap", fallBackTexture);
        }
    }
Beispiel #13
0
    private void NewBrick()
    {
        CreateBrick();

        _nextBrick = GetNextBrick();
        GameGUI.Instance.SetNextBrick(_nextBrick);
    }
Beispiel #14
0
    private BrickController GetBrick(BrickType type)
    {
        switch (type)
        {
        default:
        case BrickType.I:
            return(PrefabBrickI);

        case BrickType.J:
            return(PrefabBrickJ);

        case BrickType.L:
            return(PrefabBrickL);

        case BrickType.O:
            return(PrefabBrickO);

        case BrickType.S:
            return(PrefabBrickS);

        case BrickType.T:
            return(PrefabBrickT);

        case BrickType.Z:
            return(PrefabBrickZ);
        }
    }
        /// <summary>
        /// Returns color associated to the specified brick type
        /// </summary>
        /// <param name="brick"></param>
        /// <returns></returns>
        public Color GetBrickColor(BrickType brick)
        {
            switch (brick)
            {
            case BrickType.I: return(Color.Cyan);

            case BrickType.J: return(Color.Blue);

            case BrickType.L: return(Color.Orange);

            case BrickType.O: return(Color.Yellow);

            case BrickType.S: return(Color.Lime);

            case BrickType.T: return(Color.Purple);

            case BrickType.Z: return(Color.Red);

            case BrickType.Preset: return(Color.Gray);

            case BrickType.None:
            default:
                return(Color.Black);
            }
        }
Beispiel #16
0
 public void init(int id, int drilledAmount, BrickType brickType, string neighbourCode = "1111", MineralType mineralType = MineralType.None)
 {
     this.id            = id;
     this.drilledAmount = drilledAmount;
     this.brickType     = brickType;
     this.mineralType   = mineralType;
     this.neighbourCode = neighbourCode;
     //set sprite using drilledAmount neighbourCode and BrickManager sprites
     spr       = GetComponent <SpriteRenderer> ();
     spr.color = new Color(BRICK_COLOR[(int)brickType], BRICK_COLOR[(int)brickType], BRICK_COLOR[(int)brickType]);
     if (drilledAmount < 100)
     {
         int nonDrilledSpriteIndex = drilledAmount / 17;
         if (nonDrilledSpriteIndex == 0 && id < BrickManager.COLUMN)
         {
             if (mineralType == MineralType.NonBreakableStone)
             {
                 spr.sprite = BrickManager.current.S_Brick_Stone;
             }
             else
             {
                 spr.sprite = BrickManager.current.S_Brick_Grass;
             }
         }
         else
         {
             spr.sprite = BrickManager.current.NonDrilledBrick[nonDrilledSpriteIndex];
         }
     }
     else
     {
         Drilled();
     }
 }
Beispiel #17
0
 public Brick(BrickType type, int x, int y, int width = 50, int height = 25)
 {
     Boundary.Min  = new Vector2(x, y);
     Boundary.Size = new Vector2(width, height);
     Type          = type;
     IsHit         = false;
 }
Beispiel #18
0
 public void LoadSprite(BrickType type)
 {
     this.type = type;
     if (this.type != BrickType.Default)
     {
         this.GetComponent <SpriteRenderer> ().sprite = emptySprites [(int)type];
     }
 }
Beispiel #19
0
 private void AddBrickToPool(BrickType type, GameObject go)
 {
     if (!brickPool.ContainsKey(type))
     {
         brickPool.Add(type, new List <GameObject>());
     }
     brickPool[type].Add(go);
 }
Beispiel #20
0
 public Brick(BrickType type, int x, int y, int width = 50, int height = 25)
 {
     PosX   = x;
     PosY   = y;
     Width  = width;
     Height = height;
     Type   = type;
     Hit    = false;
 }
Beispiel #21
0
 private void Start()
 {
     brickType = new BrickType
     {
         Hits           = hits,
         Indestructible = indestructible,
         Points         = points
     };
 }
Beispiel #22
0
 public void Initialize(BrickType brickType)
 {
     BrickType      = brickType;
     _initialHealth = GameManager.Instance.BrickHealthManager.GetHealthForBrickType(BrickType);
     Health         = _initialHealth;
     BrickColor     = GameManager.Instance.BrickColorManager.GetColorForBrickType(BrickType);
     Score          = (int)BrickType + 1;
     this.gameObject.GetComponent <Renderer>().material.color = BrickColor;
     Targeted = false;
 }
Beispiel #23
0
    private void OnBrickDestroyed(BrickType type)
    {
        BrickDestroyed?.Invoke(type);

        blocksCount--;
        if (blocksCount == 0)
        {
            AllBricksDestroyed?.Invoke();
        }
    }
 private bool IsTypeAllowed(BrickType[] types, BrickType type)
 {
     foreach (BrickType compare in types)
     {
         if (compare == type)
         {
             return(true);
         }
     }
     return(false);
 }
 public void SwitchBrickToType(BrickType type)
 {
     if (switchBrick != null)
     {
         SwitchBrickToType(switchBrick, type);
     }
     else
     {
         Debug.LogError("Brick that is to be switched is null");
     }
 }
Beispiel #26
0
    private BrickBase GetBrickPrefab(BrickType type)
    {
        foreach (var brick in levelSettings.brickPrefabs)
        {
            if (brick.brickType == type)
            {
                return(brick);
            }
        }

        return(null);
    }
        public Color GetColorForBrickType(BrickType brickType)
        {
            var brickTypeColor = BrickTypesColors.FirstOrDefault(x => x.BrickType == brickType);

            if (brickTypeColor == null)
            {
                Debug.LogError(String.Format("Color value not specified for {0} brick type", brickType));
                throw new ArgumentException();
            }

            return(brickTypeColor.Color);
        }
        public int GetHealthForBrickType(BrickType brickType)
        {
            var brickTypeHealth = BrickTypesHealths.FirstOrDefault(x => x.BrickType == brickType);

            if (brickTypeHealth == null)
            {
                Debug.LogError(String.Format("Health value not specified for {0} brick type", brickType));
                throw new ArgumentException();
            }

            return(brickTypeHealth.Health);
        }
Beispiel #29
0
    public BrickType GetRandomBrickType(float bombChance)
    {
        BrickType type = BrickType.NORMAL;

        int random = Random.Range(1, 100);

        if ((float)random / 100 <= bombChance)
        {
            type = BrickType.BOMB;
        }
        return(type);
    }
Beispiel #30
0
 public static string BrickTypeToString(BrickType type)
 {
     if (type == BrickType.EV3)
     {
         return("EV3");
     }
     if (type == BrickType.NXT)
     {
         return("NXT");
     }
     return("EV3");
 }
Beispiel #31
0
 public void hitBrick()
 {
     if (Type == BrickType.Treasure)
     {
         Type = BrickType.Dead;
         scene.Player.Score += 10;
     }
     else if (Type == BrickType.Normal)
     {
         Type = BrickType.Dead;
         scene.Player.Score += 5;
     }
 }
Beispiel #32
0
        public Model getBrickModel(BrickType type)
        {
            if (type == BrickType.Treasure)
            {
                return treasureBrickModel;
            }

            if (type == BrickType.Unbreakable)
            {
                return unbreakableBrickModel;
            }

            return getRandomBrickModel();
        }
Beispiel #33
0
 public void InitBrick(BrickType brickType)
 {
     this.brickType = brickType;
     MeshRenderer mr = GetComponent<MeshRenderer>();
     switch(brickType) {
         case BrickType.Green:
             mr.material = Resources.Load("Materials/blockGreenMat") as Material;
             break;
         case BrickType.Blue:
             mr.material = Resources.Load("Materials/blockBlueMat") as Material;
             break;
         default: // Default is red.
             mr.material = Resources.Load("Materials/blockRedMat") as Material;
             break;
     }
 }
Beispiel #34
0
        // public Game1 scene;


        public Brick(Game1 scene, Vector3 gridPos, float brickSize) : base(scene)
        {
            this.scene = scene;
            GridPos = gridPos;
            Type = BrickType.Normal; //set brick type
            Model = scene.game.assetManager.getBrickModel(Type); //load normal brick model

            Position = new Vector3(GridPos.X*brickSize*Game1.scaleRatio, GridPos.Y*brickSize*Game1.scaleRatio,
                GridPos.Z*brickSize*Game1.scaleRatio);

            Transform = Matrix.CreateScale(Game1.scaleRatio, Game1.scaleRatio, Game1.scaleRatio)*
                        Matrix.CreateTranslation(Position);

            LocalTransforms = new Matrix[Model.Bones.Count];
            /*
            Vector3[] brickPoints = new Vector3[2];
            brickPoints[0] = new Vector3(Position.X - (brickSize/2), Position.Y - (brickSize/2), Position.Z - (brickSize/2));
            brickPoints[1] = new Vector3(Position.X + (brickSize/2), Position.Y + (brickSize/2), Position.Z + (brickSize/2));
            bounding = BoundingBox.CreateFromPoints(brickPoints);
            */
            World = Matrix.CreateTranslation(Position);
        }
 public bool IsTetrominoInCollision(BrickType[,] tetrominoGrid, int column, int row)
 {
     // check for collisions between the tetromino and the game board's bricks
     for (int iRow = 0; iRow < tetrominoGrid.GetLength(0); iRow++)
     {
         for (int iCol = 0; iCol < tetrominoGrid.GetLength(1); iCol++)
         {
             if (tetrominoGrid[iRow, iCol] != BrickType.None &&
                 m_gameBoardState[iRow + row, iCol + column] != BrickType.None)
                 return true; // collision
         }
     }
     return false;
 }
 public static MovingTetromino CreateMovingTetromino(TetrisGameBoard gameBoard, BrickType brick)
 {
     MovingTetromino inst = null;
     switch(brick)
     {
         case BrickType.J:
             {
                 inst = new MovingTetrominoJ(gameBoard);
                 break;
             }
         case BrickType.L:
             {
                 inst = new MovingTetrominoL(gameBoard);
                 break;
             }
         case BrickType.O:
             {
                 inst = new MovingTetrominoO(gameBoard);
                 break;
             }
         case BrickType.S:
             {
                 inst = new MovingTetrominoS(gameBoard);
                 break;
             }
         case BrickType.T:
             {
                 inst = new MovingTetrominoT(gameBoard);
                 break;
             }
         case BrickType.Z:
             {
                 inst = new MovingTetrominoZ(gameBoard);
                 break;
             }
         default:
         case BrickType.I:
             {
                 inst = new MovingTetrominoI(gameBoard);
                 break;
             }
     }
     inst.InitializeDescriptiveGrid();
     return inst;
 }
 /// <summary>
 /// Can move the tetromino to within the horizontal boundaries of the game board (left,right boundaries only). 
 /// </summary>
 /// <param name="tetrominoGrid"></param>
 /// <param name="column">Column in which the left top cell of the descriptive grid is. Top row has index 0.</param>
 /// <param name="row">Row in which the left top cell of the descriptive grid is. Leftmost column has index 0.</param>
 /// <returns>Returns false if the tetromino starts to intersect the bottom.</returns>
 public bool FitTetrominoToGameBoard(BrickType[,] tetrominoGrid, ref int column, ref int row)
 {
     // first move the tetromino within the boundaries:
     for (int iRow = 0; iRow < tetrominoGrid.GetLength(0); iRow++)
     {
         for (int iCol = 0; iCol < tetrominoGrid.GetLength(1); iCol++)
         {
             if (tetrominoGrid[iRow, iCol] != BrickType.None)
             {
                 if (row + iRow < 0)
                 {
                     // not a problem, does not happen
                 }
                 if (row + iRow >= m_rows)
                 {
                     return false; // bottom was intersected
                 }
                 if (column + iCol < 0)
                 {
                     column = -iCol;
                 }
                 if (column + iCol >= m_columns)
                 {
                     column = m_columns - iCol - 1;
                 }
             }
         }
     }
     return true;
 }
Beispiel #38
0
    private void NewBrick()
    {
        CreateBrick();

        _nextBrick = GetNextBrick();
        GameGUI.Instance.SetNextBrick(_nextBrick);
    }
 /// <summary>
 /// tries to fit the provided tetromino (represented by its descriptiveGrid) into the game board
 /// </summary>
 /// <param name="descriptiveGrid"></param>
 /// <param name="column"></param>
 /// <param name="row"></param>
 /// <param name="rotation"></param>
 /// <returns>true if the provided tetromino could be fit into the game board</returns>
 protected bool TryMovement(BrickType[,] descriptiveGrid, int column, int row, TetrominoRotation rotation)
 {
     bool bottomHit = !m_gameBoard.FitTetrominoToGameBoard(descriptiveGrid, ref column, ref row);
     if (!bottomHit && !m_gameBoard.IsTetrominoInCollision(descriptiveGrid, column, row))
     {
         Rotation = rotation;
         DescriptiveGrid = descriptiveGrid;
         Column = column;
         Row = row;
         return true;
     }
     return false;
 }
Beispiel #40
0
    private void NewGame(int level = 1)
    {
        ClearField();
        Level = level;

        GameGUI.Instance.ShowGameGUI();
        GameGUI.Instance.Level = Level;
        GameGUI.Instance.Lines = 0;
        GameGUI.Instance.Score = 0;

        _nextBrick = GetNextBrick();
        NewBrick();
        Pause = false;
    }
Beispiel #41
0
 public static Brick Create(BrickType type)
 {
     return new Brick( ResourceDictionary[type].GetResource());
 }
		public static string BrickTypeToString (BrickType type)
		{
			if (type == BrickType.EV3){
				return "EV3";	
			} 
			if (type == BrickType.NXT){
				return "NXT";	
			}
			return "EV3"; 
		
		}
Beispiel #43
0
    public void init(int id,int drilledAmount, BrickType brickType, string neighbourCode="1111", MineralType mineralType = MineralType.None)
    {
        this.id = id;
        this.drilledAmount = drilledAmount;
        this.brickType = brickType;
        this.mineralType = mineralType;
        this.neighbourCode = neighbourCode;
        //set sprite using drilledAmount neighbourCode and BrickManager sprites
        spr = GetComponent<SpriteRenderer> ();
        spr.color = new Color (BRICK_COLOR[(int)brickType],BRICK_COLOR[(int)brickType],BRICK_COLOR[(int)brickType]);
        if (drilledAmount < 100) {
            int nonDrilledSpriteIndex = drilledAmount/17;
            if(nonDrilledSpriteIndex==0 && id < BrickManager.COLUMN){
                if(mineralType == MineralType.NonBreakableStone){
                    spr.sprite = BrickManager.current.S_Brick_Stone;
                }else{
                    spr.sprite = BrickManager.current.S_Brick_Grass;
                }

            }else{
                spr.sprite = BrickManager.current.NonDrilledBrick[nonDrilledSpriteIndex];
            }
        } else {
            Drilled();
        }
    }
 private void readCanUngroupTag(ref System.Xml.XmlReader xmlReader)
 {
     if (!xmlReader.IsEmptyElement)
     {
         bool canUngroup = xmlReader.ReadElementContentAsBoolean();
         // we set the flag only if it's false. And also the brick must be a group,
         // so if we read the "CanUngroup" tag in a normal XML brick file, we just ignore this tag
         if (!canUngroup && ((this.mBrickType & BrickType.GROUP) != 0))
             this.mBrickType |= BrickType.SEALED_GROUP;
     }
     else
     {
         xmlReader.Read();
     }
 }
Beispiel #45
0
 private BrickController GetBrick(BrickType type)
 {
     switch (type)
     {
         default:
         case BrickType.I:
             return PrefabBrickI;
         case BrickType.J:
             return PrefabBrickJ;
         case BrickType.L:
             return PrefabBrickL;
         case BrickType.O:
             return PrefabBrickO;
         case BrickType.S:
             return PrefabBrickS;
         case BrickType.T:
             return PrefabBrickT;
         case BrickType.Z:
             return PrefabBrickZ;
     }
 }
Beispiel #46
0
 public void setBrickType(BrickType type)
 {
     Type = type;
     Model = scene.game.assetManager.getBrickModel(Type); //change brick model to appropriate special type
 }
 private void readNotListedInLibraryTag(ref System.Xml.XmlReader xmlReader)
 {
     if (!xmlReader.IsEmptyElement)
     {
         bool shouldIgnore = xmlReader.ReadElementContentAsBoolean();
         if (shouldIgnore)
             this.mBrickType |= BrickType.NOT_LISTED;
     }
     else
     {
         xmlReader.Read();
     }
 }
Beispiel #48
0
    public void SetNextBrick(BrickType type)
    {
        BrickController brick;
        switch (type)
        {
            default:
            case BrickType.I:
                brick = PrefabBrickI;
                break;
            case BrickType.J:
                brick = PrefabBrickJ;
                break;
            case BrickType.L:
                brick = PrefabBrickL;
                break;
            case BrickType.O:
                brick = PrefabBrickO;
                break;
            case BrickType.S:
                brick = PrefabBrickS;
                break;
            case BrickType.T:
                brick = PrefabBrickT;
                break;
            case BrickType.Z:
                brick = PrefabBrickZ;
                break;
        }

        var childsCount = UINextBrickPanel.transform.childCount;
        for (int i = 0; i < childsCount; i++)
            Destroy(UINextBrickPanel.transform.GetChild(i).gameObject);

        var obj = Instantiate(brick);
        obj.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
        var offsetX = 0.0f;
        var offsetY = 0.0f;
        switch (obj.TypeBrick)
        {
            case BrickType.I:
                offsetX = -0.33f;
                break;
            case BrickType.J:
                offsetY = -0.5f;
                break;
            case BrickType.L:
                offsetY = 0.33f;
                break;
            case BrickType.O:
                offsetX = 0.33f;
                offsetY = -0.33f;
                break;
            case BrickType.S:
                offsetY = -0.5f;
                break;
            case BrickType.T:
                offsetY = -0.5f;
                break;
            case BrickType.Z:
                offsetY = -0.5f;
                break;
        }
        var pos = Camera.main.ScreenToWorldPoint(UINextBrickPanel.transform.position);
        pos.x += offsetX;
        pos.y += offsetY;
        pos.z = -1;
        obj.transform.position = pos;
        obj.transform.SetParent(UINextBrickPanel.transform);
    }
Beispiel #49
0
 public int drillerStrenght(BrickType bkType)
 {
     return DRILLER_RATE[(int)bkType];
 }
            private Image mImage = null; // the image of the brick just as it is loaded from the hardrive. If null, the brick is ignored by BlueBrick.

            #endregion Fields

            #region Constructors

            public Brick(string partNumber, Image image, string xmlFileName, Dictionary<string, int> connectionRemapingDictionary)
            {
                // a flag to tell if this part is a group (we'll know it by reading the XML file)
                bool isGroupPart = false;

                // assign the part num
                mPartNumber = partNumber;

                // parse the xml data if the xml file exists
                if (System.IO.File.Exists(xmlFileName))
                {
                    // create an XML reader to parse the data
                    System.Xml.XmlReaderSettings xmlSettings = new System.Xml.XmlReaderSettings();
                    xmlSettings.ConformanceLevel = System.Xml.ConformanceLevel.Document;
                    xmlSettings.IgnoreWhitespace = true;
                    xmlSettings.IgnoreComments = true;
                    xmlSettings.CheckCharacters = false;
                    xmlSettings.CloseInput = true;
                    System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(xmlFileName, xmlSettings);

                    // first find and enter the unique root tag
                    bool rootNodeFound = false;
                    do
                    {
                        xmlReader.Read();
                        isGroupPart = xmlReader.Name.Equals("group");
                        rootNodeFound = isGroupPart || xmlReader.Name.Equals("part");
                    } while (!rootNodeFound && !xmlReader.EOF);

                    // set the brick type if it is a group
                    if (isGroupPart)
                    {
                        mBrickType = Brick.BrickType.GROUP;
                        mGroupInfo = new GroupInfo();
                    }

                    // if we found the root node, start to parse it
                    if (rootNodeFound)
                    {
                        // read the first child node
                        xmlReader.Read();
                        bool continueToRead = !xmlReader.EOF;
                        while (continueToRead)
                        {
                            if (xmlReader.Name.Equals("Author"))
                                readAuthorTag(ref xmlReader);
                            else if (xmlReader.Name.Equals("Description"))
                                readDescriptionTag(ref xmlReader);
                            else if (xmlReader.Name.Equals("SortingKey"))
                                readSortingKeyTag(ref xmlReader);
                            else if (xmlReader.Name.Equals("ImageURL"))
                                readImageURLTag(ref xmlReader);
                            else if (xmlReader.Name.Equals("SnapMargin"))
                                readSnapMarginTag(ref xmlReader);
                            else if (xmlReader.Name.Equals("ConnexionList"))
                                readConnexionListTag(ref xmlReader, connectionRemapingDictionary);
                            else if (xmlReader.Name.Equals("hull"))
                                readHullTag(ref xmlReader);
                            else if (xmlReader.Name.Equals("TrackDesigner"))
                                readTrackDesignerTag(ref xmlReader);
                            else if (xmlReader.Name.Equals("LDraw"))
                                readLDRAWTag(ref xmlReader);
                            else if (xmlReader.Name.Equals("OldNameList"))
                                readImageOldNameTag(ref xmlReader);
                            else if (xmlReader.Name.Equals("CanUngroup"))
                                readCanUngroupTag(ref xmlReader);
                            else if (xmlReader.Name.Equals("SubPartList"))
                                readSubPartListTag(ref xmlReader);
                            else if (xmlReader.Name.Equals("GroupConnectionPreferenceList"))
                                readGroupConnectionPreferenceListTag(ref xmlReader);
                            else if (xmlReader.Name.Equals("NotListedInLibrary"))
                                readNotListedInLibraryTag(ref xmlReader);
                            else
                                xmlReader.Read();
                            // check if we need to continue
                            continueToRead = !(xmlReader.Name.Equals("part") || xmlReader.Name.Equals("group")) && !xmlReader.EOF;
                        }
                    }

                    // close the xml file
                    xmlReader.Close();
                }

                // check if the image given in parameter is not null. This can happen if we only find an xml file
                // without a GIF file, and this happen in two situation: either it's a part that should be ignored
                // or it is a group part. In either we try to create a valid image
                if (image != null)
                {
                    // assign the image if not null (this is a normal part)
                    this.Image = image;
                }
                else
                {
                    // if the image is null check if it is a group or an ignorable part
                    // and leave the mImage null if it is a group, because the image will be created later
                    if (!isGroupPart)
                    {
                        // if the image is null for a normal brick, this brick should be ignored by BlueBrick
                        // The ignore bricks have different meaning than the unknown bricks
                        // if the brick should be ignored, set the brick type and create a dummy small image
                        this.mBrickType |= Brick.BrickType.IGNORABLE | Brick.BrickType.NOT_LISTED;
                        // create a default image otherwise when instanciating this brick, we will try to add
                        // it again to the library as an unknown brick.
                        this.Image = new Bitmap(1, 1); // call the setter to also set the bounding box
                    }
                }

                // If there's no hull, we use the bounding box as a default hull
                if (mHull.Count == 0)
                    mHull = mBoundingBox;
            }