Exemplo n.º 1
0
        private void BuildGameFieldAnimated()
        {
            this.state = CreationState.Creating;
            var board = Game.Instance.GameBoard;

            if (board == null)
            {
                return;
            }

            if (fieldVisuals.Capacity < board.Cells.Length)
            {
                fieldVisuals.Capacity = board.Cells.Length;
            }

            var w = board.Width;
            var h = board.Height;
            var d = board.Depth;

            var fieldMarginSize = FieldSize + Margin;
            var worldSize       = new Vector3(w * fieldMarginSize.x, h * fieldMarginSize.y, d * fieldMarginSize.z);
            var startPoint      = (-worldSize + fieldMarginSize) / 2f;

            BoardEffectOrchestrator.PlayEffect(board.Cells, new SphericalGrowthTimeline(new Vector3(0, -worldSize.y, 0), 30f),
                                               item => BoardVisuals.BoardToWorldPosition((BoardCell)item), item =>
            {
                var cell                    = (BoardCell)item;
                var instance                = Instantiate(Prefab);
                instance.BoardCell          = cell;
                instance.transform.position = startPoint + new Vector3(cell.PosX * fieldMarginSize.x, cell.PosY * fieldMarginSize.y, cell.PosZ * fieldMarginSize.z);
                instance.UpdateHullColor();
                fieldVisuals.Add(instance);
            }, this.OnVisualsCreated);
        }
Exemplo n.º 2
0
        private void DestroyGameFieldAnimated()
        {
            this.state = CreationState.Deleting;

            if (this.fieldVisuals.Count == 0)
            {
                this.OnVisualsDeleted();
                return;
            }

            var startPoint = this.fieldVisuals[0] != null ? this.fieldVisuals[0].transform.position : Vector3.zero;

            BoardEffectOrchestrator.PlayEffect(this.fieldVisuals,
                                               new SphericalGrowthTimeline(startPoint, 30f),
                                               item => ((FieldVisual)item).transform.position,
                                               item => Destroy(((FieldVisual)item).gameObject),
                                               this.OnVisualsDeleted);
        }