示例#1
0
    public Character createCharacter(string name, CHARACTER_TYPE type, int clientID, int guid)
    {
        if (mCharacterList.ContainsKey(name))
        {
            Debug.LogError("error : there is a character named : " + name + "! can not create again!");
            return(null);
        }
        if (type == CHARACTER_TYPE.CT_MYSELF)
        {
            if (mMyself != null)
            {
                Debug.LogError("error : Myself has exist ! can not create again ,name " + name);
                return(null);
            }
        }
        CharacterFactory factory      = mCharacterFactoryManager.getFactory(type);
        Character        newCharacter = factory.createCharacter(name);

        // 如果是玩家自己,则记录下来
        if (type == CHARACTER_TYPE.CT_MYSELF)
        {
            mMyself = newCharacter as CharacterMyself;
        }
        // 将创建的角色挂接到角色管理器下
        newCharacter.setParent(mManagerObject);
        newCharacter.init(clientID, guid);
        addCharacterToList(newCharacter);
        return(newCharacter);
    }
示例#2
0
    public Character createCharacter(string name, CHARACTER_TYPE type, int id)
    {
        if (mCharacterList.ContainsKey(name))
        {
            UnityUtility.logError("error : there is a character named : " + name + "! can not create again!");
            return(null);
        }
        if (type == CHARACTER_TYPE.CT_MYSELF)
        {
            if (mMyself != null)
            {
                Debug.LogError("error : Myself has exist ! can not create again ,name " + name);
                return(null);
            }
        }
        CharacterFactory factory      = mCharacterFactoryManager.getFactory(type);
        Character        newCharacter = factory.createCharacter(name);

        // 如果是玩家自己,则记录下来
        if (type == CHARACTER_TYPE.CT_MYSELF)
        {
            mMyself = newCharacter as CharacterMyself;
        }
        if (newCharacter != null)
        {
            // 将角色挂接到管理器下
            newCharacter.getObject().transform.parent = mManagerObject.transform;
            newCharacter.init(id);
            addCharacterToList(newCharacter);
        }
        return(newCharacter);
    }