Exemple #1
0
    void OnEnable()
    {
        CManagerRandomTable <SMonster> pRandomTable = CManagerRandomTable <SMonster> .instance;

        Debug.Log("초보자 몬스터 존 시작");
        for (int i = 0; i < 5; i++)
        {
            SMonster sMonster = pRandomTable.GetRandomItem((int)EMonsterRank.C);
            Debug.Log(string.Format("{0}랭크 {1}등장!", sMonster.eGrade, sMonster.strName));
        }

        Debug.Log("좀 쎈 몬스터 존 시작");
        for (int i = 0; i < 5; i++)
        {
            SMonster sMonster = pRandomTable.GetRandomItem((int)EMonsterRank.B);
            Debug.Log(string.Format("{0}랭크 {1}등장!", sMonster.eGrade, sMonster.strName));
        }


        Debug.Log("드래곤 둥지 시작!!");
        for (int i = 0; i < 5; i++)
        {
            SMonster sMonster = pRandomTable.GetRandomItem((int)EMonsterRank.S);
            Debug.Log(string.Format("{0}랭크 {1}등장!", sMonster.eGrade, sMonster.strName));
        }
    }
Exemple #2
0
    public IEnumerator Test_RandomItem_Peek()
    {
        HashSet <SItemData>             setGetItem       = new HashSet <SItemData>();
        CManagerRandomTable <SItemData> pRandomItemTable = CManagerRandomTable <SItemData> .instance;

        CManagerRandomTable <SItemData> .instance.DoClearRandomItemTable();

        pRandomItemTable.DoSetRandomMode(CManagerRandomTable <SItemData> .ERandomGetMode.Peek);

        pRandomItemTable.DoAddRandomItem(new SItemData(EItemGrade.Common, "평범한 장갑", 40));  // Total
        pRandomItemTable.DoAddRandomItem(new SItemData(EItemGrade.Common, "평범한 신발", 40));  // 80
        pRandomItemTable.DoAddRandomItem(new SItemData(EItemGrade.Rare, "드문 장갑", 19));     // 95
        pRandomItemTable.DoAddRandomItem(new SItemData(EItemGrade.Named, "네임드 신발", 1));    // 100

        for (int i = 0; i < 100; i++)
        {
            setGetItem.Add(pRandomItemTable.GetRandomItem());
        }

        UnityEngine.Assertions.Assert.IsTrue(setGetItem.Count > 1); // 종류가 1가지 이상 뽑혔는지

        var pIterNamed = setGetItem.Where(x => x.eGrade == EItemGrade.Named);

        if (pIterNamed != null)                                             // 한개도 없으면 null이다.
        {
            UnityEngine.Assertions.Assert.IsTrue(pIterNamed.Count() <= 10); // 네임드 퍼센트가 1%인데 100번중 10개 이하로 뽑혔는지
        }
        yield break;
    }
    public void DoPlaySpawnSomthing(int iDifficultyValue)
    {
        if (p_bLock_Spawn)
        {
            return;
        }

        _eState = EState.Spawning;
        int iLoopCount_Empty          = 0;
        int iLoopCount_ZeroDifficulty = 0;

        _iDifficultyRemain = iDifficultyValue;
        while (_iDifficultyRemain > 0)
        {
            Data_Spawn pDataSpawn = _pManagerRandomTable.GetRandomItem(_iDifficultyRemain);
            if (pDataSpawn == null)
            {
                if (iLoopCount_Empty++ > 10)
                {
                    break;
                }
                else
                {
                    continue;
                }
            }

            Enum_SpawnName eSpawnName = pDataSpawn.IDictionaryItem_GetKey();
            if (_mapSpawner.ContainsKey(eSpawnName) == false)
            {
                Debug.Log("Manager Spawner " + eSpawnName + " Spawn 정보가 없습니다");
                if (iLoopCount_Empty++ > 10)
                {
                    break;
                }
                else
                {
                    continue;
                }
            }

            int iSpawnDifficulty = 0;
            for (int i = 0; i < _mapSpawner[eSpawnName].Count; i++)
            {
                Class_Spawner pSpawner = _mapSpawner[eSpawnName][i];
                iSpawnDifficulty += pSpawner.ILevelSpawner_GetDifficulty();
                pSpawner.ILevelSpawner_PlaySpawn();
            }

            _iDifficultyRemain -= iSpawnDifficulty;
            if (iSpawnDifficulty == 0 && iLoopCount_ZeroDifficulty++ > 10)
            {
                Debug.LogWarning("Manager Spawner " + eSpawnName + " Spawn Difficulty가 0인데 계속 생성합니다.");
                break;
            }
            //Debug.Log( eEnemy + "Play iGeneateCount : " + iGeneateCount + " Pattern Reain : " + _iDifficultyRemain );
        }
        _eState = EState.SpawnFinish;
    }
