protected void RaiseEventTilesSwitchAnimFinished(bool canRaiseGlobalSwitchEvent, AbstractBoardAnimations sender, AbstractTile src, AbstractTile dst) {
		// These 2 tiles aren't animating anymore.
		src.IsMoving = false;
		dst.IsMoving = false;
		
		(src as Match3Tile).GravityEnabled = true;
		(dst as Match3Tile).GravityEnabled = true;
		
		if (canRaiseGlobalSwitchEvent && onTilesSwitchAnimFinished != null) {
			onTilesSwitchAnimFinished(sender, src, dst);
		}
	}
Exemple #2
0
    public void OnTilesSwitchAnimFinished(AbstractBoardAnimations sender, AbstractTile srcTile, AbstractTile dstTile)
    {
//		Debug.Log("Switch anim finished!");
        // Update the board positions of the animated tiles (update the board logic after the animation finishes).
        boardData.SwitchTiles(srcTile, dstTile);

        Match3Tile srcMatch3Tile = srcTile as Match3Tile;
        Match3Tile dstMatch3Tile = dstTile as Match3Tile;

        bool foundMatches = matchesFinder.FindMatches();

        if ((!foundMatches || (!srcMatch3Tile.IsMatched && !dstMatch3Tile.IsMatched)) &&
            (srcMatch3Tile.SwitchBackOnMatchFail && dstMatch3Tile.SwitchBackOnMatchFail))
        {
            if (OnUserTilesSwitchBad != null)
            {
                OnUserTilesSwitchBad(srcMatch3Tile, dstMatch3Tile);
            }

            srcMatch3Tile.IsTileSwitching = true;
            dstMatch3Tile.IsTileSwitching = true;

            BoardAnimations.SwitchTilesAnim(false, srcMatch3Tile, dstMatch3Tile,
                                            (_sender, _srcTile, _dstTile) =>
            {
                boardData.SwitchTiles(_srcTile, _dstTile);
                _srcTile.IsTileSwitching = false;
                _dstTile.IsTileSwitching = false;
            }
                                            );

            srcMatch3Tile.RaiseEventSwitchBackOnFail(dstMatch3Tile);
            dstMatch3Tile.RaiseEventSwitchBackOnFail(srcMatch3Tile);
        }
        else if (srcMatch3Tile.IsMatched || dstMatch3Tile.IsMatched)
        {
            srcMatch3Tile.IsTileSwitching = false;
            dstMatch3Tile.IsTileSwitching = false;

            loseConditions.NewMove();

            srcMatch3Tile.RaiseEventSwitchSuccess(dstMatch3Tile);
            dstMatch3Tile.RaiseEventSwitchSuccess(srcMatch3Tile);
        }
        else if (!srcMatch3Tile.SwitchBackOnMatchFail || !dstMatch3Tile.SwitchBackOnMatchFail)
        {
            // Reset the "IsTileSwitching" property for tiles that don't switch back on match fail because they finished their switch animation.
            srcMatch3Tile.IsTileSwitching = false;
            dstMatch3Tile.IsTileSwitching = false;
        }

        DestroyLastFoundMatches();
    }
Exemple #3
0
    protected void RaiseEventTilesSwitchAnimFinished(bool canRaiseGlobalSwitchEvent, AbstractBoardAnimations sender, AbstractTile src, AbstractTile dst)
    {
        // These 2 tiles aren't animating anymore.
        src.IsMoving = false;
        dst.IsMoving = false;

        (src as Match3Tile).GravityEnabled = true;
        (dst as Match3Tile).GravityEnabled = true;

        if (canRaiseGlobalSwitchEvent && onTilesSwitchAnimFinished != null)
        {
            onTilesSwitchAnimFinished(sender, src, dst);
        }
    }
	public void TileMoved(AbstractBoardAnimations sender, AbstractTile srcTile, AbstractTile dstTile) 
	{
		StartTimer();
	}
	public void OnTilesSwitchAnimFinished(AbstractBoardAnimations sender, AbstractTile srcTile, AbstractTile dstTile) {
//		Debug.Log("Switch anim finished!");
		// Update the board positions of the animated tiles (update the board logic after the animation finishes).
		boardData.SwitchTiles(srcTile, dstTile);

		Match3Tile srcMatch3Tile = srcTile as Match3Tile;
		Match3Tile dstMatch3Tile = dstTile as Match3Tile;
		
		bool foundMatches = matchesFinder.FindMatches();
		
		if (( !foundMatches || (!srcMatch3Tile.IsMatched && !dstMatch3Tile.IsMatched) ) &&
			(srcMatch3Tile.SwitchBackOnMatchFail && dstMatch3Tile.SwitchBackOnMatchFail)) 
		{
			if (OnUserTilesSwitchBad != null) {
				OnUserTilesSwitchBad(srcMatch3Tile, dstMatch3Tile);
			}

			srcMatch3Tile.IsTileSwitching = true;
			dstMatch3Tile.IsTileSwitching = true;

			BoardAnimations.SwitchTilesAnim(false, srcMatch3Tile, dstMatch3Tile,
				(_sender, _srcTile, _dstTile) => 
				{
					boardData.SwitchTiles(_srcTile, _dstTile);
					_srcTile.IsTileSwitching = false;
					_dstTile.IsTileSwitching = false;
				}
			);
			
			srcMatch3Tile.RaiseEventSwitchBackOnFail(dstMatch3Tile);
			dstMatch3Tile.RaiseEventSwitchBackOnFail(srcMatch3Tile);
		} 
		else if (srcMatch3Tile.IsMatched || dstMatch3Tile.IsMatched) {
			srcMatch3Tile.IsTileSwitching = false;
			dstMatch3Tile.IsTileSwitching = false;
			
			loseConditions.NewMove();
			
			srcMatch3Tile.RaiseEventSwitchSuccess(dstMatch3Tile);
			dstMatch3Tile.RaiseEventSwitchSuccess(srcMatch3Tile);
		}
		else if (!srcMatch3Tile.SwitchBackOnMatchFail || !dstMatch3Tile.SwitchBackOnMatchFail) { 
			// Reset the "IsTileSwitching" property for tiles that don't switch back on match fail because they finished their switch animation.
			srcMatch3Tile.IsTileSwitching = false;
			dstMatch3Tile.IsTileSwitching = false;
		}
				
		DestroyLastFoundMatches();
	}	
Exemple #6
0
 public void TileMoved(AbstractBoardAnimations sender, AbstractTile srcTile, AbstractTile dstTile)
 {
     StartTimer();
 }