Exemplo n.º 1
0
    public List <MonsterTypeInfo> ParseMonsterJson()
    {
        monsterTypeInfoList = new List <MonsterTypeInfo>();
        TextAsset  monsterText = Resources.Load <TextAsset>("MonsterTypeInfos");
        string     monsterJson = monsterText.ToString();
        JSONObject j           = new JSONObject(monsterJson);

        foreach (JSONObject temp in j.list)
        {
            MonsterTypeInfo monsterTypeInfo = new MonsterTypeInfo();
            monsterTypeInfo.monsterType  = (MonsterType)Enum.Parse(typeof(MonsterType), temp["monsterTypeString"].str);
            monsterTypeInfo.prefabPath   = temp["prefabPath"].str;
            monsterTypeInfo.maxHP        = (int)temp["maxHP"].n;
            monsterTypeInfo.attack       = (int)temp["attack"].n;
            monsterTypeInfo.attackDis    = (int)temp["attackDis"].n;
            monsterTypeInfo.skillDis     = (int)temp["skillDis"].n;
            monsterTypeInfo.attackEffect = temp["attackEffect"].str;
            monsterTypeInfo.skillEffect  = temp["skillEffect"].str;
            monsterTypeInfo.rangeMin     = (int)temp["rangeMin"].n;
            monsterTypeInfo.rangeMax     = (int)temp["rangeMax"].n;
            monsterTypeInfo.exp          = (int)temp["exp"].n;
            monsterTypeInfoList.Add(monsterTypeInfo);
        }
        return(monsterTypeInfoList);
    }
Exemplo n.º 2
0
 public void SetAttri(MonsterTypeInfo monsterTypeInfo, int degree)
 {
     monsterType  = monsterTypeInfo.monsterType;
     maxHP        = monsterTypeInfo.maxHP * degree;
     currentHP    = maxHP;
     attack       = monsterTypeInfo.attack * degree;
     attackDis    = monsterTypeInfo.attackDis;
     skillDis     = monsterTypeInfo.skillDis;
     attackEffect = monsterTypeInfo.attackEffect;
     skillEffect  = monsterTypeInfo.skillEffect;
     rangeMin     = monsterTypeInfo.rangeMin;
     rangeMax     = monsterTypeInfo.rangeMax;
 }
Exemplo n.º 3
0
    public void SpawnMonster()
    {
        monsterList = new List <GameObject>();
        int a           = (gameLevel + 5) / 5;
        int degree      = a * model.GetDifficultyDegree();
        int monsterType = (gameLevel - 1) % 5;

        monsterTypeInfo = model.GetMonsterTypeInfo((MonsterType)monsterType);
        while (true)
        {
            GameObject go = poolManager.GetInst(((MonsterType)monsterType).ToString());
            if (go == null)
            {
                break;
            }
            monsterList.Add(go);
        }
        for (int i = 0; i < monsterList.Count; i++)
        {
            Vector3 pos = new Vector3();
            while (true)
            {
                pos = new Vector3(Random.Range(-12, 12), 0, Random.Range(-8, 8));
                if (Vector3.Distance(pos, role.transform.position) > 5)
                {
                    break;
                }
            }
            monsterList[i].transform.position = pos;
            monsterList[i].GetComponent <NPCControl>().enabled = true;
            monsterList[i].GetComponent <NPCControl>().InitFSM();
            monsterList[i].GetComponent <NPCControl>().ClearTarget();
            monsterList[i].GetComponent <MonsterData>().SetAttri(monsterTypeInfo, degree);
            monsterList[i].GetComponent <MonsterData>().Init();
        }
    }