virtual protected void OnSlot_Press(int iSlotIndex, bool bPress, CNGUIInventorySlot pSlot) { _iSlotCurrentIndex = iSlotIndex; //if ((_eOption & EInventoryOption.MoveSlotItem) == EInventoryOption.MoveSlotItem) //{ // if (bPress) // { // if (_mapInventoryData.ContainsKey( iSlotIndex ) == false) return; // _pCurrentSelectSlot = pSlot; // _pCurrentSelectData = EventGetSlotData( iSlotIndex ); // pSlot.EventItem_ColliderOnOff( false ); // DebugCustom.Log( "Example", "Inventory", "Press On" + _pCurrentSelectData.IInventoryData_GetImageName(), pSlot ); // } // else // { // if (_pCurrentSelectData == null) return; // pSlot.EventItem_ColliderOnOff( true ); // _mapInventoryData[_pCurrentSelectSlot.p_iSlotIndex] = _mapInventoryData[iSlotIndex]; // _mapInventoryData[iSlotIndex] = _pCurrentSelectData; // OnSlot_Fill( pSlot, _pCurrentSelectData ); // OnSlot_Empty( _pCurrentSelectSlot ); // _pCurrentSelectData = null; // _pCurrentSelectSlot = null; // DebugCustom.Log( "Example", "Inventory", "Press Off" + pSlot.name, pSlot ); // } //} }
virtual protected void OnSlot_Fill(CNGUIInventorySlot pSlot, CLASS_Data pData) { //pSlot.DoSetItem( pData.IInventoryData_GetImageName( pSlot ) ); pSlot.DoLockItem(false); //if (_eOption != EInventoryOption.MoveSlotItem) // pSlot.EventSlot_ColliderOnOff( true ); }
virtual protected void OnSlot_Empty(CNGUIInventorySlot pSlot) { pSlot.DoClearSlot(_strOnEmptySprite); if (_eOption != EInventoryOption.MoveSlotItem) { pSlot.EventSlot_ColliderOnOff(false); } }
virtual protected void OnSlot_Fill_And_Lock(CNGUIInventorySlot pSlot, CLASS_Data pData) { pSlot.DoSetItem(pData.IInventoryData_GetImageName()); pSlot.DoLockItem(true); if (_eOption != EInventoryOption.MoveSlotItem) { pSlot.EventSlot_ColliderOnOff(true); } }
virtual protected void OnSlot_Press(int iSlotIndex, bool bPress, CNGUIInventorySlot pSlot) { _iSlotCurrentIndex = iSlotIndex; if ((_eOption & EInventoryOption.MoveSlotItem) == EInventoryOption.MoveSlotItem) { if (bPress) { if (_mapInventoryData.ContainsKey(iSlotIndex) == false) { return; } _pCurrentSelectSlot = pSlot; _pCurrentSelectData = EventGetSlotData(iSlotIndex); pSlot.EventItem_ColliderOnOff(false); //DebugCustom.Log("Example", "Inventory", "Press On" + _pCurrentSelectData.IInventoryData_GetImageName( pSlot ), pSlot); } else { if (_pCurrentSelectData == null) { return; } pSlot.EventItem_ColliderOnOff(true); _mapInventoryData[_pCurrentSelectSlot.p_iSlotIndex] = _mapInventoryData[iSlotIndex]; _mapInventoryData[iSlotIndex] = _pCurrentSelectData; OnSlot_Fill(pSlot, _pCurrentSelectData); OnSlot_Empty(_pCurrentSelectSlot); _pCurrentSelectData = null; _pCurrentSelectSlot = null; Debug.LogWarning("Press Off" + pSlot.name, pSlot); } } }
// ========================================================================== // /* public - [Do] Function * 외부 객체가 호출(For External class call)*/ /* public - [Event] Function * 프랜드 객체가 호출(For Friend class call)*/ // ========================================================================== // /* protected - [abstract & virtual] */ /* protected - [Event] Function * 자식 객체가 호출(For Child class call) */ /* protected - Override & Unity API */ private void OnEnable() { _listSlotSibling.Clear(); CNGUIInventorySlot pTarget = target as CNGUIInventorySlot; if (Application.isPlaying) { return; } CNGUIPanelBase pUIPopupOwner = pTarget.GetComponentInParent <CNGUIPanelBase>(); pUIPopupOwner.GetComponentsInChildren(_listSlotSibling); _listSlotSibling.Sort(Comparer_BySiblingIndex); for (int i = 0; i < _listSlotSibling.Count; i++) { if (_listSlotSibling[i] == pTarget) { pTarget.p_iSlotIndex = i; } } }
// ========================================================================== // /* private - [Proc] Function * 로직을 처리(Process Local logic) */ /* private - Other[Find, Calculate] Func * 찾기, 계산등 단순 로직(Simpe logic) */ private int Comparer_BySiblingIndex(CNGUIInventorySlot pObjectX, CNGUIInventorySlot pObjectY) { int iSiblingIndexX = pObjectX.transform.GetSiblingIndex(); int iSiblingIndexY = pObjectY.transform.GetSiblingIndex(); if (pObjectX.transform.parent != pObjectY.transform.parent) { iSiblingIndexX = pObjectX.transform.parent.GetSiblingIndex(); iSiblingIndexY = pObjectY.transform.parent.GetSiblingIndex(); } if (iSiblingIndexX < iSiblingIndexY) { return(-1); } else if (iSiblingIndexX > iSiblingIndexY) { return(1); } else { return(0); } }