Example #1
0
    protected bool CheckForColorDirectionalDestroy()
    {
        int sumH = matchCount[(int)TileMatchDirection.Left] + matchCount[(int)TileMatchDirection.Right];
        int sumV = matchCount[(int)TileMatchDirection.Top] + matchCount[(int)TileMatchDirection.Bottom];

        if (sumH == 3 && sumV < 2 && (matchCount[(int)TileMatchDirection.Left] == 2 || matchCount[(int)TileMatchDirection.Right] == 2))
        {
            NormalTile tileLeft  = (BoardPiece as Match3BoardPiece).Left.Tile as NormalTile;
            NormalTile tileRight = (BoardPiece as Match3BoardPiece).Right.Tile as NormalTile;

            if (movedByInput || ((tileLeft == null || !tileLeft.movedByInput) && (tileRight == null || !tileRight.movedByInput)))
            {
                movedByInput = true;
                StartCoroutine(SpawnDirectionalDestroy(typeof(ColumnDestroyTile)));
                return(true);
            }
        }

        if (sumV == 3 && sumH < 2 && (matchCount[(int)TileMatchDirection.Top] == 2 || matchCount[(int)TileMatchDirection.Bottom] == 2))
        {
            NormalTile tileTop    = (BoardPiece as Match3BoardPiece).Top.Tile as NormalTile;
            NormalTile tileBottom = (BoardPiece as Match3BoardPiece).Bottom.Tile as NormalTile;

            if (movedByInput || ((tileTop == null || !tileTop.movedByInput) && (tileBottom == null || !tileBottom.movedByInput)))
            {
                movedByInput = true;
                StartCoroutine(SpawnDirectionalDestroy(typeof(RowDestroyTile)));
                return(true);
            }
        }

        return(false);
    }
Example #2
0
    public override void RaiseEventTileSwitchAnimBegan(Match3Tile neighborTile)
    {
        base.RaiseEventTileSwitchAnimBegan(neighborTile);
        lastNeighborTile = neighborTile as NormalTile;

        movedByInput = true;
    }
    public void Replicate()
    {
        int randomIndex        = Random.Range(0, validReplicationList.Count);
        int randomIndexSpecial = Random.Range(0, validReplicationListSpecial.Count);
        Match3BoardPiece targetBoardPiece;

        if (validReplicationList.Count != 0)
        {
            targetBoardPiece = freezerNeighbors[validReplicationList[randomIndex]];
        }
        else
        {
            targetBoardPiece = freezerNeighbors[validReplicationListSpecial[randomIndexSpecial]];
        }

        NormalTile oldTile = targetBoardPiece.Tile as NormalTile;

        //Create new freezer tile
        Match3BoardRenderer.Instance.SpawnSpecificTileAt(targetBoardPiece.BoardPosition, typeof(FreezerTile), TileColorType.None, false);
        FreezerTile newFreezerTile = (targetBoardPiece.Tile as FreezerTile);

        //Raise CREATE event
        RaiseOnFreezerTileCreateEvent(newFreezerTile);

        newFreezerTile.StartCoroutine(newFreezerTile.PlayCreateAnimation());

        if (oldTile != null)
        {
            oldTile.DisableTileLogic();
            GameObject.Destroy(oldTile.gameObject);
        }

        Match3BoardGameLogic.Instance.IsBoardStable = false;
        Match3BoardGameLogic.Instance.TryCheckStableBoard();
    }
    // Use this for initialization
    void Start()
    {
//		yield return new WaitForSeconds(1f);

        NormalTile tile = GetComponent <NormalTile>();

        tile.ApplyLateUpdatePunchEffect(Vector3.up - Vector3.right);
    }
