public void UpdateValues(AbstractWinCondition condition)
    {
        if (label == null)
        {
            label = GetComponent <UILabel>();
            if (brothers != null && brothers.Length > 1)
            {
                deactivateOffset = (brothers[0].parent.localPosition.x - brothers[1].parent.localPosition.x) * 0.5f;
            }
        }

        WinDestroyTiles winCondition = (condition as WinDestroyTiles);

        if (!label.enabled)
        {
            UpdateBrothers(deactivateOffset);
        }

        if (winCondition == null || (winCondition as WinDestroyTilesSnow) != null || winCondition.destroyTiles.Length <= destroyTilesIndex)
        {
            myTexture.gameObject.SetActive(false);
            label.enabled = false;
            UpdateBrothers(-deactivateOffset);
            return;
        }

        myTexture.gameObject.SetActive(true);
        label.enabled = true;

        DestroyTilesPair destroyTiles = winCondition.destroyTiles[destroyTilesIndex];

        myTexture.mainTexture = destroyTiles.type.transform.Find("Model").renderer.sharedMaterial.mainTexture;

        string key = "Level" + Match3BoardRenderer.levelIdx + "Destroy" + destroyTilesIndex;

        if (TweaksSystem.Instance.intValues.ContainsKey(key))
        {
            label.text = TweaksSystem.Instance.intValues[key].ToString();
        }
        else
        {
            label.text = destroyTiles.number.ToString();
        }
    }
예제 #2
0
    void Start()
    {
        winCondition = (gameLogic.winConditions as WinDestroyTiles);

        if (winCondition == null)
        {
            Destroy(transform.parent.parent.gameObject);
            return;
        }

        if (winCondition.destroyTiles.Length <= destroyTilesIndex)
        {
            if (brothers != null && brothers.Length > 1)
            {
                deactivateOffset = (brothers[0].parent.localPosition.x - brothers[1].parent.localPosition.x) * 0.5f;
                UpdateBrothers(-deactivateOffset);
            }

            Destroy(transform.parent.gameObject);
            return;
        }

        if (targetScore != null)
        {
            targetScore.SetActive(false);
        }

        destroyTiles = winCondition.destroyTiles[destroyTilesIndex];

        myTexture.mainTexture = destroyTiles.type.transform.Find("Model").renderer.sharedMaterial.mainTexture;

        label = GetComponent <UILabel>();

//		Debug.LogWarning("Destroy tiles start: " + label.text);
        StartCoroutine("UpdateValues");

        Match3Tile.OnAnyTileDestroyed      += OnTilesDestroyed;
        SnowTile.OnSnowWinDestroyCondition += OnTilesDestroyed;
    }
	void Start () 
	{
		winCondition = (gameLogic.winConditions as WinDestroyTiles);
		
		if (winCondition == null) {
			Destroy(transform.parent.parent.gameObject);
			return;
		}
		
		if (winCondition.destroyTiles.Length <= destroyTilesIndex) 
		{
			if (brothers != null && brothers.Length > 1) {
				deactivateOffset = (brothers[0].parent.localPosition.x - brothers[1].parent.localPosition.x) * 0.5f;
				UpdateBrothers(-deactivateOffset);
			}
			
			Destroy(transform.parent.gameObject);
			return;
		}
		
		if (targetScore != null) {
			targetScore.SetActive(false);
		}
		
		destroyTiles = winCondition.destroyTiles[destroyTilesIndex];
		
		myTexture.mainTexture = destroyTiles.type.transform.Find("Model").renderer.sharedMaterial.mainTexture;
		
		label = GetComponent<UILabel>();
		
//		Debug.LogWarning("Destroy tiles start: " + label.text);
		StartCoroutine("UpdateValues");
		
		Match3Tile.OnAnyTileDestroyed += OnTilesDestroyed;
		SnowTile.OnSnowWinDestroyCondition += OnTilesDestroyed;
	}