Example #1
0
        private void OnPetStageChange()
        {
            Transform transform = SelfRole._inst.m_curModel.FindChild("birdstop");

            for (int i = 0; i < transform.childCount; i++)
            {
                UnityEngine.Object.Destroy(transform.GetChild(i));
            }
            A3_PetModel instance = ModelBase <A3_PetModel> .getInstance();

            SXML       node       = instance.PetXML.GetNode("pet.stage", "stage==" + instance.Stage.ToString());
            string     @string    = node.getString("avatar");
            GameObject gameObject = Resources.Load <GameObject>("profession/" + @string);
            GameObject x          = Resources.Load <GameObject>("profession/birdpath");
            bool       flag       = this._birdPrefab == null || x == null;

            if (!flag)
            {
                GameObject gameObject2 = UnityEngine.Object.Instantiate(this._birdPrefab, transform.position, Quaternion.identity) as GameObject;
                GameObject gameObject3 = UnityEngine.Object.Instantiate(this._pathPrefab, transform.position, Quaternion.identity) as GameObject;
                bool       flag2       = gameObject2 == null || gameObject3 == null;
                if (!flag2)
                {
                    gameObject3.transform.parent = transform;
                    PetBird petBird = gameObject2.AddComponent <PetBird>();
                    petBird.Path = gameObject3;
                }
            }
        }
        private void OnPetStageChange()
        {
            Transform stop = SelfRole._inst.m_curModel.FindChild("birdstop");

            for (int i = 0; i < stop.childCount; i++)
            {
                GameObject.Destroy(stop.GetChild(i));
            }

            A3_PetModel petModel = A3_PetModel.getInstance();

            SXML   stageXML = petModel.PetXML.GetNode("pet.stage", "stage==" + petModel.Stage.ToString());
            string avatar   = stageXML.getString("avatar");

            GameObject birdPrefab = GAMEAPI.ABModel_LoadNow_GameObject("profession_" + avatar);
            GameObject pathPrefab = GAMEAPI.ABModel_LoadNow_GameObject("profession_birdpath");

            if (_birdPrefab == null || pathPrefab == null)
            {
                return;
            }

            GameObject bird = GameObject.Instantiate(_birdPrefab, stop.position, Quaternion.identity) as GameObject;
            GameObject path = GameObject.Instantiate(_pathPrefab, stop.position, Quaternion.identity) as GameObject;

            if (bird == null || path == null)
            {
                return;
            }

            path.transform.parent = stop;

            PetBird bd = null;

            bd      = bird.AddComponent <PetBird>();
            bd.Path = path;
        }