// METHODS -------------------------------------------------------------
 public void Rotate( bool pClockwise )
 {
     if (pClockwise) {
         Top.attachTo(_pucks[2]);
         Right.attachTo(_pucks[1]);
         Left.attachTo (_pucks[0]);
     } else {
         Top.attachTo(_pucks[1]);
         Right.attachTo(_pucks[0]);
         Left.attachTo (_pucks[2]);
     }
     Top = GetSideEntity(0);
     Right = GetSideEntity(2);
     Left = GetSideEntity(1);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Remove a <c>CardCrystallonEntity</c> from <c>availableCards</c>.
 /// </summary>
 /// <param name='pCard'>
 /// <see cref="Crystallography.CardCrystallonEntity"/>
 /// </param>
 private void rm( CardCrystallonEntity pCard )
 {
     availableCards.Remove(pCard);
     if(pCard.Wild) {
         availableWildCards.Remove(pCard);
     }
 }
 //OVERRIDES ------------------------------------------------------------
 public override void removeFromScene(bool doCleanup)
 {
     if( doCleanup ) {
         foreach( AbstractCrystallonEntity e in members ) {
             (e as CardCrystallonEntity).setParticle(0);
         }
         for( int i=0; i<3; i++ ) {
             GameScene.Layers[0].RemoveChild(radialNodes[i], true);
             radialNodes[i] = null;
             radialSprites[i] = null;
         }
         Top = null;
         Left = null;
         Right = null;
         EventHandler<CubeCompleteEventArgs> handler = CubeCompleteDetected;
         if ( handler != null ) {
             handler( this, new CubeCompleteEventArgs {
                 members = Array.ConvertAll( this.members, item => (CardCrystallonEntity)item )
             });
         }
     }
     base.removeFromScene (doCleanup);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Teleport the specified pCard.
 /// </summary>
 /// <param name='pCard'>
 /// P card.
 /// </param>
 public void Teleport( CardCrystallonEntity pCard )
 {
     pCard.Visible = false;
     var _screenWidth = Director.Instance.GL.Context.GetViewport().Width * 0.6f + 220.0f;
     var _screenHeight = Director.Instance.GL.Context.GetViewport().Height * 0.75f + 50.0f;
     pCard.setPosition( _screenWidth * GameScene.Random.NextFloat(), _screenHeight * GameScene.Random.NextFloat() );
     pCard.getNode().RunAction( new CallFunc( () => { pCard.FadeIn(); } ) );
 }
Exemplo n.º 5
0
        /// <summary>
        /// Builds a particular card.
        /// </summary>
        /// <returns>
        /// The card.
        /// </returns>
        /// <param name='pId'>
        /// P identifier.
        /// </param>
        protected CardCrystallonEntity BuildCard(int pId)
        {
            CardCrystallonEntity card;
            if (   GameScene.currentLevel == 999
                && availableWildCards.Count < MAX_WILDCARDS
            //			    && GameScene.Random.NextFloat() < WILDCARD_BASE_CHANCE) { // ------------------------------------------ POSSIBLE WILDCARD
                && WildcardIDs.Contains(pId) ) {

                card = new WildCardCrystallonEntity(_scene, _physics, pId, _physics.SceneShapes[0]);
                availableWildCards.Add(card);
            } else { // ----------------------------------------------------------------------------------------------- NORMAL CARD
                card = new CardCrystallonEntity(_scene, _physics, pId, _physics.SceneShapes[0]);
            }
            availableCards.Add(card);
            return card;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Removes a specific card from the list of available cards.
 /// </summary>
 /// <param name='pCardEntities'>
 /// P card entities.
 /// </param>
 public void MakeUnavailable( CardCrystallonEntity[] pCardEntities )
 {
     foreach ( CardCrystallonEntity e in pCardEntities ) {
         rm ( e );
         // IN INFINITE MODE, RECYCLE CARD IDS
         if ( GameScene.currentLevel == 999 ) {
             DeckOfIDs.Add(e.id);
             TotalCardsInDeck++;
         }
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Removes a <c>CardCrystallonEntity</c> from the scene, with the option to delete entirely.
 /// </summary>
 /// <param name='pCardEntities'>
 /// An array of <c>CardCrystallonEntites</c>
 /// </param>
 public void Remove( CardCrystallonEntity pCardEntity, bool pDelete=false )
 {
     if ( pDelete ) {
         rm(pCardEntity);
     }
     pCardEntity.removeFromScene( pDelete );
 }
Exemplo n.º 8
0
 // METHODS -------------------------------------------------------------------------
 /// <summary>
 /// Add the specified <c>CardCrystallonEntity</c> to <c>availableCards</c>.
 /// </summary>
 /// <see cref="Crystallography.CardCrystallonEntity"/>
 /// P card.
 /// </param>
 public CardCrystallonEntity Add( CardCrystallonEntity pCard )
 {
     if (availableCards.Contains(pCard) == false) {
         availableCards.Add(pCard);
     }
     return pCard;
 }
        /// <summary>
        /// Checks an arbitrary array of cards to see whether any matches are still possible.
        /// </summary>
        /// <returns>
        /// Whether any matches are possible
        /// </returns>
        /// <param name='pCards'>
        /// The array of cards
        /// </param>
        /// <param name='pForScore'>
        /// Whether this is for points or not
        /// </param>
        public bool CheckForMatch( CardCrystallonEntity[] pCards, bool pForScore = false )
        {
            int len = pCards.Length;
            if (len < SelectionGroup.MAX_CAPACITY) {
                return false;
            }

            CardCrystallonEntity[] triad = new CardCrystallonEntity[SelectionGroup.MAX_CAPACITY];
            for (int i=0; i < len-2; i++) {
                for (int j=i+1; j < len-1; j++) {
                    for (int k=j+1; k < len; k++) {
                        triad[0] = pCards[i];
                        triad[1] = pCards[j];
                        triad[2] = pCards[k];
                        if (EvaluateMatch( triad, pForScore ) ) {
                            if ( pForScore ) {
                                MatchScoreEventArgs scoreArgs = CalculateMatchScore( allSameScoreDict );
                                scoreArgs.Node = pCards[0].getNode();
                                scoreArgs.Entity = pCards[0];

                                EventHandler<MatchScoreEventArgs> handler = MatchScoreDetected;
                                if ( handler != null ) {
                                    handler( this, scoreArgs );
                                }
                            }
                            return true;
                        }
                    }
                }
            }
            return false;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Applies qualities to all cards as prescribed in <c>qualityDict</c>
        /// </summary>
        //        private void ApplyQualities() {
        //            foreach ( string key in qualityDict.Keys ) {
        //                if ( !AppMain.ORIENTATION_MATTERS) {
        //                    if ( key == "QOrientation" ) {
        //                        continue;
        //                    }
        //                }
        //                var type = Type.GetType( "Crystallography." + key );
        //                var quality = (IQuality)type.GetProperty("Instance").GetValue(null, null);
        //                var variations = qualityDict[key];
        //                for ( int i=0; i<variations.Length; i++ ) {
        //                    var cardList = variations[i];
        //                    if ( cardList != null ) {
        //                        foreach ( var id in cardList ) {
        //                            quality.Apply(CardManager.Instance.getCardById(id), i);
        //                        }
        //                    }
        //                }
        //            }
        //        }
        public void ApplySingleQualityToEntity( string pQualityName, CardCrystallonEntity pEntity )
        {
            if (qualityDict.ContainsKey(pQualityName) == false) return;

            var type = Type.GetType( "Crystallography." + pQualityName );
            var quality = (IQuality)type.GetProperty("Instance").GetValue(null, null);
            var variations = qualityDict[pQualityName];
            for ( int i=0; i<variations.Length; i++ ) {
                if ( variations[i] == null ) { continue; }
                if ( (variations[i] as IList<int>).Contains (pEntity.id) ) {
                    quality.Apply( pEntity , i );
                    break;
                }
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Applies the array of qualities to entity.
 /// </summary>
 /// <param name='pQualityArray'>
 /// P array of literal quality names e.g. "QColor"
 /// </param>
 /// <param name='pEntity'>
 /// P the card to apply the qualities to
 /// </param>
 public void ApplyQualitiesToEntity( List<string> pQualityList, CardCrystallonEntity pEntity)
 {
     //			var len = pQualityList.Count;
     foreach ( string quality in pQualityList) {
         if ( !AppMain.ORIENTATION_MATTERS ) {
             if ( quality == "QOrientation" ) {
                 continue;
             }
         }
         ApplySingleQualityToEntity( quality, pEntity);
     }
     //			for ( var i=0; i < len; i++ ) {
     //				if ( !AppMain.ORIENTATION_MATTERS ) {
     //					if ( pQualityArray[i] == "QOrientation" ) {
     //						continue;
     //					}
     //				}
     //				ApplySingleQualityToEntity( pQualityArray[i], pEntity);
     //			}
 }
Exemplo n.º 12
0
 /// <summary>
 /// Applies all qualities listed in the level definition sheet to a specific card.
 /// </summary>
 /// <param name='pEntity'>
 /// The specified Card
 /// </param>
 public void ApplyQualitiesToEntity( CardCrystallonEntity pEntity )
 {
     //TODO would be nice to support entities other than cards...
     foreach ( string key in qualityDict.Keys ) {
         if ( !AppMain.ORIENTATION_MATTERS ) {
             if ( key == "QOrientation" ) {
                 continue;
             }
         }
         ApplySingleQualityToEntity( key, pEntity );
     //				var type = Type.GetType( "Crystallography." + key );
     //				var quality = (IQuality)type.GetProperty("Instance").GetValue(null, null);
     //				var variations = qualityDict[key];
     //				for ( int i=0; i<variations.Length; i++ ) {
     //					if ( variations[i] == null ) { continue; }
     //					if ( (variations[i] as IList<int>).Contains (pEntity.id) ) {
     //						quality.Apply( pEntity , i );
     //						break;
     //					}
     //				}
     }
     // the countdown quality is formatted differently and needs to be iterated on its own.
     if ( countdownDict.Keys.Count > 0 ) {
         var c = countdownDict[pEntity.id];
         if ( c != 0 ) {
             QCountdown.Instance.Apply(pEntity, c);
         }
     }
 }