Exemple #1
0
        public void Clear()
        {
            var elements = new HashSet <FieldElement>(Elements);

            foreach (var element in elements)
            {
                element.Destroy();
            }
            Elements.Clear();
            LastElement = null;
            Ball?.Destroy();
            Ball = null;
        }
Exemple #2
0
        public void CreateNext()
        {
            if (LastElement == null)
            {
                return;
            }

            FieldCoords  nextDir = Random.value > 0.5f ? FieldCoords.Top : FieldCoords.Right;
            FieldCoords  nextPos = LastElement.Coords + nextDir;
            FieldElement next    = _elementsFactory.Create(nextPos);

            next.Entity.Behaiour.SelectState(BehaiourState.Create);
            LastElement = next;
        }
Exemple #3
0
        public void CreateStart()
        {
            Clear();

            int   startSize = _gameSettings.StartSize;
            float tileSize  = _gameSettings.TileSize;

            for (int i = 0; i < startSize; i++)
            {
                for (int j = 0; j < startSize; j++)
                {
                    _elementsFactory.Create(new FieldCoords(i, j));
                }
            }

            LastElement = _elementsFactory.Create(new FieldCoords(startSize / 2, startSize));
            LastElement.Entity.Behaiour.SelectState(BehaiourState.Create);


            Ball = _ballFactory.Create();
            var c = startSize * tileSize / 2;

            Ball.Position = new Vector3(c, 0.14f, c);
        }