Example #5
0
 /// <summary>
 /// Event raised by the <see cref="WinterchillEffect"/> spawned in the "SpawnEffect(float angle)" method when a tile
 /// entered the freeze trigger of the effect.
 /// </summary>
 /// <param name='tile'>
 /// Tile.
 /// </param>
 void OnTileEnteredFreezeTrigger(NormalTile tile)
 {
     //TODO: currently if a tile doesn't support the freeze effect it will not get destroyed.
     if (tile != this && tile.IsDestructible && tile.Freeze())
     {
         //TODO: Make the tile not match any other tiles because it will be destroyed by this effect anyway. ???
         tilesToDestroy.Add(tile);
     }
 }
    //Called When Color bomb meets Bomb Tile (Alternative effect - temporary until we decide wich will remain)
    //TODO: Lots of redundancy between this coroutine and DestroyDirectionalTiles
    IEnumerator CombineWithBombDestroy()
    {
        if (OnBombColorBombCombine != null)
        {
            OnBombColorBombCombine(this);
        }

        //Update the tiles to destroy list
        Board.ApplyActionToAll((boardPiece) => {
            if (IsValidTarget(boardPiece.Tile, destroyColor))
            {
                tilesToDestroy.Add(boardPiece.Tile as Match3Tile);
            }
        });

        //tilesToDestroy.Remove(neighborTile);
        //Destroy(neighborTile.gameObject);

        StartCoroutine(ConvertTilesToBombTiles());

        yield return(new WaitForSeconds(postConversionWaitTime));

        for (int i = 0; i < tilesToDestroy.Count; i++)
        {
            tileIterator = tilesToDestroy[i] as NormalTile;

//			if ( IsGlacierShardTargetValid(tileIterator) ) {
//				if (prefabTilesDestroyEffect != null) {
//						Transform effectInstance = (Instantiate(prefabTilesDestroyEffect) as GameObject).transform;
//						effectInstance.position = WorldPosition;
//						effectInstance.parent = cachedTransform.parent;
//
//						effectInstance.LookAt(tileIterator.cachedTransform);
//
//						StartCoroutine(MoveTargetTo(effectInstance, tileIterator.cachedTransform, tilesDestroyEffect.destroyTileTime));
////						HOTween.To(effectInstance, tilesDestroyEffect.destroyTileTime, "localPosition", Board[i, j].LocalPosition);
//
//						Destroy(effectInstance.gameObject, tilesDestroyEffect.lifeTime);
//				}

            yield return(new WaitForSeconds(tilesDestroyEffect.destroyTileTime));

            // Repeat the tests for the targeted tile because things may have changed until the glacier shard reaches it.
            if (IsGlacierShardTargetValid(tileIterator))
            {
                tileIterator.Destroy();
            }
//			}
        }

        // Wait for an extra 0.5f seconds for extra safety.
        yield return(new WaitForSeconds(0.5f));

        base.TileDestroy(false);

        Match3BoardGameLogic.Instance.TryCheckStableBoard();
    }
Example #7
0
 /// <summary>
 /// Event raised by the <see cref="TileBombDestroyEffect"/> when a tile enters the destroy trigger of the effect.
 /// </summary>
 /// <param name='tile'>
 /// Tile.
 /// </param>
 void OnTileEnteredDestroyTrigger(NormalTile tile)
 {
     // Make sure we don't add to the destroy list this tile or the time bomb tile it may have spawned.
     if (tile != this && tile.IsDestructible && !(tile is TimeBombTile) && tile.Freeze())
     {
         //TODO: Make the tile not match any other tiles because it will be destroyed by this effect anyway???
         tilesToDestroy.Add(tile);
     }
 }
    //Called When Color bomb meets directional tile
    //TODO: Lots of redundancy between this coroutine and DestroyDirectionalTiles
    IEnumerator DestroyDirectionalTiles()
    {
        if (OnColorBombDirectionalCombine != null)
        {
            OnColorBombDirectionalCombine(this);
        }

        //Update the tiles to destroy list
        Board.ApplyActionToAll((boardPiece) => {
//			if (boardPiece.Tile != null && boardPiece.Tile.IsDestructible && (boardPiece.Tile as  Match3Tile).TileColor == destroyColor)
            if (IsValidTarget(boardPiece.Tile, destroyColor))
            {
                boardPiece.Tile.IsUserMoveable = false;
                tilesToDestroy.Add(boardPiece.Tile as Match3Tile);
            }
        });

        StartCoroutine(ConvertToDirectionalDestroyers());

        yield return(new WaitForSeconds(postConversionWaitTime));

        for (int i = 0; i < tilesToDestroy.Count; i++)
        {
            tileIterator = tilesToDestroy[i] as NormalTile;

//			Ice bolt effect. Removed because no longer needed-------------------------------------------------------------------
//			if ( IsGlacierShardTargetValid(tileIterator) ) {
//				if (prefabTilesDestroyEffect != null) {
//						Transform effectInstance = (Instantiate(prefabTilesDestroyEffect) as GameObject).transform;
//						effectInstance.position = WorldPosition;
//						effectInstance.parent = cachedTransform.parent;
//
//						effectInstance.LookAt(tileIterator.cachedTransform);
//
//						StartCoroutine(MoveTargetTo(effectInstance, tileIterator.cachedTransform, tilesDestroyEffect.destroyTileTime));
////						HOTween.To(effectInstance, tilesDestroyEffect.destroyTileTime, "localPosition", Board[i, j].LocalPosition);
//
//						Destroy(effectInstance.gameObject, tilesDestroyEffect.lifeTime);
//				}
//-------------------------------------------------------------------------------------------------------------------------------

            yield return(new WaitForSeconds(tilesDestroyEffect.destroyTileTime));

            // Repeat the tests for the targeted tile because things may have changed until the glacier shard reaches it.
            if (IsGlacierShardTargetValid(tileIterator))
            {
                tileIterator.Destroy();
            }
//			}
        }

        base.TileDestroy(false);

        Match3BoardGameLogic.Instance.TryCheckStableBoard();
    }
