示例#1
0
        protected void CreateCharacter(string variantName, UIBuddy3DModelCreater old, IDictionary variantPartitions)
        {
            if (string.IsNullOrEmpty(variantName))
            {
                old.mDMono.gameObject.CustomSetActive(false);
                return;
            }

            // create pool
            if (mOtherCharacterPool.Count != mCharacterPoolSize)
            {
                otherCharaacterCreator.ShowCharacter(false);

                GameObject characterCreatorGO = otherCharaacterCreator.mDMono.gameObject;
                Transform  parentTransform    = otherCharaacterCreator.mDMono.transform.parent;
                for (int i = mOtherCharacterPool.Count; i < mCharacterPoolSize; ++i)
                {
                    GameObject            creatorObj = Object.Instantiate(characterCreatorGO, parentTransform) as GameObject;
                    UIBuddy3DModelCreater creator    = creatorObj.GetMonoILRComponent <UIBuddy3DModelCreater>();
                    mOtherCharacterPool.Add(creator);
                }

                for (int i = mOtherCharacterPool.Count - 1; i >= mCharacterPoolSize; --i)
                {
                    UIBuddy3DModelCreater creator = mOtherCharacterPool[i];
                    mOtherCharacterPool.RemoveAt(i);
                    creator.DestroyCharacter();
                    Object.Destroy(creator.mDMono.gameObject);
                }
            }
            //if (mCharacterPool.Contains(Current)) mCurrent = null;

            if (mCurrentOther != null)
            {
                mCurrentOther.ShowCharacter(false);
            }

            string targetVariantName     = string.Format("{0}-I", variantName);
            UIBuddy3DModelCreater target = null;
            int targetIndex = -1;

            for (int i = 0, cnt = mOtherCharacterPool.Count; i < cnt; ++i)
            {
                UIBuddy3DModelCreater creator = mOtherCharacterPool[i];

                if (targetVariantName == creator.CharacterVariantTemplate)
                {
                    if (target != null)
                    {
                        target.ShowCharacter(false);
                    }

                    target      = creator;
                    targetIndex = i;
                    break;
                }

                if (target == null)
                {
                    target      = creator;
                    targetIndex = i;
                    continue;
                }

                if (creator.idle && !target.idle)
                {
                    target.ShowCharacter(false);

                    target      = creator;
                    targetIndex = i;
                }
            }
            if (target != null)
            {// use pool
                mOtherCharacterPool.RemoveAt(targetIndex);
                mOtherCharacterPool.Add(target);
            }
            else
            {// don't use pool
                target = otherCharaacterCreator;
            }
            target.ShowCharacter(true);


            // create
            target.CharacterVariantTemplate = targetVariantName;
            target.CreatCharacter(variantPartitions);

            mCurrentOther = target;
            mScaled       = false;
        }
示例#2
0
        protected void CreateCharacter()
        {
            if (string.IsNullOrEmpty(mVariantName))
            {
                return;
            }

            // create pool
            if (mCharacterPool.Count != mCharacterPoolSize)
            {
                characterCreator.ShowCharacter(false);

                GameObject characterCreatorGO = characterCreator.mDMono.gameObject;
                Transform  parentTransform    = characterCreator.mDMono.transform.parent;
                for (int i = mCharacterPool.Count; i < mCharacterPoolSize; ++i)
                {
                    GameObject            creatorObj = UnityEngine.Object.Instantiate(characterCreatorGO, parentTransform) as GameObject;
                    UIBuddy3DModelCreater creator    = creatorObj.GetMonoILRComponent <UIBuddy3DModelCreater>();
                    mCharacterPool.Add(creator);
                }

                for (int i = mCharacterPool.Count - 1; i >= mCharacterPoolSize; --i)
                {
                    UIBuddy3DModelCreater creator = mCharacterPool[i];
                    mCharacterPool.RemoveAt(i);
                    creator.DestroyCharacter();
                    UnityEngine.Object.Destroy(creator.mDMono.gameObject);
                }
            }

            // find creator
            if (mCurrent != null)
            {
                mCurrent.ShowCharacter(false);
            }

            string targetVariantName     = string.Format("{0}-I", mVariantName);
            UIBuddy3DModelCreater target = null;
            int targetIndex = -1;

            for (int i = 0, cnt = mCharacterPool.Count; i < cnt; ++i)
            {
                UIBuddy3DModelCreater creator = mCharacterPool[i];

                if (targetVariantName == creator.CharacterVariantTemplate)
                {
                    if (target != null)
                    {
                        target.ShowCharacter(false);
                    }

                    target      = creator;
                    targetIndex = i;
                    break;
                }

                if (target == null)
                {
                    target      = creator;
                    targetIndex = i;
                    continue;
                }

                if (creator.idle && !target.idle)
                {
                    target.ShowCharacter(false);

                    target      = creator;
                    targetIndex = i;
                }
            }
            if (target != null)
            {// use pool
                mCharacterPool.RemoveAt(targetIndex);
                mCharacterPool.Add(target);
            }
            else
            {// don't use pool
                target = characterCreator;
            }
            target.ShowCharacter(true);

            // create
            target.CharacterVariantTemplate = targetVariantName;
            target.CreatCharacter(mVariantPartitions);

            mCurrent = target;
            mScaled  = false;
        }