Esempio n. 1
0
        public BlockGrid(Transform container, Action destroyCallback, IGridInstance parent)
            : base(totals: (parent as Ship)?.Totals)
        {
            this.container       = container;
            this.destroyCallback = destroyCallback;

            Parent   = parent;
            Metadata = new BlockGridMetadata(GridMembers);
        }
Esempio n. 2
0
        public void AttemptRebuild(IGridInstance gridInstance)
        {
            var blockGrid = gridInstance.BlockGrid;

            if (!blockGrid.Any())
            {
                return;
            }

            var clusters = GetClusters(gridInstance.BlockGrid);

            if (clusters.Count() > 1)
            {
                Rebuild(gridInstance, clusters);
            }
        }
Esempio n. 3
0
        private void Rebuild(IGridInstance gridInstance, IEnumerable <Cluster> clusters)
        {
            var blockGrid = gridInstance.BlockGrid;

            blockGrid.Rebuilding = true;
            var clustersScheduledForRebuild = clusters.Where(cluster => !cluster.containsController);

            foreach (var cluster in clustersScheduledForRebuild)
            {
                var debris = this.InstantiateAndGet <Debris>(debrisGridPrefab, transform);
                debris.FromCluster(cluster);
                debris.Rigidbody2D.velocity = gridInstance.Rigidbody2D.velocity;
            }

            blockGrid.Rebuilding = false;
            blockGrid.DestroyIfEmpty();
        }
Esempio n. 4
0
 public void Setup(float animTime, IGridInstance parent, BlockContext damageMask)
 {
     this.animTime = animTime;
     barrelAnimator["BarrelAnimation"].speed = 1f / animTime;
     firingPoint.Setup(parent, damageMask);
 }