Esempio n. 1
0
    protected override void Start()
    {
        base.Start();

        m_unitTag      = "Boss";
        gameObject.tag = m_unitTag;

        m_subHook.Init(this);

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

            m_unitUI = uiObj.GetComponent <CUnitUI>();
            if (m_unitUI != null)
            {
                m_unitUI.Init(this);
                m_unitUI.gameObject.SetActive(false);
            }
        }
    }
Esempio n. 2
0
    public CWeapon EquipWeapon(CWeapon weapon, SlotIdx slotIdx = SlotIdx.Right, bool isSub = false)
    {
        CWeapon outWeapon = null;

        #region CheckNull

        if (weapon == null)
        {
            Debug.LogError("Don't Equip null Weapon");
            return(outWeapon);
        }

        GameObject weaponObj = Instantiate(weapon.Prefab);

        if (weaponObj == null)
        {
            Debug.LogError(weapon + ".prefab is null");
            return(outWeapon);
        }

        weaponObj.name = weapon.Prefab.name;

        CWeaponHook weaponHook = weaponObj.GetComponent <CWeaponHook>();

        if (weaponHook == null)
        {
            Debug.LogError(weapon + "is not Contained WeaponHook");
            return(outWeapon);
        }

        #endregion

        if (!isSub)
        {
            if (m_MainHook != null)
            {
                outWeapon = m_MainHook.Weapon;
                Destroy(m_MainHook.gameObject);
                m_mainEquip = null;
                m_MainHook  = null;
            }

            m_MainHook = weaponHook;
            m_MainHook.Init(m_unit, weapon);
            m_mainEquip = weapon;
            m_inventoryInfo.curWeaponIdx = m_mainEquip.ItemIdx;
        }
        else
        {
            if (m_subHook != null)
            {
                outWeapon = m_subHook.Weapon;
                Destroy(m_subHook.gameObject);
                m_subHook  = null;
                m_subEquip = null;
            }

            m_subHook = weaponHook;
            m_subHook.Init(m_unit, weapon);
            m_subEquip = weapon;
            m_inventoryInfo.subWeaponIdx = m_subEquip.ItemIdx;
        }

        WeaponSlotSetting(weaponHook, slotIdx);

        if (m_actionCtrl.Anim != null)
        {
            m_actionCtrl.Anim.SetInteger("WeaponIdx", (int)m_mainEquip.WeaponType);
        }

        //TODO: 방패 혹은 오브젝트를 두개를 껴야하는 경우의 관련 처리
        return(outWeapon);
    }