Tutorial

Dictionary 로 Cover 설정 및 List로 Spawn Unit을 특정하여 원하는데로 작동 할 수 있도록 개발

private void Start()
        {
            if (PlayerPrefs.GetInt("TutorialKey") != 1) return;
            spawnManager.OnMatchFound += HandleMatchFound;
            TutorialSteps = new Queue<TutorialStep>();
            commonRewardManager.OnRewardSelected += HandleMatchFound;
            
            // 3Matched
            TutorialSteps.Enqueue(new TutorialStep(
                new[] 
                { 
	                new Vector2Int(1, 4), new Vector2Int(2, 4), 
	                new Vector2Int(3, 4), new Vector2Int(4, 4) 
                },
                new Vector3(4, 4, 0), new Vector3(3, 4, 0),
                1,
                "Move units by swiping them")
            );
            // 4Matched
            TutorialSteps.Enqueue(new TutorialStep(
                new []
                {
	                new Vector2Int(1,4), new Vector2Int(2,4), 
	                new Vector2Int(3,4), new Vector2Int(4,4), 
	                new Vector2Int(3,5)
                },
                new Vector3(3,5,0), 
                new Vector3(3,4,0),
                2,
                "Swipe once more to combine units\n
                Merging 4 units will level up 2 units.")
            );
            // 5Matched
            TutorialSteps.Enqueue(new TutorialStep(
                new[] 
                { 
	                new Vector2Int(0, 1), new Vector2Int(0, 2), 
	                new Vector2Int(0, 3), new Vector2Int(0, 4), 
	                new Vector2Int(0,5), new Vector2Int(1, 3) 
                },
                new Vector3(1, 3, 0),
                new Vector3(0, 3, 0),
                3,
                "Combining 5 makes a higher tier unit")
            );
            // Power Up Matched
            // Choose Power Up
            // Press Long Object
            // Null Swap
            ...

								  
            ProcessTutorialStep(TutorialSteps.Dequeue());
        }

Grid Setting

각 유닛을 특정하여 Grid와 맞도록 배치

public IEnumerator TutorialState()
        {
            const string tutorialPattern = "FNNBND\n" +
                                           "FEEBED\n" +
                                           "DBBFFN\n" +
                                           "FDEDND\n" +
                                           "FFENFB\n" +
                                           "DBDEBE";
            var rows = tutorialPattern.Split('\n');

            var notUsePoolCharacterList = 
            characterPool.NotUsePoolCharacterList();

            for (var y = 0; y < rows.Length; y++)
            {
                var row = rows[y];
                for (var x = 0; x < row.Length; x++)
                {
                    var groupChar = row[x];
                    var unitGroups = ConvertToUnitGroup(groupChar);
                    var setUnit = notUsePoolCharacterList.FirstOrDefault
                    (t => t.GetComponent<CharacterBase>().unitGroup 
                    == unitGroups && t.activeSelf == false);
                    if (setUnit == null) continue;
                    var setUnitBase = setUnit.GetComponent<CharacterBase>();
                    setUnitBase.Initialize();
                    setUnitBase.unitGroup = unitGroups;
                    setUnitBase.GetComponent<SpriteRenderer>().sprite 
                    = setUnitBase.GetSprite(1);
                    setUnitBase.transform.position = 
                    new Vector3Int(x, 5 - y, 0); 
                    setUnitBase.gameObject.SetActive(true);
                }
            }
            yield return null;
        }
 private static CharacterBase.UnitGroups ConvertToUnitGroup(char groupChar)
	{
		return groupChar switch
		{
			'F' => CharacterBase.UnitGroups.F,
			'B' => CharacterBase.UnitGroups.B,
			'D' => CharacterBase.UnitGroups.D,
			'E' => CharacterBase.UnitGroups.E,
			'N' => CharacterBase.UnitGroups.None
		};
	}