Example #1
0
    IEnumerator CreatAI(int lastCount, GameObject parant)
    {
        for (int i = 0; i < lastCount; i++)
        {
            GameObject aiOBJ = Instantiate(Resources.Load("Prefabs/Character/CharacterAI")) as GameObject;

            aiOBJ.transform.parent = parant.transform;
            int xValue = Random.Range(-160, 160);
            aiOBJ.transform.localPosition = new Vector3(xValue, -45, 0);

            yield return(new WaitForSeconds(0.1f));

            CharacterAI aiClass = aiOBJ.GetComponent <CharacterAI>();


            int characterState = -1;

            while (true)
            {
                int tempState = Random.Range(0, 4);
                if (characterState != tempState)
                {
                    characterState = tempState;
                    break;
                }
            }

            aiClass.Init(characterState);
        }
    }
Example #2
0
 private void Start()
 {
     _charAI.Init();
     _charAttack.Init();
 }