Example #9
0
	public override void InitComponent () {
		base.InitComponent ();

		movedByInput = false;
		
		lastNeighborTile = null;
		
		if (prefabDestroyEffect) {
			destroyEffect = prefabDestroyEffect.GetComponent<DestroyEffect>();
		}
	}
Example #10
0
    protected void PopulateTileList()
    {
        Match3BoardGameLogic.Instance.boardData.ApplyActionToAll((boardPiece) => {
            NormalTile tile = boardPiece.Tile as  NormalTile;

            if (tile && tile.GetType() == typeof(NormalTile))
            {
                tileList.Add(tile);
            }
        });
    }
Example #11
0
    //Used to test the editor scripting
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        NormalTile tile = (NormalTile)target;

        if (GUILayout.Button("Get Planar Position"))
        {
            Debug.Log(tile.name + " : " + tile.GetPlanarPosition());
        }
    }
Example #12
0
	void OnTileSelected(AbstractTile tile)
	{
		if (!tile.IsMoving && tile.IsDestructible && !tile.IsDestroying && tile.IsUserMoveable && !(tile as NormalTile).IsFrozen()) 
		{
			Match3Tile.OnTileTap -= OnTileSelected;
			tileToDestroy = tile as NormalTile;
			
			effectPosition = tile.cachedTransform;
			
			ActuallyUsingItem();
			DoItem();
		}
	}
Example #13
0
 public void OnStartNormalTileDestroySndEvent(NormalTile tile, bool isSingleDestroyed)
 {
     if (!isSingleDestroyed)
     {
         sndTileMatch.PlayQueued();
     }
     else
     {
         // Use another sound effect controller with different properties when multiple tiles will be destroyed one by one
         // to ensure that the next destroy sound won't stop the previous destroy sound (given the impression of a "machine-gun" sound play sequence).
         sndTileDestroy.PlayQueued();
     }
 }
Example #14
0
    void OnTileSelected(AbstractTile tile)
    {
        if (!tile.IsMoving && tile.IsDestructible && !tile.IsDestroying && tile.IsUserMoveable && !(tile as NormalTile).IsFrozen())
        {
            Match3Tile.OnTileTap -= OnTileSelected;
            tileToDestroy         = tile as NormalTile;

            effectPosition = tile.cachedTransform;

            ActuallyUsingItem();
            DoItem();
        }
    }
