Beispiel #1
0
 protected override void ReleaseCharacter(bool isDestroyCharacter = false)
 {
     for (int i = 0; i < mOtherCharacterPool.Count; ++i)
     {
         UIBuddy3DModelCreater creator = mOtherCharacterPool[i];
         if (creator != null)
         {
             creator.ShowCharacter(false);
             if (isDestroyCharacter)
             {
                 creator.DestroyCharacter();
             }
         }
     }
     mCurrentOther = null;
     base.ReleaseCharacter(isDestroyCharacter);
 }
Beispiel #2
0
        protected virtual void ReleaseCharacter(bool isDestroyCharacter = false)
        {
            for (int i = 0; i < mCharacterPool.Count; ++i)
            {
                UIBuddy3DModelCreater creator = mCharacterPool[i];
                if (creator != null)
                {
                    creator.ShowCharacter(false);
                    if (isDestroyCharacter)
                    {
                        creator.DestroyCharacter();
                    }
                }
            }

            mCurrent = null;
            mScaled  = true;
        }
Beispiel #3
0
        /// <summary>
        /// 初始化角色
        /// </summary>
        protected virtual void InitCharacter()
        {
            if (string.IsNullOrEmpty(mVariantName))
            {
                return;
            }

            string targetVariantName = string.Format("{0}-I", mVariantName);

            for (int i = 0; i < mCharacterPool.Count; ++i)
            {
                UIBuddy3DModelCreater creator = mCharacterPool[i];
                if (creator != null && !string.IsNullOrEmpty(creator.CharacterVariantTemplate) && creator.CharacterVariantTemplate.Equals(targetVariantName))
                {
                    creator.ShowCharacter(true);
                    mCurrent = creator;
                    mScaled  = false;
                    break;
                }
            }
        }
Beispiel #4
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;
        }
Beispiel #5
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;
        }