public override AbstractCrystallonEntity BeAddedToGroup(GroupCrystallonEntity pGroup)
 {
     pGroup.Attach( this );
     if (pGroup is SelectionGroup) {
         getNode().StopActionByTag(20);
         Sequence sequence = new Sequence() { Tag = 20 };
         sequence.Add( new DelayTime( 3.0f ) );
         sequence.Add( new CallFunc( () => {
             playSound();
         } ) );
         getNode().RunAction(sequence);
     }
     return this;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks for all-same or all-different qualities in a group
        /// </summary>
        /// <returns>
        /// Whether it matches.
        /// </returns>
        /// <param name='pGroup'>
        /// The group to be checked.
        /// </param>
        /// <param name='pForScore'>
        /// Whether this is for points or not
        /// </param>
        public bool CheckForMatch( GroupCrystallonEntity pGroup, bool pForScore = true )
        {
            //			if (pGroup.population < pGroup.maxPopulation) {
            //				return false;
            //			}
            if ( EvaluateMatch( pGroup.members, pForScore ) ) {
                if ( pForScore ) {
                    MatchScoreEventArgs scoreArgs = CalculateMatchScore( allSameScoreDict );
                    scoreArgs.Node = pGroup.pucks[0].Children.First();
                    scoreArgs.Entity = pGroup;

                    EventHandler<MatchScoreEventArgs> handler = MatchScoreDetected;
                    if ( handler != null ) {
                        handler( this, scoreArgs );
                    }
                }
                return true;
            }
            return false;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Remove a group from the Scene, with the option to delete it entirely
 /// </summary>
 /// <param name='pGroup'>
 /// <see cref="Crystallography.GroupCrystallonEntity"/>
 /// </param>
 /// <param name='pDelete'>
 /// Remove all references to the group from the GroupManager? Defaults to <c>false</c>.
 /// </param>
 public void Remove( GroupCrystallonEntity pGroup, bool pDelete=false )
 {
     pGroup.removeFromScene( pDelete );
     if ( pDelete ) {
         rm ( pGroup );
     }
 }
Ejemplo n.º 4
0
 // METHODS -------------------------------------------------------------------------
 /// <summary>
 /// Add one specified GroupCrystallonEntity to the group manager's list. DOES NOT add to The Scene.
 /// </summary>
 /// <param name='pGroup'>
 /// The GroupCrystallonEntity.
 /// </param>
 public GroupCrystallonEntity Add( GroupCrystallonEntity pGroup )
 {
     availableGroups.Add(pGroup);
     return pGroup;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Remove one specified GroupCrystallonEntity.
 /// </summary>
 /// <param name='pGroup'>
 /// Group to be removed.
 /// </param>
 private void rm( GroupCrystallonEntity pGroup )
 {
     availableGroups.Remove(pGroup);
 }
Ejemplo n.º 6
0
 protected void FadeIn( GroupCrystallonEntity pGroup)
 {
     pGroup.Visible = true;
     foreach( AbstractCrystallonEntity e in pGroup.members ) {
         if (e is CardCrystallonEntity) {
             (e as CardCrystallonEntity).HideGlow();
             (e.getNode() as SpriteBase).Color.W = 0.0f;
             e.getNode().RunAction( new TintBy( new Sce.PlayStation.Core.Vector4(0.0f, 0.0f, 0.0f, 1.0f), 2.0f) );
         }
     }
 }
Ejemplo n.º 7
0
 public void Teleport( GroupCrystallonEntity pGroup )
 {
     pGroup.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;
     pGroup.setPosition( _screenWidth * GameScene.Random.NextFloat(), _screenHeight * GameScene.Random.NextFloat() );
     pGroup.getNode().RunAction( new CallFunc( () => { FadeIn (pGroup); } ) );
 }
 /// <summary>
 /// Determines whether this instance can be added to the specified pGroup.
 /// </summary>
 /// <returns>
 /// <c>true</c> if this instance can be added to the specified pGroup; otherwise, <c>false</c>.
 /// </returns>
 /// <param name='pGroup'>
 /// If set to <c>true</c> p group.
 /// </param>
 public override bool CanBeAddedTo( GroupCrystallonEntity pGroup )
 {
     bool okToSnap = false;
     //			if ( pGroup.MemberType.IsAssignableFrom(this.MemberType) ) { // GROUPS' MEMBER TYPES ARE COMPATIBLE
     if ( pGroup.CheckMemberTypeCompatability(this) ) {
         if( AppMain.ORIENTATION_MATTERS ) { // -------------------- ORIENTATION TEST
             okToSnap = true;
             for ( int i=0; i < _maxMembers; i++ ) {
                 if (_pucks[i].Children.Count > 0 && pGroup._pucks[i].Children.Count > 0) {
                     okToSnap = false;
                     break;
                 }
             }
         } else {
             okToSnap = ( this.population + pGroup.population <= pGroup.maxPopulation );
         }
     }
     return okToSnap;
 }
 // OVERRIDES ----------------------------------------------------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Object-specific code for being added to any group.
 /// </summary>
 /// <returns>
 /// This object
 /// </returns>
 /// <param name='pGroup'>
 /// The destination group
 /// </param>
 public override AbstractCrystallonEntity BeAddedToGroup(GroupCrystallonEntity pGroup)
 {
     getSprite().Color.W = 1.0f; // make fully opaque if selected while fading in.
     HideGlow();
     pGroup.Attach( this );
     pGroup.PostAttach( this );
     return this;
 }
 // OVERRIDES -------------------------------------------------------------
 /// <summary>
 /// Adds the members of this group to the specified GroupCrystallonEntity descendent, 
 /// and schedules this newly emptied group's destruction.
 /// </summary>
 /// <returns>
 /// null -- because this group is scheduled for destruction
 /// </returns>
 /// <param name='pGroup'>
 /// The destination group
 /// </param>
 public override AbstractCrystallonEntity BeAddedToGroup(GroupCrystallonEntity pGroup)
 {
     //			if( AppMain.ORIENTATION_MATTERS == false ) {
     //				if ( pGroup.population == 1 ) {
     //					AbstractCrystallonEntity piece = (AbstractCrystallonEntity)pGroup.Remove(pGroup.members[0]);
     //					(piece as SpriteTileCrystallonEntity).setOrientation(2);
     //					pGroup.Attach( piece );
     //				}
     //			}
     for ( int i=0; i<members.Length; i++) {
         AbstractCrystallonEntity e = members[i];
         if ( e != null ) {
             pGroup.Attach( e );
         }
     }
     pGroup.PostAttach( this );
     // CLEAR MEMBERS LIST & SCHEDULE DELETION OF EMPTIED GROUP
     RemoveAll();
     getNode().Schedule((dt) => { GroupManager.Instance.Remove(this, true); } );
     return null;
 }
Ejemplo n.º 11
0
 // OVERRIDES -------------------------------------------------------------
 //        public override GroupCrystallonEntity Add (ICrystallonEntity pEntity)
 //        {
 //            if (pEntity != null) {
 //                if ( false == pEntity is CubeCrystallonEntity ) { // ------------------------------------ IGNORE CUBES
 //                    if( pEntity.CanBeAddedTo(this) ){
 //                        pEntity.BeAddedToGroup(this);
 //                    }
 //                }
 //            }
 //            return this;
 ////			return base.Add (pEntity);
 //        }
 /// <summary>
 ///  DON'T CALL THIS FUNCTION ON SELECTION GROUP. JUST RETURNS A REFERENCE TO ITSELF.
 /// </summary>
 public override AbstractCrystallonEntity BeAddedToGroup(GroupCrystallonEntity pGroup)
 {
     // Selection Group should never be added to any other group.
     return this;
 }
 public virtual bool CanBeAddedTo( GroupCrystallonEntity pGroup )
 {
     return false;
 }
 /// <summary>
 /// Object-specific code for being added to a GroupCrystallonEntity
 /// </summary>
 /// <returns>
 /// This object
 /// </returns>
 /// <param name='pGroup'>
 /// The group to be added to
 /// </param>
 public abstract AbstractCrystallonEntity BeAddedToGroup( GroupCrystallonEntity pGroup );
 public override AbstractCrystallonEntity BeAddedToGroup(GroupCrystallonEntity pGroup)
 {
     Attach( this );
     return this;
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Spawn a new group the specified pX and pY.
        /// </summary>
        /// <param name='pX'>
        /// X coordinate
        /// </param>
        /// <param name='pY'>
        /// Y coordinate
        /// </param>
        public GroupCrystallonEntity spawn( float pX, float pY, AbstractCrystallonEntity[] pMembers, bool pComplete = false )
        {
            GroupCrystallonEntity g;
            if (pComplete) {
                g = new CubeCrystallonEntity(_scene, _physics, null);
            } else {
                g = new GroupCrystallonEntity(_scene, _physics, null, SelectionGroup.MAX_CAPACITY, pComplete);
            }
            foreach (AbstractCrystallonEntity e in pMembers) {
                g.Add(e);
            }
            g.id = NextId;
            NextId += 1;
            g.setPosition( pX, pY );
            g.BeReleased(g.getPosition());

            EventHandler handler = GroupSpawned;
            if (handler != null) {
                handler( this, null );
            }

            return g;
            //			g.addToScene();
            //			return Add(g);
        }
 public override bool CanBeAddedTo(GroupCrystallonEntity pGroup)
 {
     return false;
 }
 public override bool CanBeAddedTo(GroupCrystallonEntity pGroup)
 {
     bool okToSnap = false;
     if (_sprite.Color.W < 0.8f) {
         Console.WriteLine(_sprite.Color.W);
         return false;
     }
     //			if( pGroup.MemberType.IsAssignableFrom(this.GetType()) ) { // CHECK FOR OBJECT TYPE COMPATIBILITY WITH GROUP
     if ( pGroup.CheckMemberTypeCompatability(this) ){
         if (AppMain.ORIENTATION_MATTERS) { // ------------------- ORIENTATION TEST
             okToSnap = ( pGroup.pucks[_orientationIndex].Children.Count == 0 );
             okToSnap = okToSnap && (Array.IndexOf(pGroup.members, this) == -1);
         } else {
             okToSnap = ( pGroup.population < pGroup.maxPopulation );
         }
     }
     return okToSnap;
 }