Example #15
0
    public override void InitComponent()
    {
        base.InitComponent();

        movedByInput = false;

        lastNeighborTile = null;

        if (prefabDestroyEffect)
        {
            destroyEffect = prefabDestroyEffect.GetComponent <DestroyEffect>();
        }
    }
    public void OnTriggerEnter(Collider target)
    {
        if (target.gameObject.layer == LayerMask.NameToLayer("BoardTile"))
        {
            NormalTile targetTile = target.GetComponent <NormalTile>();

            if (targetTile)
            {
                // Mark that these tiles are going to be destroyed one by one (not gathered in a list and then destroyed in a bulk).
                targetTile.isSingleDestroyed = true;

                targetTile.Destroy();
                RaiseOnTargetDestroyed();
            }
        }
    }
    /// <summary>
    /// Determines whether this tile instance is a valid target for colorBombInteraction
    /// </summary>
    /// <returns>
    /// <c>true</c> if this instance is valid target; otherwise, <c>false</c>.
    /// </returns>
    public bool IsValidTarget(AbstractTile tile, TileColorType destroyColor)
    {
        NormalTile target = tile as NormalTile;

//		if (target != null &&
//			target.IsDestructible &&
//			target.TileColor == destroyColor)
//		{
//			return true;
//		}
//		return false;
//
        return(target != null &&
               target.IsDestructible &&
               target.TileColor == destroyColor &&
               !target.IsDestroying &&
               !(target is SnowTile) &&
               !target.IsFrozen());
    }
    protected IEnumerator CombineWithColorBombDestroy(float perTileWaitTime = 0.075f)
    {
        if (wasFirstTapped)
        {
            if (OnColorBombColorBombCombine != null)
            {
                OnColorBombColorBombCombine(this);
            }

            // Init the delay after each glacier shard will be thrown towards a tile.
            for (int colIdx = 0; colIdx < Board.NumColumns; colIdx++)
            {
                for (int rowIdx = 0; rowIdx < Board.NumRows; rowIdx++)
                {
                    tileIterator = Board[rowIdx, colIdx].Tile as NormalTile;

                    if (IsGlacierShardTargetValid(tileIterator) && tileIterator != this && tileIterator != lastNeighborTile)
                    {
                        // Throw the next glacier shard at the next found tile after "totalDelay" seconds.
                        StartCoroutine(StartGlacierDestroyForTile(tileIterator, (targetTile) =>
                        {
                            if (IsGlacierShardTargetValid(targetTile) && targetTile != this && targetTile != lastNeighborTile)
                            {
                                targetTile.isSingleDestroyed = true;
                                targetTile.IsMatched         = true;
                                targetTile.Destroy();
                            }
                        }));

                        yield return(new WaitForSeconds(perTileWaitTime));
                    }
                }
            }
        }

        // Wait for the last shard to hit the board, wait an extra 1 second for safety and then destroy this tile.
        yield return(new WaitForSeconds(tilesDestroyEffect.destroyTileTime + 0.5f));

        base.TileDestroy(false);

        Match3BoardGameLogic.Instance.TryCheckStableBoard();
    }
    // Use this for initialization
    IEnumerator Start()
    {
        NormalTile normalTile = GetComponent <NormalTile>();

//		normalTile.tileModelTransform.localPosition += Vector3.up * normalTile.fallBouncePower;
        HOTween.To(normalTile.tileModelTransform, normalTile.fallBounceStiffness, new TweenParms()
                   .Prop("localPosition", Vector3.up * normalTile.fallBouncePower)
                   .Ease(EaseType.EaseOutSine)                              //, amplit, period)
                   );

        yield return(new WaitForSeconds(normalTile.fallBounceStiffness * 0.5f));

        Tweener fallBounceAnimTweener = HOTween.To(normalTile.tileModelTransform, normalTile.fallBounceStiffness, new TweenParms()
                                                   .Prop("localPosition", normalTile.tileModelLocalPos)
                                                   .Ease(EaseType.EaseOutBounce)//, amplit, period)
                                                   );

//		yield return new WaitForSeconds(0.1f);
//		fallBounceAnimTweener.Play();
//		fallBounceAnimTweener.Kill();
    }
	/// <summary>
	/// Raises the trigger enter Unity event.
	/// </summary>
	/// <param name='other'>
	/// The collider that entered this trigger.
	/// </param>
	void OnTriggerEnter(Collider other)
	{
		if (!enabled)  //|| other.gameObject.layer != Match3Globals.Instance.layerBoardTile
		{
			return;
		}
		
		tileComponent = other.GetComponent<NormalTile>();
		
		if (OnTileEntered != null && tileComponent != null)
		{
			OnTileEntered(tileComponent);
			return;
		}
		
		boardPieceComponent = other.GetComponent<Match3BoardPiece>();
		
		if (OnBoardPieceEntered != null && boardPieceComponent != null)
		{
			OnBoardPieceEntered(boardPieceComponent);
		}
	}
    /// <summary>
    /// Raises the trigger enter Unity event.
    /// </summary>
    /// <param name='other'>
    /// The collider that entered this trigger.
    /// </param>
    void OnTriggerEnter(Collider other)
    {
        if (!enabled)          //|| other.gameObject.layer != Match3Globals.Instance.layerBoardTile
        {
            return;
        }

        tileComponent = other.GetComponent <NormalTile>();

        if (OnTileEntered != null && tileComponent != null)
        {
            OnTileEntered(tileComponent);
            return;
        }

        boardPieceComponent = other.GetComponent <Match3BoardPiece>();

        if (OnBoardPieceEntered != null && boardPieceComponent != null)
        {
            OnBoardPieceEntered(boardPieceComponent);
        }
    }
    /// <summary>
    /// Starts the glacier destroy for a targeted tile. Used by "CombineWithColorBombDestroy(...)" method.
    /// </summary>
    /// <returns>
    /// The glacier destroy for tile.
    /// </returns>
    /// <param name='targetTile'>
    /// Target tile.
    /// </param>
    /// <param name='afterDelay'>
    /// After delay.
    /// </param>
    protected IEnumerator StartGlacierDestroyForTile(NormalTile targetTile, System.Action <NormalTile> OnFinished = null)
    {
//		yield return new WaitForSeconds(afterDelay);
        targetTile.IsUserMoveable = false;

        Transform effectInstance = (Instantiate(iceTrailEffect) as GameObject).transform;

        effectInstance.position = WorldPosition;
        effectInstance.parent   = cachedTransform.parent;

        effectInstance.LookAt(targetTile.cachedTransform);

        StartCoroutine(MoveTargetTo(effectInstance, targetTile.cachedTransform, tilesDestroyEffect.destroyTileTime));

        GameObject.Destroy(effectInstance.gameObject, tilesDestroyEffect.lifeTime * 1.5f);

        yield return(new WaitForSeconds(tilesDestroyEffect.destroyTileTime));

        if (OnFinished != null)
        {
            OnFinished(targetTile);
        }
    }
