private void Match3_OnLevelSet(object sender, System.EventArgs e)
    {
        LevelSO levelSO = match3.GetLevelSO();

        switch (levelSO.goalType)
        {
        default:
        case LevelSO.GoalType.Glass:
            transform.Find("glassImage").gameObject.SetActive(true);
            glassText.gameObject.SetActive(true);

            targetScoreText.gameObject.SetActive(false);
            break;

        case LevelSO.GoalType.Score:
            transform.Find("glassImage").gameObject.SetActive(false);
            glassText.gameObject.SetActive(false);

            targetScoreText.gameObject.SetActive(true);

            targetScoreText.text = levelSO.targetScore.ToString();
            break;
        }

        UpdateText();
    }
    private void Awake()
    {
        levelSO         = match3.GetLevelSO();
        Columns         = levelSO.width;
        Rows            = levelSO.height;
        NumCellTypes    = levelSO.gemList.Count;
        NumSpecialTypes = levelSO.goalType == LevelSO.GoalType.Glass ? 1 : 0;

        agent = GetComponent <Agent>();
    }
예제 #3
0
    private void Awake()
    {
        levelSO = match3.GetLevelSO();

        Columns         = levelSO.width;
        Rows            = levelSO.height;
        NumCellTypes    = levelSO.gemList.Count;
        NumSpecialTypes = levelSO.goalType == LevelSO.GoalType.Score ? 0 : 1;

        agent = GetComponent <Agent>();

        match3Visual.OnStateWaitingForUser += Match3Visual_OnStateWaitingForUser;
        match3.OnGemGridPositionDestroyed  += Match3_OnGemGridPositionDestroyed;
        match3.OnGlassDestroyed            += Match3_OnGlassDestroyed;
        match3.OnMoveUsed   += Match3_OnMoveUsed;
        match3.OnOutOfMoves += Match3_OnOutOfMoves;
        match3.OnWin        += Match3_OnWin;
    }
예제 #4
0
    private void Match3_OnWin(object sender, System.EventArgs e)
    {
        winLoseTransform.gameObject.SetActive(true);
        winLoseTransform.Find("Text").GetComponent <TextMeshProUGUI>().text = "<color=#1ACC23>YOU WIN!</color>";

        LevelProgression.LevelStars levelStars = LevelProgression.LevelStars._1;

        LevelNumberSO levelNumberSO = match3.GetLevelNumberSO();
        LevelSO       levelSO       = match3.GetLevelSO();

        Debug.Log("GetUsedMoveCount:  " + match3.GetUsedMoveCount());
        switch (levelSO.goalType)
        {
        case LevelSO.GoalType.Score:
            if (match3.GetUsedMoveCount() <= levelSO.stars3Goal)
            {
                levelStars = LevelProgression.LevelStars._3;
            }
            else
            {
                if (match3.GetUsedMoveCount() <= levelSO.stars2Goal)
                {
                    levelStars = LevelProgression.LevelStars._2;
                }
            }
            break;

        case LevelSO.GoalType.Glass:
            if (match3.GetUsedMoveCount() <= levelSO.stars3Goal)
            {
                levelStars = LevelProgression.LevelStars._3;
            }
            else
            {
                if (match3.GetUsedMoveCount() <= levelSO.stars2Goal)
                {
                    levelStars = LevelProgression.LevelStars._2;
                }
            }
            break;
        }

        winLoseTransform.Find("Star_1").GetComponent <Image>().color = starUnachievedColor;
        winLoseTransform.Find("Star_2").GetComponent <Image>().color = starUnachievedColor;
        winLoseTransform.Find("Star_3").GetComponent <Image>().color = starUnachievedColor;

        switch (levelStars)
        {
        case LevelProgression.LevelStars._0:
            winLoseTransform.Find("Star_1").gameObject.SetActive(false);
            winLoseTransform.Find("Star_2").gameObject.SetActive(false);
            winLoseTransform.Find("Star_3").gameObject.SetActive(false);
            break;

        case LevelProgression.LevelStars._1:
            winLoseTransform.Find("Star_1").GetComponent <Image>().color = starAchievedColor;
            break;

        case LevelProgression.LevelStars._2:
            winLoseTransform.Find("Star_1").GetComponent <Image>().color = starAchievedColor;
            winLoseTransform.Find("Star_2").GetComponent <Image>().color = starAchievedColor;
            break;

        case LevelProgression.LevelStars._3:
            winLoseTransform.Find("Star_1").GetComponent <Image>().color = starAchievedColor;
            winLoseTransform.Find("Star_2").GetComponent <Image>().color = starAchievedColor;
            winLoseTransform.Find("Star_3").GetComponent <Image>().color = starAchievedColor;
            break;
        }

        LevelProgression.SetLevelStars(match3.GetLevelNumberSO(), levelStars);
    }
예제 #5
0
    public void Setup(Match3 match3, Grid <Match3.GemGridPosition> grid)
    {
        this.match3 = match3;
        this.grid   = grid;

        float cameraYOffset = 1f;

        cameraTransform.position = new Vector3(grid.GetWidth() * .5f, grid.GetHeight() * .5f + cameraYOffset, cameraTransform.position.z);

        match3.OnGemGridPositionDestroyed += Match3_OnGemGridPositionDestroyed;
        match3.OnNewGemGridSpawned        += Match3_OnNewGemGridSpawned;

        // Initialize Visual
        gemGridDictionary   = new Dictionary <Match3.GemGrid, GemGridVisual>();
        glassGridDictionary = new Dictionary <Match3.GemGridPosition, GlassGridVisual>();

        for (int x = 0; x < grid.GetWidth(); x++)
        {
            for (int y = 0; y < grid.GetHeight(); y++)
            {
                Match3.GemGridPosition gemGridPosition = grid.GetGridObject(x, y);
                Match3.GemGrid         gemGrid         = gemGridPosition.GetGemGrid();

                Vector3 position = grid.GetWorldPosition(x, y);
                position = new Vector3(position.x, 20f);

                // Visual Transform
                Transform gemGridVisualTransform = Instantiate(pfGemGridVisual, position, Quaternion.identity);
                gemGridVisualTransform.Find("sprite").GetComponent <SpriteRenderer>().sprite = gemGrid.GetGem().sprite;

                GemGridVisual gemGridVisual = new GemGridVisual(gemGridVisualTransform, gemGrid);

                gemGridDictionary[gemGrid] = gemGridVisual;

                // Glass Visual Transform
                Transform glassGridVisualTransform = Instantiate(pfGlassGridVisual, grid.GetWorldPosition(x, y), Quaternion.identity);

                GlassGridVisual glassGridVisual = new GlassGridVisual(glassGridVisualTransform, gemGridPosition);

                glassGridDictionary[gemGridPosition] = glassGridVisual;

                // Background Grid Visual
                Instantiate(pfBackgroundGridVisual, grid.GetWorldPosition(x, y), Quaternion.identity);
            }
        }

        SetBusyState(.5f, () => SetState(State.TryFindMatches));

        Camera.main.orthographicSize = Mathf.Max(8.5f, match3.GetLevelSO().width * .92f);

        backgroundTransform.position = new Vector3(
            cameraTransform.position.x,
            cameraTransform.position.y,
            0f
            );
        backgroundTransform.localScale = new Vector3(
            3000,
            Camera.main.orthographicSize * 2f
            );

        isSetup = true;
    }