         
     }
 
+    func GenerateColorForLevel(level:Int) {
+        let r = CGFloat(arc4random() % 255)
+        let g = CGFloat(arc4random() % 255)
+        let b = CGFloat(arc4random() % 255)
+        
+        colorA = UIColor(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: 1)
+        
+        // 从基数 0.2 开始递增，增量为 0.03 * Level
+        let alpha = 0.2 + (0.03 * CGFloat(level));
+        
+        colorB = colorA.colorWithAlphaComponent(alpha)
+        
+        ranmodColorIndex = Int(arc4random()) % tileCount;
+    }
 }

    // MARK: -
    
    func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return tileNum
    }
    
    func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {

    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        var cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! UICollectionViewCell
        
        if indexPath.row == self.ranmodColorIndex {
            cell.backgroundColor = colorB;
        }else{
            cell.backgroundColor = colorA;
        }

        return cell
    }
    
    func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
        if indexPath.row == self.ranmodColorIndex {
            
            level = level + 1
            
            scoreLabel.text = "\(level)"
            
            self.GenerateColorForLevel(level);
            
            // reload CollectionView (使用 reloadSections 会有个默认渐显动画)
            tileCollectionView.reloadSections(NSIndexSet(index: 0))
        }
    }
    
    // MARK: -