Example #23
0
    private void GenerateGridFromCSV(string filepath, string filename)
    {
        Tile[] obstacleTiles =
        {
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-481")),
                type = "ObstacleTile"
            },
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-484")),
                type = "ObstacleTile"
            },
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-487")),
                type = "ObstacleTile"
            },
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-489")),
                type = "ObstacleTile"
            },
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-554")),
                type = "ObstacleTile"
            }
        };

        Tile[] normalTiles =
        {
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-105")),
                type = "NormalTile"
            }, // uncracked
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-81")),
                type = "NormalTile"
            },
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-82")),
                type = "NormalTile"
            },
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-83")),
                type = "NormalTile"
            },
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-103")),
                type = "NormalTile"
            },
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-104")),
                type = "NormalTile"
            },
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-292")),
                type = "NormalTile"
            },
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-293")),
                type = "NormalTile"
            },
            new Tile()
            {
                tile = (GameObject)Instantiate(Resources.Load("tileset-294")),
                type = "NormalTile"
            }
        };

        Tile start = new Tile()
        {
            tile = (GameObject)Instantiate(Resources.Load("StartTile")),
            type = "StartTile"
        };

        Tile end = new Tile()
        {
            tile = (GameObject)Instantiate(Resources.Load("EndTile")),
            type = "EndTile"
        };

        Tile trap = new Tile()
        {
            tile = (GameObject)Instantiate(Resources.Load("SpikeTile")),
            type = "TrapTile"
        };

        Tile ice = new Tile()
        {
            tile = (GameObject)Instantiate(Resources.Load("IceTile")),
            type = "IceTile"
        };


        string[,] GridCSV = CsvUtil.readData(filepath, filename);
        rows = GridCSV.GetLength(0);
        cols = GridCSV.GetLength(1);

        float centerOffsetX = -cols * tileSize / 2; // center
        float centerOffsetY = rows * tileSize / 2;

        for (int i = 0; i < GridCSV.GetLength(0); i++)
        {
            List <Tile> tileRow = new List <Tile>();

            for (int j = 0; j < GridCSV.GetLength(1); j++)
            {
                GameObject tile;
                if (GridCSV[i, j] == "S")
                {
                    tile = (GameObject)Instantiate(start.tile, transform);
                    StartTile startTile = new StartTile()
                    {
                        tile = tile,
                        type = "StartTile"
                    };
                    tileRow.Add(startTile);
                }
                else if (GridCSV[i, j] == "E")
                {
                    tile = (GameObject)Instantiate(end.tile, transform);
                    EndTile endTile = new EndTile()
                    {
                        tile = tile,
                        type = "EndTile"
                    };
                    tileRow.Add(endTile);
                }
                else if (GridCSV[i, j] == "W") //W = wallobstacle
                {
                    int randomChoice = (int)Random.Range(0, obstacleTiles.Length - 0.001f);
                    tile = (GameObject)Instantiate(obstacleTiles[randomChoice].tile, transform);
                    ObstacleTile obstacleTile = new ObstacleTile()
                    {
                        tile = tile,
                        type = "ObstacleTile"
                    };
                    tileRow.Add(obstacleTile);
                }
                else if (GridCSV[i, j] == "T")
                {
                    tile = (GameObject)Instantiate(trap.tile, transform);
                    TrapTile trapTile = new TrapTile()
                    {
                        tile = tile,
                        type = "TrapTile"
                    };
                    tileRow.Add(trapTile);
                }
                else if (GridCSV[i, j] == "I")
                {
                    tile = (GameObject)Instantiate(ice.tile, transform);
                    IceTile iceTile = new IceTile()
                    {
                        tile = tile,
                        type = "IceTile"
                    };
                    tileRow.Add(iceTile);
                }
                else
                {
                    int randomChoice = (int)Random.Range(0, normalTiles.Length - 0.001f);
                    tile = (GameObject)Instantiate(normalTiles[randomChoice].tile, transform);
                    NormalTile normalTile = new NormalTile()
                    {
                        tile = tile,
                        type = "NormalTile"
                    };
                    tileRow.Add(normalTile);
                }

                float posX = j * tileSize + centerOffsetX;
                float posY = i * -tileSize + centerOffsetY;
                if (GridCSV[i, j] == "S")
                {
                    StartPos = new Vector2(posX, posY);
                }
                tile.transform.position = new Vector2(posX, posY);
            }
            Tiles.Add(tileRow);
        }

        foreach (Tile obstacleTile in obstacleTiles)
        {
            Destroy(obstacleTile.tile);
        }
        foreach (Tile normalTile in normalTiles)
        {
            Destroy(normalTile.tile);
        }
        Destroy(start.tile);
        Destroy(end.tile);
        Destroy(trap.tile);
        Destroy(ice.tile);

        //bool x = await Task.FromResult(false);
    }
