Exemplo n.º 1
0
        public static IGameObject createGameObject(int row, int col, BallsTypes type, bool isPlayer = false)
        {
            IGameObject gameObject;

            switch (type)
            {
            case BallsTypes.Universal:
                gameObject = new UniversalBubble(type);
                break;

            default:
                gameObject = new Bubble(type);
                break;
            }

            Color32 color = getColor(type);

            Vector3 pos;

            if (isPlayer)
            {
                pos = FieldManager.findCoordsForPlayer();
            }
            else
            {
                pos = FieldManager.findCoordsByRowCol(row, col);

                gameObject.row = row;
                gameObject.col = col;
            }

            gameObject.createShape(FieldManager.CELL_WIDTH * 0.5f, pos.x, pos.y, color, FieldManager.gamePivot);
            gameObject.setActive = true;
            return(gameObject);
        }
Exemplo n.º 2
0
        private void populateField()
        {
//            if (tempField.Count == 0)
//            {
//                return;
//            }

            Random rand     = new Random();
            var    ballsNum = 200;
            var    startRow = 5;

            for (int i = 0; i < ballsNum; i++)
            {
                BallsTypes type = (BallsTypes)rand.Next(1, 4);

                int row = startRow + i / FIELD_WIDTH;
                int col = i + startRow * FIELD_WIDTH - FIELD_WIDTH * row;

                tempField.Add(new GameObjectData(row, col, type));
            }


            maxHeight = tempField.Max(data => data.row) + 1;
            FieldManager.rowOffset = ((maxHeight - 1) % 2 == 0) ? 0 : 1;
        }
Exemplo n.º 3
0
        public void createPlayerBubble()
        {
            Random     rand = new Random();
            BallsTypes type = (BallsTypes)rand.Next(1, 5);

            IGameObject gameObject = GameObjectsPool.getOrCreateFromPool(type, isPlayer: true);

            currentPlayerBall = gameObject;
        }
Exemplo n.º 4
0
        public void createGameObject(int row, int col, BallsTypes type)
        {
            IGameObject gameObject = GameObjectsPool.getOrCreateFromPool(type, row, col);

            field.Add(gameObject.id, gameObject);

            if (gameObject.row > LAST_VISIBLE_ROW)
            {
                gameObject.view.setActive = false;
            }
        }
Exemplo n.º 5
0
        public static IGameObject getOrCreateFromPool(BallsTypes type, int row = 0, int col = 0, bool isPlayer = false)
        {
            if (objects.ContainsKey(type))
            {
                if (objects[type].Count > 0)
                {
                    IGameObject obj = objects[type].Pop();
                    obj.setActive = true;
                    obj.setCoords(row, col, isPlayer);

                    return(obj);
                }
            }

            return(GameObjectsFactory.createGameObject(row, col, type, isPlayer));
        }
Exemplo n.º 6
0
        private static Color getColor(BallsTypes type)
        {
            switch (type)
            {
            case BallsTypes.Yellow:
                return(Color.yellow);

            case BallsTypes.Red:
                return(Color.red);

            case BallsTypes.Green:
                return(Color.green);

            case BallsTypes.Universal:
                return(Color.black);

            default:
                return(Color.black);
            }
        }
Exemplo n.º 7
0
        public Bubble(BallsTypes type)
        {
            _type = type;

            _id = GetHashCode();
        }
 public UniversalBubble(BallsTypes type) : base(type)
 {
     _stars = GameObject.Instantiate(starsPrortotype);
 }
Exemplo n.º 9
0
 public GameObjectData(int row, int col, BallsTypes type)
 {
     this.row  = row;
     this.col  = col;
     this.type = type;
 }