public static void Pool(NewGameCharacter character)
 {
     if (GonnaQuit)
     {
         return;
     }
     if (character != null)
     {
         character.CleanUp();
         ObjPoolController.DestroyImmediate(character.gameObject);
     }
 }
 public static void Pool(GameObject obj)
 {
     if (GonnaQuit)
     {
         return;
     }
     if (obj != null)
     {
         NewGameCharacter character = obj.GetComponent <NewGameCharacter>();
         if (character != null)
         {
             character.CleanUp();
         }
         ObjPoolController.DestroyImmediate(obj);
     }
 }
        void OnLoadJoe(UnityEngine.Object obj, ResourceLoadParam param)
        {
            if (obj == null)
            {
                return;
            }
            GameObject newObj = GameObject.Instantiate(obj) as GameObject;

            if (newObj == null)
            {
                return;
            }
            newObj.name = "Joe(Merged)";
            Joe         = newObj.GetComponent <NewGameCharacter>();
            newObj.SetActive(false);
            newObj.transform.SetParent(transform);
        }
        void OnGUI()
        {
            return;

            if (GUI.Button(new Rect(300, 10, 150, 30), "GetCharacter"))
            {
                CurrentCharacter = GetCharacter(Profession.ShuaiShuai, Color.red);
                CurrentCharacter.Active(false);
            }
            if (GUI.Button(new Rect(300, 50, 150, 30), "PoolCharacter"))
            {
                Pool(CurrentCharacter);
            }
            if (GUI.Button(new Rect(300, 90, 150, 30), "Character Appear"))
            {
                CurrentCharacter.Appear(new Vector3(1.2f, 0.6f, 0.5f), Air2000.Character.CharacterCommand.CC_Appear);
            }
        }
        public static NewGameCharacter GetCharacter(Profession prefession, Color color)
        {
            NewGameCharacter ch = null;

            switch (prefession)
            {
            case Profession.ShuaiShuai:
                ch = Instance.ShuaiShuai;
                break;

            case Profession.Joe:
                ch = Instance.Joe;
                break;

            case Profession.LittleSister:
                ch = Instance.LittleSister;
                break;

            case Profession.Mage:
                ch = Instance.Mage;
                break;

            default:
                break;
            }
            if (ch == null)
            {
                return(null);
            }
            GameObject newChObj = ObjPoolController.Instantiate(ch.gameObject);

            if (newChObj == null)
            {
                return(null);
            }
            ch = newChObj.GetComponent <NewGameCharacter>();
            if (ch == null)
            {
                return(null);
            }
            ch.Init(color);
            return(ch);
        }
예제 #6
0
        /// <summary>
        /// 玩家断线
        /// </summary>
        public void OnPlayerOffLine()
        {
            mSuperposition.Clear();

            if (mCharacters != null && mCharacters.Count > 0)
            {
                for (int i = 0; i < mCharacters.Count; i++)
                {
                    NewGameCharacter ch = mCharacters[i];
                    if (ch == null)
                    {
                        continue;
                    }
                    CharacterPoolController.Pool(ch);
                }
                mCharacters.Clear();
                GameObject.DestroyObject(mCharacterHold.gameObject);
            }


            mSuperposition.Clear();
        }
 void OnEnable()
 {
     Instance = target as NewGameCharacter;
 }