Example #24
0
	/// <summary>
	/// Event raised by the <see cref="TileBombDestroyEffect"/> when a tile enters the destroy trigger of the effect.
	/// </summary>
	/// <param name='tile'>
	/// Tile.
	/// </param>
	void OnTileEnteredDestroyTrigger(NormalTile tile) {
		// Make sure we don't add to the destroy list this tile or the time bomb tile it may have spawned.
		if ( tile != this && tile.IsDestructible && !(tile is TimeBombTile) && tile.Freeze()) {
			//TODO: Make the tile not match any other tiles because it will be destroyed by this effect anyway???
			tilesToDestroy.Add(tile);
		}
	}
	protected bool IsGlacierShardTargetValid(NormalTile targetTile) {
		return targetTile != null && !(targetTile is SnowTile) && !(targetTile is FreezerTile) && !targetTile.IsFrozen() && targetTile.IsDestructible && !targetTile.IsDestroying;
	}
	/// <summary>
	/// Starts the glacier destroy for a targeted tile. Used by "CombineWithColorBombDestroy(...)" method.
	/// </summary>
	/// <returns>
	/// The glacier destroy for tile.
	/// </returns>
	/// <param name='targetTile'>
	/// Target tile.
	/// </param>
	/// <param name='afterDelay'>
	/// After delay.
	/// </param>
	protected IEnumerator StartGlacierDestroyForTile(NormalTile targetTile, System.Action<NormalTile> OnFinished = null) {
//		yield return new WaitForSeconds(afterDelay);
		targetTile.IsUserMoveable = false;
		
		Transform effectInstance = (Instantiate(iceTrailEffect) as GameObject).transform;
		effectInstance.position = WorldPosition;
		effectInstance.parent = cachedTransform.parent;
		
		effectInstance.LookAt(targetTile.cachedTransform);

		StartCoroutine(MoveTargetTo(effectInstance, targetTile.cachedTransform, tilesDestroyEffect.destroyTileTime));
		
		GameObject.Destroy(effectInstance.gameObject, tilesDestroyEffect.lifeTime * 1.5f);
		
		yield return new WaitForSeconds(tilesDestroyEffect.destroyTileTime);
		
		if (OnFinished != null) {
			OnFinished(targetTile);
		}
	}
	//Called When Color bomb meets Bomb Tile (Alternative effect - temporary until we decide wich will remain)
	//TODO: Lots of redundancy between this coroutine and DestroyDirectionalTiles
	IEnumerator CombineWithBombDestroy() {
	
		if (OnBombColorBombCombine != null) {
			OnBombColorBombCombine(this);
		}
		
		//Update the tiles to destroy list
		Board.ApplyActionToAll((boardPiece) => {
			if (IsValidTarget(boardPiece.Tile, destroyColor))
			{
					tilesToDestroy.Add(boardPiece.Tile as Match3Tile);
			}
		});
			
		//tilesToDestroy.Remove(neighborTile);
		//Destroy(neighborTile.gameObject);
		
		StartCoroutine(ConvertTilesToBombTiles());
		
		yield return new WaitForSeconds(postConversionWaitTime);
		
		for(int i = 0; i < tilesToDestroy.Count; i++) {
			tileIterator = tilesToDestroy[i] as NormalTile;
			
//			if ( IsGlacierShardTargetValid(tileIterator) ) {
//				if (prefabTilesDestroyEffect != null) {
//						Transform effectInstance = (Instantiate(prefabTilesDestroyEffect) as GameObject).transform;
//						effectInstance.position = WorldPosition;
//						effectInstance.parent = cachedTransform.parent;
//						
//						effectInstance.LookAt(tileIterator.cachedTransform);
//				
//						StartCoroutine(MoveTargetTo(effectInstance, tileIterator.cachedTransform, tilesDestroyEffect.destroyTileTime));
////						HOTween.To(effectInstance, tilesDestroyEffect.destroyTileTime, "localPosition", Board[i, j].LocalPosition);
//						
//						Destroy(effectInstance.gameObject, tilesDestroyEffect.lifeTime);
//				}
				
				yield return new WaitForSeconds(tilesDestroyEffect.destroyTileTime);
				
				// Repeat the tests for the targeted tile because things may have changed until the glacier shard reaches it.
				if ( IsGlacierShardTargetValid(tileIterator) ) {
					tileIterator.Destroy();
				}
//			}
		}
		
		// Wait for an extra 0.5f seconds for extra safety.
		yield return new WaitForSeconds(0.5f);
		
		base.TileDestroy(false);
		
		Match3BoardGameLogic.Instance.TryCheckStableBoard();
	}
	//Called When Color bomb meets directional tile
	//TODO: Lots of redundancy between this coroutine and DestroyDirectionalTiles
	IEnumerator DestroyDirectionalTiles() 
	{
		if (OnColorBombDirectionalCombine != null) {
			OnColorBombDirectionalCombine(this);
		}
		
		//Update the tiles to destroy list
		Board.ApplyActionToAll((boardPiece) => {
//			if (boardPiece.Tile != null && boardPiece.Tile.IsDestructible && (boardPiece.Tile as  Match3Tile).TileColor == destroyColor)
			if (IsValidTarget(boardPiece.Tile, destroyColor)) 
			{
				boardPiece.Tile.IsUserMoveable = false;
				tilesToDestroy.Add(boardPiece.Tile as Match3Tile);
			}
		});	
		
		StartCoroutine(ConvertToDirectionalDestroyers());
		
		yield return new WaitForSeconds(postConversionWaitTime);
		
		for(int i = 0; i < tilesToDestroy.Count; i++) 
		{
			tileIterator = tilesToDestroy[i] as NormalTile;
			
//			Ice bolt effect. Removed because no longer needed-------------------------------------------------------------------
//			if ( IsGlacierShardTargetValid(tileIterator) ) {
//				if (prefabTilesDestroyEffect != null) {
//						Transform effectInstance = (Instantiate(prefabTilesDestroyEffect) as GameObject).transform;
//						effectInstance.position = WorldPosition;
//						effectInstance.parent = cachedTransform.parent;
//						
//						effectInstance.LookAt(tileIterator.cachedTransform);
//				
//						StartCoroutine(MoveTargetTo(effectInstance, tileIterator.cachedTransform, tilesDestroyEffect.destroyTileTime));
////						HOTween.To(effectInstance, tilesDestroyEffect.destroyTileTime, "localPosition", Board[i, j].LocalPosition);
//						
//						Destroy(effectInstance.gameObject, tilesDestroyEffect.lifeTime);
//				}
//-------------------------------------------------------------------------------------------------------------------------------
			
				yield return new WaitForSeconds(tilesDestroyEffect.destroyTileTime);
				
				// Repeat the tests for the targeted tile because things may have changed until the glacier shard reaches it.
				if ( IsGlacierShardTargetValid(tileIterator) ) {
					tileIterator.Destroy();
				}
//			}
		}
		
		base.TileDestroy(false);
		
		Match3BoardGameLogic.Instance.TryCheckStableBoard();
	}
 protected bool IsGlacierShardTargetValid(NormalTile targetTile)
 {
     return(targetTile != null && !(targetTile is SnowTile) && !(targetTile is FreezerTile) && !targetTile.IsFrozen() && targetTile.IsDestructible && !targetTile.IsDestroying);
 }
