protected void ResetSelection() { ClusterHighlight(firstCluster, false); firstCluster = null; ClusterHighlight(secondCluster, false); secondCluster = null; }
protected void ConnectClusters() { List <Block> blockList = new List <Block>(); Quaternion clusterRotation = firstCluster.transform.rotation; blockList.AddRange(firstCluster.attachedBlockList); firstCluster.DetachAllBlocks(); blockList.AddRange(secondCluster.attachedBlockList); secondCluster.DetachAllBlocks(); List <Vector3> blockPositions = new List <Vector3>(); foreach (var block in blockList) { blockPositions.Add(block.transform.position); } Vector3 clusterPosition = VectorUtils.FindCentroid(blockPositions); BlockCluster blockCluster = BlockCluster.SpawnCluster(clusterPosition); foreach (var block in blockList) { blockCluster.AddBlockRange(blockList); } ClusterHighlight(blockCluster, false); ResetSelection(); }
protected void ClusterHighlight(BlockCluster blockCluster, bool state) { if (blockCluster == null) { return; } foreach (var block in blockCluster.attachedBlockList) { var material = block.SwitchMaterial(state); } }
protected void SelectCluster(BlockCluster blockCluster) { if (firstCluster == null) { firstCluster = blockCluster; ClusterHighlight(blockCluster, true); return; } if (secondCluster == null) { if (firstCluster == blockCluster) { return; } secondCluster = blockCluster; ClusterHighlight(blockCluster, true); ConnectClusters(); } }
protected void SetClusterSettings(BlockCluster blockCluster) { blockCluster.SetSettings(useGravity); }
protected void RemoveCluster(BlockCluster blockCluster) { clusterList.Remove(blockCluster); }
protected void AddCluster(BlockCluster blockCluster) { clusterList.Add(blockCluster); }