Exemple #4
0
 void OnEnable()
 {
     for (int i = 0; i < 100; i++)
     {
         SItemData sItem = _pRandomItemTable.GetRandomItem();
         Debug.Log(string.Format("당첨!! 확률{0}%로 {1}당첨!", sItem.iPercent, sItem.strName));
     }
 }
Exemple #5
0
    public IEnumerator Test_RandomItem_Delete()
    {
        HashSet <SItemData>             setGetItem       = new HashSet <SItemData>();
        CManagerRandomTable <SItemData> pRandomItemTable = CManagerRandomTable <SItemData> .instance;

        CManagerRandomTable <SItemData> .instance.DoClearRandomItemTable();

        pRandomItemTable.DoSetRandomMode(CManagerRandomTable <SItemData> .ERandomGetMode.Delete);

        pRandomItemTable.DoAddRandomItem(new SItemData(EItemGrade.Common, "평범한 장갑", 40));  // Total
        pRandomItemTable.DoAddRandomItem(new SItemData(EItemGrade.Common, "평범한 신발", 40));  // 80
        pRandomItemTable.DoAddRandomItem(new SItemData(EItemGrade.Rare, "드문 장갑", 19));     // 95
        pRandomItemTable.DoAddRandomItem(new SItemData(EItemGrade.Named, "네임드 신발", 1));    // 100

        for (int i = 0; i < 4; i++)
        {
            setGetItem.Add(pRandomItemTable.GetRandomItem());
        }

        UnityEngine.Assertions.Assert.IsTrue(setGetItem.Count >= 4); // 딜리트 모드는 모든 아이템이 뽑혀야 한다.

        Assert.IsNull(pRandomItemTable.GetRandomItem());             // 다 뽑으면 Null이 나온다.

        // 다시 한번 반복
        setGetItem.Clear();
        pRandomItemTable.DoReset_OnDeleteMode();

        for (int i = 0; i < 4; i++)
        {
            setGetItem.Add(pRandomItemTable.GetRandomItem());
        }

        UnityEngine.Assertions.Assert.IsTrue(setGetItem.Count >= 4); // 딜리트 모드는 모든 아이템이 뽑혀야 한다.
        Assert.IsNull(pRandomItemTable.GetRandomItem());             // 다 뽑으면 Null이 나온다.

        yield break;
    }
Exemple #6
0
    void OnEnable()
    {
        Debug.LogWarning("아이템은 17개 넣었는데, 뽑기 요청은 20개를 하여 for문 한번 돌때마다 3번씩 아이템이 없다 뜰것입니다");

        for (int i = 0; i < 20; i++)
        {
            SItemData sItem = _pRandomItemTable.GetRandomItem();

            if (sItem == null)
            {
                Debug.Log("아이템이 없다..");
            }
            else
            {
                Debug.Log(string.Format("당첨!! 확률{0}%로 {1}획득!", sItem.iPercent, sItem.strName));
            }
        }


        _pRandomItemTable.DoReset_OnDeleteMode();
        Debug.LogWarning("리셋!!");

        for (int i = 0; i < 20; i++)
        {
            SItemData sItem = _pRandomItemTable.GetRandomItem();

            if (sItem == null)
            {
                Debug.Log("아이템이 없다..");
            }
            else
            {
                Debug.Log(string.Format("당첨!! 확률{0}%로 {1}획득!", sItem.iPercent, sItem.strName));
            }
        }
    }