Example #30
0
	public override void RaiseEventTileSwitchAnimBegan(Match3Tile neighborTile) 
	{
		base.RaiseEventTileSwitchAnimBegan(neighborTile);
		lastNeighborTile = neighborTile as NormalTile;
		
		movedByInput = true;
	}
Example #31
0
 public void OnStartTileImpactBounceSndEvent(NormalTile tile)
 {
     // Plays from 3 random audio clips setup on the sound effect
     sndTileDropImpact.PlayQueued();
 }
	protected IEnumerator CombineWithColorBombDestroy(float perTileWaitTime = 0.075f)
	{
		if (wasFirstTapped) {
			if (OnColorBombColorBombCombine != null) {
				OnColorBombColorBombCombine(this);
			}
			
			// Init the delay after each glacier shard will be thrown towards a tile.
			for(int colIdx = 0; colIdx < Board.NumColumns; colIdx++) {
				for(int rowIdx = 0; rowIdx < Board.NumRows; rowIdx++) {
					tileIterator = Board[rowIdx, colIdx].Tile as NormalTile;
					
					if ( IsGlacierShardTargetValid(tileIterator) && tileIterator != this && tileIterator != lastNeighborTile) 
					{
						// Throw the next glacier shard at the next found tile after "totalDelay" seconds.
						StartCoroutine(StartGlacierDestroyForTile(tileIterator, (targetTile) => 
						{
							if ( IsGlacierShardTargetValid(targetTile) && targetTile != this && targetTile != lastNeighborTile ) {
								targetTile.isSingleDestroyed = true;
								targetTile.IsMatched = true;
								targetTile.Destroy();
							}
						}));
						
						yield return new WaitForSeconds(perTileWaitTime);
					}
				}
			}
		}
		
		// Wait for the last shard to hit the board, wait an extra 1 second for safety and then destroy this tile.
		yield return new WaitForSeconds(tilesDestroyEffect.destroyTileTime + 0.5f);
	
		base.TileDestroy(false);
		
		Match3BoardGameLogic.Instance.TryCheckStableBoard();
	}
	public void OnStartNormalTileDestroySndEvent(NormalTile tile, bool isSingleDestroyed)
	{
		if ( !isSingleDestroyed ) {
			sndTileMatch.PlayQueued();
		}
		else {
			// Use another sound effect controller with different properties when multiple tiles will be destroyed one by one
			// to ensure that the next destroy sound won't stop the previous destroy sound (given the impression of a "machine-gun" sound play sequence).
			sndTileDestroy.PlayQueued();
		}
	}
	public void OnStartTileImpactBounceSndEvent(NormalTile tile)
	{
		// Plays from 3 random audio clips setup on the sound effect
		sndTileDropImpact.PlayQueued();
	}
	/// <summary>
	/// Event raised by the <see cref="WinterchillEffect"/> spawned in the "SpawnEffect(float angle)" method when a tile 
	/// entered the freeze trigger of the effect.
	/// </summary>
	/// <param name='tile'>
	/// Tile.
	/// </param>
	void OnTileEnteredFreezeTrigger(NormalTile tile) {
		//TODO: currently if a tile doesn't support the freeze effect it will not get destroyed.
		if ( tile != this && tile.IsDestructible && tile.Freeze() ) {
			//TODO: Make the tile not match any other tiles because it will be destroyed by this effect anyway. ???
			tilesToDestroy.Add(tile);
		}
	}