public void EquipItem(ItemInstance instance, eSlotType slotNum, bool isSave = true) { ItemInfo info = instance.ITEM_INFO; if (DicEquipItem.ContainsKey(slotNum)) { // 현재 장착중인 슬롯 // 착용 해제 //DicEquipItem[slotNum].SLOT_TYPE = eSlotType.SLOT_NONE; DicEquipItem.Remove(slotNum); // 새롭게 착용 instance.SLOT_TYPE = slotNum; DicEquipItem[slotNum] = instance; } else { instance.SLOT_TYPE = slotNum; DicEquipItem.Add(slotNum, instance); } if (EquipE != null) { EquipE(); } if (isSave) { SetLocalData(); } GameManager.Instance.PlayerActor.equipItemStatus(); }
public void GetLocalData() { // ITEM_ID _ SlotType _ ITEM_NO | ITEM_ID _ SlotType _ ITEM_NO | string instanceStr = PlayerPrefs.GetString( ConstValue.LocalSave_ItemInstance, string.Empty); Debug.Log(instanceStr); string[] array = instanceStr.Split('|'); for (int i = 0; i < array.Length; i++) { // ITEM_ID _ SlotType _ ITEM_NO if (array[i].Length <= 0) { continue; } string[] detail = array[i].Split('_'); if (detail.Length < 2) { continue; } int itemId = int.Parse(detail[0]); Debug.Log(itemId); eSlotType slotType = (eSlotType)int.Parse(detail[1]); //1번 슬롯인가, 2번 슬롯인가 ItemInfo info = null; DicItemInfo.TryGetValue(int.Parse(detail[2]), out info); if (info == null) { Debug.Log("ID : " + itemId + " ItemNo : " + detail[1] + " is not Valid"); continue; } // ItemInstance ItemInstance instance = new ItemInstance(itemId, slotType, info); //listItem.Add(instance); // Equip if (slotType == eSlotType.SLOT_1) { //DicEquipItem.Add(eSlotType.SLOT_1, instance); EquipItem(instance, eSlotType.SLOT_1, true); } else if (slotType == eSlotType.SLOT_2) { //EquipItem(instance, eSlotType.SLOT_1, false); //DicEquipItem.Add(eSlotType.SLOT_2, instance); EquipItem(instance, eSlotType.SLOT_2, true); } } }
public ItemInstance(int id, eSlotType type, ItemInfo _info) { ItemID = id; EquipSlotType = type; ItemNO = int.Parse(_info.KEY); Info = _info; }
// Constructor - initialize the player stats. public Player(string i_Name, eSlotType i_ColorType, bool i_Human) { m_Name = i_Name; m_MyColor = i_ColorType; m_Human = i_Human; }
// Constructor which initialize the specified slot to be empty and with a position in the table. public OthelloSlot(int i_Row, int i_Column) { m_Row = i_Row; m_Column = i_Column; m_Type = eSlotType.Empty; }
// this private method helps us check if the current direction is making the slot a possible move. private bool movePerDirection( OthelloSlot i_Slot, eSlotType i_PlayerType, int i_RowMovement, int i_ColumnMovement, bool i_LastColorWasDifferent) { bool toReturn = true; int rowToCheck = i_Slot.Row + i_RowMovement; int columnToCheck = i_Slot.Column + i_ColumnMovement; if ((rowToCheck >= 0) && (rowToCheck < m_GameBoard.Size) && (columnToCheck >= 0) && (columnToCheck < m_GameBoard.Size)) { OthelloSlot slotToCheck = m_GameBoard[rowToCheck, columnToCheck]; if (slotToCheck.SlotType == eSlotType.Empty) { toReturn = false; } else if (slotToCheck.SlotType == i_PlayerType) { toReturn = i_LastColorWasDifferent; } else { toReturn = movePerDirection( m_GameBoard[rowToCheck, columnToCheck], i_PlayerType, i_RowMovement, i_ColumnMovement, true); } } else { toReturn = false; } return toReturn; }
// this method changes in times of need the color of the coins. private bool changeSlotsPerDirection( OthelloSlot i_FromThisSlot, eSlotType i_OriginalType, int i_RowMovement, int i_ColumnMovement, bool i_NeedToChangeSlotsType, ref List<OthelloSlot> i_SlotsToFlip) { bool toReturn = false; int rowToCheck = i_FromThisSlot.Row + i_RowMovement; int columnToCheck = i_FromThisSlot.Column + i_ColumnMovement; if ((rowToCheck >= 0) && (rowToCheck < m_GameBoard.Size) && (columnToCheck >= 0) && (columnToCheck < m_GameBoard.Size)) { OthelloSlot slotToCheck = m_GameBoard[rowToCheck, columnToCheck]; if (slotToCheck.SlotType == eSlotType.Empty) { toReturn = false; } else if (slotToCheck.SlotType == i_OriginalType) { if (i_NeedToChangeSlotsType) { toReturn = true; } } else { toReturn = changeSlotsPerDirection( m_GameBoard[rowToCheck, columnToCheck], i_OriginalType, i_RowMovement, i_ColumnMovement, true, ref i_SlotsToFlip); if (toReturn) { i_SlotsToFlip.Add(m_GameBoard[rowToCheck, columnToCheck]); } } } else { toReturn = false; } return toReturn; }