Ejemplo n.º 1
0
        /// <summary>
        ///     Добавляет бонус-эффект к гему. Тут добавляется внешний вид
        ///     Действия описываются в BonusAction()
        /// </summary>
        public void AddBonus(Constants.BonusType bonus)
        {
            Bonus = bonus;
            var bonusGO = new GameObject();
            bonusGO.transform.parent = transform;
            bonusGO.AddComponent<SpriteRenderer>();
            bonusGO.transform.localPosition = new Vector3(0, 0, -1);

            if (bonus == Constants.BonusType.CollumnBomb){
                bonusGO.name = "CollumnBonus";
                bonusGO.GetComponent<SpriteRenderer>().sprite = BonusCollumnBombSprite;
            }
            if (bonus == Constants.BonusType.RowBomb){
                bonusGO.name = "RowBonus";
                bonusGO.GetComponent<SpriteRenderer>().sprite = BonusRowBombSprite;
            }
        }
Ejemplo n.º 2
0
        public void Init(BoardLogic board, int x, int y, Constants.BonusType bonus)
        {
            _board = board;
            transform.parent = board.transform;

            _isHighlighted = false;
            _animationCounter = 0;
            X = x;
            Y = y;
            _spriteRenderer = GetComponent<SpriteRenderer>();
            if (bonus != Constants.BonusType.NoBonus){
                AddBonus(bonus);
            }

            // Calc Position:
            var screenPos = Utils.GetScreenPosByGridPos(GetVectorPos(), transform);
            var goalWorldPos = Camera.main.ScreenToWorldPoint(screenPos);
            transform.localPosition = goalWorldPos;
        }