Пример #1
0
 internal bool AddToCollection(IGameObject gameObject)
 {
     if (Collection.Count() < Columns * Rows) // if there is space left
     {
         // reset rotation
         gameObject.MyRotation = 0f;
         var ccNode = (CCNode)gameObject;
         Collection.Add(gameObject);
         CollectionNode.AddChild(ccNode);
         // place the node correctly
         ccNode.AnchorPoint = CCPoint.AnchorMiddle;
         float ratioWidth  = ccNode.ContentSize.Width / BoxSize.Width;
         float ratioHeight = ccNode.ContentSize.Height / BoxSize.Height;
         if (ratioWidth > ratioHeight)
         {
             gameObject.FitToWidth(BoxSize.Width);
         }
         else
         {
             gameObject.FitToHeight(BoxSize.Height);
         }
         if (gameObject.GetTotalScale() > MaxScale)
         {
             ccNode.Scale = MaxScale;
         }
         UpdateCollectionPositions();
         MoveCollectionNode(CCPoint.Zero);
         return(true);
     }
     return(false);
 }