Beispiel #1
0
    protected override void Start()
    {
        m_unitTag      = "Player";
        gameObject.tag = m_unitTag;

        CDataManager dataMgr = CDataManager.Inst;

        if (dataMgr == null)
        {
            return;
        }

        Data.PlayerInfo playerInfo = dataMgr.PlayerRecord.PlayerInfo;

        GameObject genderPrefab = null;

        if (playerInfo.gender == Gender.Female)
        {
            genderPrefab = Resources.Load <GameObject>("Prefabs/Character/Player/Female");
            Gender       = Gender.Female;
        }
        else
        {
            genderPrefab = Resources.Load <GameObject>("Prefabs/Character/Player/Male");
            Gender       = Gender.Male;
        }

        if (genderPrefab == null)
        {
            return;
        }

        GameObject genderGO = Instantiate(genderPrefab, transform);

        genderGO.name = genderPrefab.name;

        base.Start();

        m_inputCtrl = GetComponent <CInputCtrl>();
        CameraCtrl.SetCamera(m_inputCtrl, this);

        m_inventory = GetComponent <CInventory>();
        m_inventory.Initialized(this);

        if (m_unitUIPrefab)
        {
            GameObject uiObj = Instantiate <GameObject>(m_unitUIPrefab, CStageUIManager.Inst.transform);
            uiObj.name = m_unitUIPrefab.name;

            m_unitUI = uiObj.GetComponent <CUnitUI>();
            if (m_unitUI != null)
            {
                m_unitUI.Init(this);
            }
        }
    }