Exemplo n.º 1
0
    public void DoSpawn_Character(bool bUpdateForce)
    {
        while (transform.childCount > 1)
        {
            DestroyImmediate(transform.GetChild(0).gameObject);
        }

        for (int i = 0; i < transform.childCount; i++)
        {
            GameObject pChildObject = transform.GetChild(0).gameObject;
            if (bUpdateForce)
            {
                DestroyImmediate(pChildObject);
            }
            else if (pChildObject.name.Contains(p_eCharacterType.ToString_GarbageSafe()) == false)
            {
                DestroyImmediate(pChildObject);
            }
        }

        if (transform.childCount == 0)
        {
            GameObject pObjectPrefab = GameObject.Instantiate(Resources.Load("Character/" + p_eCharacterType.ToString_GarbageSafe())) as GameObject;
            pObjectPrefab.transform.SetParent(transform);
            pObjectPrefab.transform.DoResetTransform();
        }

        for (int i = 0; i < listJewel.Count; i++)
        {
            listJewel[i].EventOnAwake();
        }

        AIInput pAIMovementInput = transform.GetChild(0).GetComponent <AIInput>();

        if (pAIMovementInput != null)
        {
            pAIMovementInput.DoInitJewelList(listJewel);
        }

        if (pWeapon_Equip != null)
        {
            PlayerItemCollector pCollector = transform.GetChild(0).GetComponentInChildren <PlayerItemCollector>();
            pCollector.DoCreateAndEquipWeapon(pWeapon_Equip.name);
        }

        if (pStats != null)
        {
            p_pCharacter       = transform.GetChild(0).GetComponent <CharacterModel>();
            p_pCharacter.pStat = Stats.Instantiate(pStats);
            p_pCharacter.pStat.DoInit(p_pCharacter);
        }
    }