示例#1
0
    public MonsterPatternJSON LoadMonsterAttackPattern(int monsterCode)
    {
        string  query   = $"SELECT * FROM dbo.MonsterPattern WHERE MonsterCode = '{monsterCode}'";
        DataSet dataSet = ConnectDB_GetDataSet("Game_DB", query);

        string             jsonSTR = string.Empty;
        MonsterPatternJSON pattern = null;

        if (dataSet != null)
        {
            try
            {
                jsonSTR = dataSet.Tables[0].Rows[0].ItemArray[1].ToString();
                pattern = JsonUtility.FromJson <MonsterPatternJSON>(jsonSTR);
            }
            catch (Exception e)
            {
                Debug.Log($"Monter DB(DBMS) : {monsterCode} 오류 / {e.Message}");
            }
            return(pattern);
        }
        else
        {
            Debug.Log($"Monter DB(DBMS) 에서 {monsterCode} 몬스터 패턴 을 찾을 수 없습니다");
            return(null);
        }
    }
    private void InitializeAttackSystems()
    {
        MonsterPatternJSON patternJSON = MonsterDB.Instance.GetMonsterPattern(MonsterCode);

        MonsterAttackPattern[] patterns = patternJSON.AttackPatterns;
        attackSystems = new MonsterAttackSystem[patterns.Length];

        GameObject AttackSystemObj = new GameObject("AttackSystems");

        AttackSystemObj.transform.parent        = transform;
        AttackSystemObj.transform.localPosition = Vector3.zero;
        for (int i = 0; i < patterns.Length; ++i)
        {
            GameObject newSystem = new GameObject($"System_{i}");
            newSystem.transform.parent        = AttackSystemObj.transform;
            newSystem.transform.localPosition = Vector3.zero;
            newSystem.AddComponent <MonsterAttackSystem>();
            MonsterAttackSystem newSystemComponent = newSystem.GetComponent <MonsterAttackSystem>();
            newSystemComponent.Initialize(patterns[i]);
            attackSystems[i] = newSystemComponent;
        }
    }
示例#3
0
    public MonsterPatternJSON GetMonsterPattern(int monsterCode)
    {
        MonsterPatternJSON foundJSON = null;

        if (monsterPatterns.TryGetValue(monsterCode, out foundJSON))
        {
            return(foundJSON);
        }
        else
        {
            foundJSON = DBConnector.Instance.LoadMonsterAttackPattern(monsterCode);
            if (foundJSON == null)
            {
                Debug.Log($"Monster DB : {monsterCode} 로드 실패");
                return(null);
            }
            else
            {
                monsterPatterns.Add(monsterCode, foundJSON);
                return(foundJSON);
            }
        }
    }