コード例 #1
0
 private void SetMaterials(csItem lowItem, csItem highItem, int count)
 {
     // 조합품의 조합재료 리스트에 해당 재료와 개수를 추가한다.
     highItem.AddMaterial(lowItem, count);
     // 조합재료의 조합품 리스트에 해당 물품과 가지고 있어야 할 개수를 추가한다.
     lowItem.AddCombination(highItem, count);
 }
コード例 #2
0
    // 조합 버튼 이벤트
    public void BtnCombine()
    {
        // 조합 재료를 모두 가지고 있지 않은 경우
        if (!hasItems)
        {
            csMessageBox.Show("재료가 부족합니다.");
            return;
        }
        // 조합 재료가 빈 아이템인 경우 행동없이 리턴
        if (csItemList.Instance.IsEmpty(combItem))
        {
            return;
        }

        // 조합아이템의 재료List를 호출
        List <csItems> materials = combItem.MaterialList;

        // 현재 인벤토리에 조합재료가 모두 있는지 확인
        for (int i = 0; i < materials.Count; i++)
        {
            csItem item = csItemList.Instance.GetItem((int)materials [i].id);
            // 재료가 부족한 경우 바로 리턴
            if (!csInventory.Instance.SetToInventory(item, -materials [i].count))
            {
                csMessageBox.Show("재료가 부족합니다.");
                return;
            }
        }
        // 재료를 모두 가지고 있는 경우 조합아이템을 추가
        csInventory.Instance.SetToInventory(combItem, combCount);
        // 조합아이템의 재료들을 인벤토리에서 제거
        workTable.RemoveAtPossibilityList();
        // 조합창 Update
        workTable.UpdateList();
    }
コード例 #3
0
 void Start()
 {
     if (combItem == null)
     {
         combItem = csItemList.Instance.EmptyItem;
     }
 }
コード例 #4
0
ファイル: csInventory.cs プロジェクト: adf789/Last_Survivor
    // 매개변수로 넘어온 toPos의 위치에 있는 아이템과 fromSlot의 아이템을 swap한다.
    public void ItemSwap(csInventorySlot fromSlot, Vector3 toPos)
    {
        csInventorySlot toSlot;
        int             toIndex;

        if (!NearSlot(toPos, out toSlot, out toIndex))
        {
            fromSlot.Restore();
            return;
        }

        // 바꿀 아이템의 index 값을 구한다.
        int fromIndex = curInventory.IndexOf(fromSlot.Item);

        // 아이템의 위치와 개수를 swap 한다.
        csItem tempItem  = fromSlot.Item;
        int    tempCount = fromSlot.Count;

        fromSlot.SetItem(toSlot.Item, toSlot.Count);
        toSlot.SetItem(tempItem, tempCount);

        // list의 아이템 정보를 swap 한다.
        ReplaceToList(fromIndex, toIndex);

        // curIndex를 재탐색한다.
        SetIndex();
    }
コード例 #5
0
ファイル: csInventory.cs プロジェクト: fafara/Creature_Race
    private bool PlaceEmpty(csItem item, int amount)
    {
        if (emptySlots > 0)
        {
            Debug.Log("빈공간잇음");
            for (int i = 0; i < MySlots.Count; i++)
            {
                csSlotStorage tmp = MySlots[i];

                if (tmp.IsEmpty)
                {
                    Debug.Log("빈공간 인덱스 : " + i);
                    tmp.AddItem(item);

                    for (int j = 0; j < amount - 1 && tmp.IsAvailable; j++)
                    {
                        tmp.AddItem(item);
                    }

                    emptySlots--;
                    Debug.Log("빈공간 : " + emptySlots);

                    SqlQurey(i, tmp.Items.Peek().itemCode, tmp.Items.Count);
                    return(true);
                }
            }
        }
        return(false);
    }
コード例 #6
0
ファイル: csCrateSlot.cs プロジェクト: adf789/Last_Survivor
 // 해당 슬롯에 아이템과 개수 초기화.
 public void  SetItem(csItem item, int count)
 {
     this.item      = item;
     this.itemCount = count;
     gameObject.GetComponent <Image> ().sprite         = item.Picture;
     transform.GetChild(0).GetComponent <Text> ().text = itemCount.ToString();
 }
コード例 #7
0
 // 현재 인벤토리에서 조합 가능한 재료를 탐색한다.
 public void UpdateList()
 {
     if (!isInit)
     {
         Init();
         isInit = true;
     }
     for (int i = 0; i < csInventory.Instance.Count; i++)
     {
         csItem item = csInventory.Instance.GetToInventory(i);
         // 현재 아이템이 빈 아이템이거나 아이템의 타입이 기타 아이템인 경우 continue
         if (csItemList.Instance.IsEmpty(item) || item.Type != (int)csItemList.Type.ETC)
         {
             continue;
         }
         // 해당 아이템이 조합재료가 인벤토리에 하나라도 존재할 시 조합 가능한 List에 추가한다.
         List <csItems> combList = item.CombinationList;
         for (int j = 0; j < combList.Count; j++)
         {
             csItem combItem = csItemList.Instance.GetItem((int)combList [j].id);
             if (!possibleCombList.Contains(combItem))
             {
                 // 조합 가능한 List에 추가
                 possibleCombList.Add(combItem);
                 // 조합창의 List가 한번이라도 변화가 있을 경우 조합창 UI를 업데이트 하기 위한 bool 변수
                 isChangedList = true;
             }
         }
     }
     // 탐색이 끝난 후 UI를 재구성한다.
     UpdateUI();
 }
コード例 #8
0
    // 죽는 상태로 돌입할 때
    public override void EnterState(csMonster _Monster)
    {
        csRespawn.Instance.CurMonsterCount = csRespawn.Instance.CurMonsterCount - 1;
        csInventory inv  = csInventory.Instance;
        csItem      item = csItemList.Instance.GetItem(2);

        inv.SetToInventory(item, 1);
    }
コード例 #9
0
    // 해당 아이템의 오브젝트를 BuildList 하위 오브젝트에서 찾아서 생성한다.
    public void SearchBuildingObj(csItem item)
    {
        Transform obj = GameObject.Find("BuildList").transform.Find(item.Name);

        obj = Instantiate <Transform> (obj);

        _instance.BuildingObj = obj;
    }
コード例 #10
0
ファイル: csCrateSlot.cs プロジェクト: adf789/Last_Survivor
 public void Init()
 {
     item      = csItemList.Instance.EmptyItem;
     itemCount = 0;
     inventory = csInventory.Instance;
     gameObject.GetComponent <Image> ().sprite         = item.Picture;
     transform.GetChild(0).GetComponent <Text> ().text = itemCount.ToString();
 }
コード例 #11
0
ファイル: csInventory.cs プロジェクト: fafara/Creature_Race
    public void Assembly(csItem item, int type)
    {
        GameObject parent = null;

        Transform[] SpawnObject;

        if (item.itemType == csItem.ItemType.Head)
        {
            parent = GameObject.Find("Head_Point");
        }
        else if (item.itemType == csItem.ItemType.Tail)
        {
            parent = GameObject.Find("Tail_Point");
        }
        else if (item.itemType == csItem.ItemType.Front_Leg)
        {
            if (item.legCount == 2)
            {
                parent = GameObject.Find("MiddleLeg_Point");
            }
            else
            {
                parent = GameObject.Find("FrontLeg_Point");
            }
        }
        else if (item.itemType == csItem.ItemType.Back_Leg)
        {
            parent = GameObject.Find("BackLeg_Point");
        }

        SpawnObject = parent.GetComponentsInChildren <Transform>();

        for (int i = 1; i < SpawnObject.Length; i++)
        {
            Destroy(SpawnObject[i].gameObject);
        }

        // 새로운 장비가 장착 됐을때만
        if (type == 0)
        {
            string name         = item.itemCode;
            string removeName   = name.Remove(name.Length - 1, 1);
            string insertName   = removeName.Insert(removeName.Length, "1");
            string lastPartName = "PartPrefabs/" + insertName;

            GameObject part = Resources.Load(lastPartName, typeof(GameObject)) as GameObject;

            GameObject goTemp = Instantiate(part) as GameObject;

            Vector3    tmp  = goTemp.transform.position;
            Quaternion temp = goTemp.transform.rotation;


            goTemp.transform.parent        = parent.transform;
            goTemp.transform.localPosition = tmp;
            goTemp.transform.localRotation = temp;
        }
    }
コード例 #12
0
ファイル: csInventory.cs プロジェクト: adf789/Last_Survivor
 // 매개변수의 아이템이 현재 인벤토리에 있는지 판단 후 가지고 있는 개수를 반환한다.
 public int CountToInventory(csItem item)
 {
     if (IsContain(item))
     {
         int index = curInventory.IndexOf(item);
         return(countList[index]);
     }
     return(0);
 }
コード例 #13
0
    // 나무 오브젝트를 비활성화한 후 특정 아이템을 습득
    private void CutTree()
    {
        col.enabled = false;
        anim.SetBool("Lumber", true);
        csInventory inv  = csInventory.Instance;
        csItem      item = csItemList.Instance.GetItem(0);

        inv.SetToInventory(item, 3);
        StartCoroutine("Disable");
    }
コード例 #14
0
ファイル: csItem.cs プロジェクト: adf789/Last_Survivor
    // 조합 가능한 아이템을 List에 추가
    public void AddCombination(csItem item, int count)
    {
        csItems items = new csItems(item, count);

        if (combList == null)
        {
            combList = new List <csItems> ();
        }
        combList.Add(items);
    }
コード例 #15
0
ファイル: csItem.cs プロジェクト: adf789/Last_Survivor
    // 해당 아이템을 조합하기 위한 재료를 List에 추가
    public void AddMaterial(csItem item, int count)
    {
        csItems items = new csItems(item, count);

        if (materialList == null)
        {
            materialList = new List <csItems> ();
        }
        materialList.Add(items);
    }
コード例 #16
0
    // 조합아이템 및 재료가 표시될 Panel Update
    private void UpdateCombPanel(Transform panel, csItem combItem)
    {
        // 조합 재료를 출력하기 위한 StringBuilder
        StringBuilder sb         = new StringBuilder();
        short         checkCount = 0;
//		bool checkPossibility = false;
        List <csItems> materials = combItem.MaterialList;

        // 조합에 필요한 재료들을 StringBuilder에 Append한다.
        for (int i = 0; i < materials.Count; i++)
        {
            csItems needItem  = materials [i];
            int     needCount = needItem.count;
            csItem  item      = csItemList.Instance.GetItem((int)needItem.id);
            int     count     = csInventory.Instance.CountToInventory(item);

            // 현재 가지고 있는 아이템의 개수가 조합에 필요한 개수보다 많다면 카운트한다.
            if (count >= needCount)
            {
                checkCount++;
            }
//			if (count > 0)
//				checkPossibility = true;

            sb.Append(item.Name + " : " + count + "/" + needCount + "\n");
        }

        // 조합창에 출력될 Panel의 조합아이템 이미지와 조합재료 문자열을 설정한다.
        csWorktablePanel workPanel = panel.GetComponent <csWorktablePanel> ();

        panel.GetChild(0).GetComponent <Image> ().sprite = combItem.Picture;
        panel.GetChild(1).GetComponent <Text> ().text    = sb.ToString();

        // 현재 Update될 Panel에 조합아이템과 개수와 해당 클래스의 객체를 인자로 보낸다.
        workPanel.SetWorkPanel(combItem, 1, this);

        // 카운트된 개수가 조합에 필요한 아이템의 종류 수와 같다면 workPanel 객체의 HasItems를 true로 바꾼다.
        // 이 HasItems은 해당 Panel에서 조합 가능한 유무를 판단한다.
        if (checkCount == materials.Count)
        {
            workPanel.HasItems = true;
        }
        else
        {
            workPanel.HasItems = false;
        }

        // 조합 재료가 하나도 없을 때 false를 반환한다.
//		if (checkPossibility) {
//			return true;
//		} else {
//			return false;
//		}
    }
コード例 #17
0
ファイル: csItemList.cs プロジェクト: adf789/Last_Survivor
 public bool IsEmpty(csItem item)
 {
     if (item.Equals(itemDatabase [-1]))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #18
0
    // isDragOk도 재설정해야댐

    public void AddItem(csItem item)
    {
        isDragOk = true;
        items.Push(item);

        if (items.Count > 1)
        {
            itemAmount.text = items.Count.ToString();
        }

        ChangeSprite(item.itemAtlas, item.itemSpriteName);
    }
コード例 #19
0
 // 해당 아이템이 조합가능한지 판단 후 값을 반환한다.
 public bool isPossibility(csItem combItem)
 {
     for (int i = 0; i < combItem.MaterialList.Count; i++)
     {
         csItem item = csItemList.Instance.GetItem((int)combItem.MaterialList[i].id);
         if (csInventory.Instance.HasInventory(item))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #20
0
ファイル: csRaceMake.cs プロジェクト: fafara/Creature_Race
    public void PreloadAssembly(csItem item)
    {
        GameObject parent = null;

        if (item.itemType == csItem.ItemType.Head)
        {
            parent = MyPlayer.transform.FindChild("Head_Point").gameObject;
            Debug.Log("케케");
        }
        else if (item.itemType == csItem.ItemType.Tail)
        {
            parent = MyPlayer.transform.FindChild("Tail_Point").gameObject;
        }
        else if (item.itemType == csItem.ItemType.Front_Leg)
        {
            if (item.legCount == 2)
            {
                parent = MyPlayer.transform.FindChild("MiddleLeg_Point").gameObject;
            }
            else
            {
                parent = MyPlayer.transform.FindChild("FrontLeg_Point").gameObject;
            }
        }
        else if (item.itemType == csItem.ItemType.Back_Leg)
        {
            parent = MyPlayer.transform.FindChild("BackLeg_Point").gameObject;
        }

        string name       = item.itemCode;
        string removeName = name.Remove(name.Length - 1, 1);
        string insertName = removeName.Insert(removeName.Length, "1");

        string lastPartName = "PartPrefabs/" + insertName;


        GameObject part = Resources.Load(lastPartName, typeof(GameObject)) as GameObject;

        GameObject goTemp = Instantiate(part) as GameObject;

        goTemp.name = insertName;
        Vector3    tmp  = goTemp.transform.position;
        Quaternion temp = goTemp.transform.rotation;
        Vector3    sale = goTemp.transform.localScale;

        goTemp.transform.parent        = parent.transform;
        goTemp.transform.localPosition = tmp;
        goTemp.transform.localRotation = temp;
        goTemp.transform.localScale    = sale;
    }
コード例 #21
0
ファイル: csInventory.cs プロジェクト: fafara/Creature_Race
    public void sellClear()
    {
        int count = sell.Items.Count;

        if (count != 0)
        {
            csItem item = sell.Items.Peek();
            AddItem(item, count);
            sell.ClearSlot();

            SellSqlQurey(4, "0", 0);
        }
        sellPrice.text = "0";
    }
コード例 #22
0
ファイル: csRaceMake.cs プロジェクト: Reiie/Creature_Race
    public void PreloadAssembly(csItem item)
    {
        GameObject parent = null;

        if (item.itemType == csItem.ItemType.Head)
        {
            parent = MyPlayer.transform.FindChild("Head_Point").gameObject;
            Debug.Log("케케");
        }
        else if (item.itemType == csItem.ItemType.Tail)
        {

            parent = MyPlayer.transform.FindChild("Tail_Point").gameObject;
        }
        else if (item.itemType == csItem.ItemType.Front_Leg)
        {
            if (item.legCount == 2)
            {

                parent = MyPlayer.transform.FindChild("MiddleLeg_Point").gameObject;
            }
            else {

                parent = MyPlayer.transform.FindChild("FrontLeg_Point").gameObject;
            }
        }
        else if (item.itemType == csItem.ItemType.Back_Leg)
        {
            parent = MyPlayer.transform.FindChild("BackLeg_Point").gameObject;
        }

        string name = item.itemCode;
        string removeName = name.Remove(name.Length - 1, 1);
        string insertName = removeName.Insert(removeName.Length, "1");

        string lastPartName = "PartPrefabs/" + insertName;

        GameObject part = Resources.Load(lastPartName, typeof(GameObject)) as GameObject;

        GameObject goTemp = Instantiate(part) as GameObject;
        goTemp.name = insertName;
        Vector3 tmp = goTemp.transform.position;
        Quaternion temp = goTemp.transform.rotation;
        Vector3 sale = goTemp.transform.localScale;
        goTemp.transform.parent = parent.transform;
        goTemp.transform.localPosition = tmp;
        goTemp.transform.localRotation = temp;
        goTemp.transform.localScale = sale;
    }
コード例 #23
0
ファイル: csInventory.cs プロジェクト: adf789/Last_Survivor
    // 현재 사용하는 csItem과 int를 담고있는 list의 순서를 같게 하기 위해
    // 함수를 이용하여 삽입, 삭제, 검사를 함.

    // SetToList의 반환 형태는 새로 추가를 했거나, 값을 변경에 성공했으면 true를 반환하고, 실패하였으면 false를 반환한다.
    // 또한 이 함수에서 인벤토리의 GUI 상태를 변경한다.
    private bool SetToList(csItem item, int count)
    {
        // 해당 아이템이 있는 경우
        if (IsContain(item))
        {
            // 해당 아이템의 인덱스와 개수를 구한다.
            int index    = curInventory.IndexOf(item);
            int curCount = countList [index];
            // 현재 가지고 있는 개수와 파라미터인 count 값과의 합이 음수이면 아무 행동없이 false를 반환한다.
            if (curCount + count < 0)
            {
                return(false);
            }
            curInventory [index] = csItemList.Instance.EmptyItem;
            countList [index]    = 0;
            if (curCount + count == 0)
            {
                // 인벤토리 UI에서 해당 아이템을 삭제한다.
                DeleteToInventoryUI(item, index);
                SetIndex();
            }
            if (curCount + count > 0)
            {
                curInventory[index] = item;
                countList[index]    = curCount + count;

                // 해당 아이템의 개수를 인벤토리 UI에서 수정한다.
                AddToInventoryUI(index, curCount + count);
            }
            return(true);
        }
        // 해당 아이템이 없는 경우
        else
        {
            if (count <= 0 || curIndex > 11)
            {
                return(false);
            }
            // 아이템 추가 전 추가해야 될 index를 찾음.
            SetIndex();

            curInventory[curIndex] = item;
            countList[curIndex]    = count;

            // 해당 아이템을 인벤토리 UI에 새로 추가
            AddToInventoryUI(item, count);
            return(true);
        }
    }
コード例 #24
0
 // 슬롯의 초기 설정을 한다.
 public void Init()
 {
     // 아이템의 이동을 시각적으로 표현하기 위한 dragPos, dragImg를 초기화한다.
     // 임의로 위치할 dragPos의 위치와 이미지로 나타낼 dragImg가 없는 경우 초기화한다.
     // SelectItemPos은 해당 슬롯의 사용, 버림과 관련된 변수다.
     if (dragPos == null || dragImg == null || SelectItemPos == null)
     {
         dragPos       = csAlreadyGame.DragItemView;
         dragImg       = dragPos.GetComponent <Image> ();
         SelectItemPos = csAlreadyGame.SelectItemView;
     }
     // 초기 아이템은 빈 아이템으로 대체한다.
     item = csItemList.Instance.EmptyItem;
     GetComponent <Image> ().sprite = item.Picture;
     slot = GetComponent <csInventorySlot> ();
 }
コード例 #25
0
 // 조합 아이템 리스트 중에서 현재 조합이 가능한 것만 제외한 후 나머지는 제거한다.
 public void RemoveAtPossibilityList()
 {
     if (!isInit)
     {
         Init();
         isInit = true;
     }
     for (int i = 0; i < possibleCombList.Count;)
     {
         csItem combItem = possibleCombList[i++];
         if (!csCombineInfo.Instance.isPossibility(combItem) && possibleCombList.Contains(combItem))
         {
             this.possibleCombList.Remove(combItem);
             i--;
         }
     }
 }
コード例 #26
0
ファイル: csItemList.cs プロジェクト: adf789/Last_Survivor
    // 아이템별로 사용되었을 시 행동 정의
    public void ItemUse(csItem item)
    {
        switch (item.Name)
        {
        case "Meat":
            csCharacterStatus.Instance.ChangeFatigue(10);
            csCharacterStatus.Instance.ChangeHp(5);
            csSelectedItem.Instance.UseItem();
            break;

        case "Tent":
        case "Campfire":
            csBuilding.Instance.SearchBuildingObj(item);
            csBuilding.Instance.IsBuilding = true;
            break;
        }
    }
コード例 #27
0
ファイル: csInventory.cs プロジェクト: Reiie/K-K
    public bool AddItem(csItem item, int amount)
    {
        if (item.itemMaxAmount == 1)
        {

            PlaceEmpty(item, 1);
            return true;
        }
        else
        {
            for (int i = 0; i < MySlots.Count; i++)
            {
                csSlotStorage tmp = MySlots[i];

                if (!tmp.IsEmpty)
                {

                    if (tmp.CurrentItem.itemID == item.itemID && tmp.IsAvailable)
                    {
                        for (int j = 0; j < amount && tmp.IsAvailable; j++)
                        {
                            tmp.AddItem(item);

                        }
                        SqlQurey(i, tmp.Items.Peek().itemCode, tmp.Items.Count);
                        return true;
                    }
                }
            }

            Debug.Log(emptySlots);
            // 슬롯에 맞는 아이템이 없는경우
            if (emptySlots > 0)
            {
                Debug.Log("슬롯에 맞는게 없다");
                PlaceEmpty(item, amount);
                return true;
            }

        }
        return false;
    }
コード例 #28
0
ファイル: csInventory.cs プロジェクト: adf789/Last_Survivor
 // 아이템과 개수로 현재 인벤토리 상태를 재배열한다.
 public bool SetToInventory(csItem item, int count)
 {
     if (SetToList(item, count))
     {
         if (count > 0)
         {
             csMessageBox.Show(item.Name + " " + count + "개를 얻었습니다.");
         }
         return(true);
     }
     else if (count < 0)
     {
         csMessageBox.Show("해당 아이템이 인벤토리에 충분치 않습니다.");
     }
     else if (curIndex > SIZE)
     {
         csMessageBox.Show("인벤토리 공간이 없습니다.");
     }
     return(false);
 }
コード例 #29
0
ファイル: csInventory.cs プロジェクト: adf789/Last_Survivor
    // List의 아이템 항목 중에서 index1과 index2의 순서를 바꾼다.
    private bool ReplaceToList(int index1, int index2)
    {
        int range = curInventory.Capacity;

        if (range - 1 < index1 && range - 1 < index2)
        {
            return(false);
        }

        csItem tempItem = curInventory [index1];
        int    temp     = countList [index1];

        curInventory [index1] = curInventory [index2];
        countList [index1]    = countList [index2];

        curInventory [index2] = tempItem;
        countList [index2]    = temp;

        return(true);
    }
コード例 #30
0
ファイル: csInventory.cs プロジェクト: fafara/Creature_Race
    public bool AddItem(csItem item, int amount)
    {
        if (item.itemMaxAmount == 1)
        {
            PlaceEmpty(item, 1);
            return(true);
        }
        else
        {
            for (int i = 0; i < MySlots.Count; i++)
            {
                csSlotStorage tmp = MySlots[i];

                if (!tmp.IsEmpty)
                {
                    if (tmp.CurrentItem.itemID == item.itemID && tmp.IsAvailable)
                    {
                        for (int j = 0; j < amount && tmp.IsAvailable; j++)
                        {
                            tmp.AddItem(item);
                        }
                        SqlQurey(i, tmp.Items.Peek().itemCode, tmp.Items.Count);
                        return(true);
                    }
                }
            }

            Debug.Log(emptySlots);
            // 슬롯에 맞는 아이템이 없는경우
            if (emptySlots > 0)
            {
                Debug.Log("슬롯에 맞는게 없다");
                PlaceEmpty(item, amount);
                return(true);
            }
        }
        return(false);
    }
コード例 #31
0
 // 해당 오브젝트에 상호작용의 발생된 경우 호출된다.
 public void Interaction(GameObject gameObject)
 {
     // 현재 캐릭터가 들고있는 도구가 Pickaxe인 경우
     if (csCharacterStatus.Instance.CurrentEquip().Equals("Pickaxe"))
     {
         // 해당 오브젝트의 내구도를 1깎는다.
         curHp -= 1f;
         // 상호작용에 해당하는 소리 재생
         audioSource.Play();
         // 플레이어의 인벤토리로 지정된 아이템이 추가됨
         csInventory inv  = csInventory.Instance;
         csItem      item = csItemList.Instance.GetItem(1);
         inv.SetToInventory(item, 1);
         // 해당 오브젝트의 내구도가 0이하가 됐을 경우
         if (curHp <= 0f)
         {
             BreakRock();
         }
     }
     else
     {
         csMessageBox.Show("알맞은 도구가 아닙니다.");
     }
 }
コード例 #32
0
    // 외부 xml 파일에서 조합목록을 불러와 초기화한다.
    private void InitCombination()
    {
        // combineList.xml을 불러온다.
        XmlNodeList nodeList = csXMLManager.XmlNodeList("combineList");

        // 조합 아이템 개수만큼 for문
        for (int i = 1; i < nodeList.Count; i++)
        {
            XmlNode node = nodeList.Item(i);
            csItem  item = csItemList.Instance.GetItem(node.Attributes.GetNamedItem("combItem").Value);
            // 조합 아이템 List에 추가
            combinationList.Add(item);

            // 해당 조합아이템의 조합 재료만큼 for문
            for (int j = 0; j < (node.Attributes.Count - 1) / 2; j++)
            {
                csItem material = csItemList.Instance.GetItem(node.Attributes.GetNamedItem("item" + j).Value);
                int    count;
                int.TryParse(node.Attributes.GetNamedItem("count" + j).Value, out count);
                // 조합아이템에는 재료리스트로, 각 재료에는 조합가능 리스트로 추가된다.
                SetMaterials(material, item, count);
            }
        }
    }
コード例 #33
0
ファイル: csInventory.cs プロジェクト: Reiie/K-K
    private bool PlaceEmpty(csItem item, int amount)
    {
        if (emptySlots > 0)
        {
            Debug.Log("빈공간잇음");
            for (int i = 0; i < MySlots.Count; i++)
            {
                csSlotStorage tmp = MySlots[i];

                if (tmp.IsEmpty)
                {
                    Debug.Log("빈공간 인덱스 : " + i);
                    tmp.AddItem(item);

                    for (int j = 0; j < amount - 1 && tmp.IsAvailable; j++)
                    {
                        tmp.AddItem(item);

                    }

                    emptySlots--;
                    Debug.Log("빈공간 : " + emptySlots);

                    SqlQurey(i, tmp.Items.Peek().itemCode, tmp.Items.Count);
                    return true;
                }
            }
        }
        return false;
    }
コード例 #34
0
ファイル: csInventory.cs プロジェクト: Reiie/K-K
    public void MaterialCheck(csItem blueprint,int index,int createIndex)
    {
        // 설계도 위치
        blueprintIndex = index;
        makeIndex = createIndex;

        // 어떤 등급의 금속이 필요한지 조사
        if (blueprint.l_metal > 0)
        {
            metalSpriteName = "Material_0011";
            needMetalCount = blueprint.l_metal;
            metalNameLabel.text = "불순물 섞인 금속";
        }
        else if (blueprint.m_metal > 0)
        {
            metalSpriteName = "Material_0012";
            needMetalCount = blueprint.m_metal;
            metalNameLabel.text = "보통 금속";
        }
        else if (blueprint.h_metal > 0)
        {
            metalSpriteName = "Material_0013";
            needMetalCount = blueprint.h_metal;
            metalNameLabel.text = "정제된 금속";
        }

        // 어떤 등급의 회로가 필요한지 조사
        if (blueprint.l_circuit > 0)
        {
            circuitSpriteName = "Material_0021";
            needCircuitCount = blueprint.l_circuit;
            circuitNameLabel.text = "낡은 회로";
        }
        else if (blueprint.m_circuit > 0)
        {
            circuitSpriteName = "Material_0022";
            needCircuitCount = blueprint.m_circuit;
            circuitNameLabel.text = "일반 회로";
        }
        else if (blueprint.h_circuit > 0)
        {
            circuitSpriteName = "Material_0023";
            needCircuitCount = blueprint.h_circuit;
            circuitNameLabel.text = "고급 회로";
        }

        // 어떤 등급의 잡동사니가 필요한지 조사
        if (blueprint.l_junk > 0)
        {
            junkSpriteName = "Material_0031";
            needJunkCount = blueprint.l_junk;
            junkNameLabel.text = "녹슨 잡동사니";
        }
        else if (blueprint.m_junk > 0)
        {
            junkSpriteName = "Material_0032";
            needJunkCount = blueprint.m_junk;
            junkNameLabel.text = "잡동사니";
        }
        else if (blueprint.h_junk > 0)
        {
            junkSpriteName = "Material_0033";
            needJunkCount = blueprint.h_junk;
            junkNameLabel.text = "고급 잡동사니";
        }

        // 각 재료에 맞게 재료창 스프라이트 변경
        metalSprite.spriteName = metalSpriteName;
        circuitSprite.spriteName = circuitSpriteName;
        junkSprite.spriteName = junkSpriteName;

        for (int i = 0; i < 28; i++)
        {
            // 비어있지 않은곳만 조사
            if (MySlots[i].Items.Count != 0)
            {
                // 들어있는게 금속인지 조사
                if (MySlots[i].Items.Peek().itemCode == metalSpriteName)
                {
                    // 재료 위치 기억
                    if (metalIndex == -1)
                    {
                        metalIndex = i;
                    }
                    MyMetalCount = MyMetalCount + MySlots[i].Items.Count;

                }
                // 들어있는게 회로인지 조사
                else if (MySlots[i].Items.Peek().itemCode == circuitSpriteName)
                {
                    if (circuitIndex == -1)
                    {
                        circuitIndex = i;
                    }
                    MyCircuitCount = MyCircuitCount + MySlots[i].Items.Count;
                }
                // 들어있는게 잡동사니인지 조사
                else if (MySlots[i].Items.Peek().itemCode == junkSpriteName)
                {
                    if (junkIndex == -1)
                    {
                        junkIndex = i;
                    }
                    MyJunkCount = MyJunkCount + MySlots[i].Items.Count;
                }
            }
            else
            {
               // Debug.Log("비어있는곳");
            }
        }

        bool isMake = true;

        // 3가지 재료중 하나라도 안되면 제작 불가능
        if (MyMetalCount < needMetalCount)
        {
            isMake = false;
            metalSprite.alpha = 0.5f;
            metalLabel.color = Color.red;
        }
        if (MyCircuitCount < needCircuitCount)
        {
            isMake = false;
            circuitSprite.alpha = 0.5f;
            circuitLabel.color = Color.red;
        }

        if (MyJunkCount < needJunkCount)
        {
            isMake = false;
            junkSprite.alpha = 0.5f;
            junkLabel.color = Color.red;
        }

        if(isMake)
        {
            makePossible = true;
        }
        metalLabel.text = "" + MyMetalCount + "  /  " + needMetalCount;
        circuitLabel.text = "" + MyCircuitCount + "  /  " + needCircuitCount;
        junkLabel.text = "" + MyJunkCount + "  /  " + needJunkCount;
    }
コード例 #35
0
ファイル: csInventory.cs プロジェクト: Reiie/K-K
    public void Assembly(csItem item, int type)
    {
        GameObject parent = null;
        Transform[] SpawnObject;

        if (item.itemType == csItem.ItemType.Head)
        {
            parent = GameObject.Find("Head_Point");
        }
        else if (item.itemType == csItem.ItemType.Tail)
        {
            parent = GameObject.Find("Tail_Point");
        }
        else if (item.itemType == csItem.ItemType.Front_Leg)
        {
            if (item.legCount == 2)
            {
                parent = GameObject.Find("MiddleLeg_Point");
            }
            else {
                parent = GameObject.Find("FrontLeg_Point");
            }

        }
        else if (item.itemType == csItem.ItemType.Back_Leg)
        {
            parent = GameObject.Find("BackLeg_Point");
        }

        SpawnObject = parent.GetComponentsInChildren<Transform>();

        for (int i = 1; i < SpawnObject.Length; i++)
        {
            Destroy(SpawnObject[i].gameObject);
        }

        // 새로운 장비가 장착 됐을때만
        if (type == 0)
        {
            string name = item.itemCode;
            string removeName = name.Remove(name.Length - 1, 1);
            string insertName = removeName.Insert(removeName.Length, "1");
            string lastPartName = "PartPrefabs/" + insertName;

            GameObject part = Resources.Load(lastPartName, typeof(GameObject)) as GameObject;

            GameObject goTemp = Instantiate(part) as GameObject;

            Vector3 tmp = goTemp.transform.position;
            Quaternion temp = goTemp.transform.rotation;

            goTemp.transform.parent = parent.transform;
            goTemp.transform.localPosition = tmp;
            goTemp.transform.localRotation = temp;
        }
    }
コード例 #36
0
ファイル: csItemDataBase.cs プロジェクト: Reiie/Creature_Race
    public void SqlQurey(int type)
    {
        string m_ConnectionString;
        string m_SQLiteFileName = "raceDB.sqlite";
        string conn;
        #if UNITY_EDITOR
        m_ConnectionString = "URI=file:" + Application.streamingAssetsPath + "/" + m_SQLiteFileName;
        //m_ConnectionString = "URI=file:" + Application.dataPath + "/" + m_SQLiteFileName;
        #else
            // check if file exists in Application.persistentDataPath
            var filepath = string.Format("{0}/{1}", Application.persistentDataPath, m_SQLiteFileName);

            if (!File.Exists(filepath))
            {
                // if it doesn't ->
                // open StreamingAssets directory and load the db ->

        #if UNITY_ANDROID
                WWW loadDb = new WWW("jar:file://" + Application.dataPath + "!/assets/" + m_SQLiteFileName);  // this is the path to your StreamingAssets in android
                loadDb.bytesDownloaded.ToString();
                while (!loadDb.isDone) { }  // CAREFUL here, for safety reasons you shouldn't let this while loop unattended, place a timer and error check
                // then save to Application.persistentDataPath
                File.WriteAllBytes(filepath, loadDb.bytes);
        #elif UNITY_IOS
                     var loadDb = Application.dataPath + "/Raw/" + m_SQLiteFileName;  // this is the path to your StreamingAssets in iOS
                    // then save to Application.persistentDataPath
                    File.Copy(loadDb, filepath);
        #elif UNITY_WP8
                    var loadDb = Application.dataPath + "/StreamingAssets/" + m_SQLiteFileName;  // this is the path to your StreamingAssets in iOS
                    // then save to Application.persistentDataPath
                    File.Copy(loadDb, filepath);
        #elif UNITY_WINRT
          var loadDb = Application.dataPath + "/StreamingAssets/" + m_SQLiteFileName;  // this is the path to your StreamingAssets in iOS
          // then save to Application.persistentDataPath
          File.Copy(loadDb, filepath);
        #else
         var loadDb = Application.dataPath + "/StreamingAssets/" + m_SQLiteFileName;  // this is the path to your StreamingAssets in iOS
         // then save to Application.persistentDataPath
         File.Copy(loadDb, filepath);

        #endif
            }

            m_ConnectionString = "URI=file:" + filepath;
        #endif
        // 아이템정보 읽어오기
        if (Application.platform == RuntimePlatform.Android)
        {
            conn = "URI=file:" + Application.persistentDataPath + "/raceDB.sqlite"; //Path to databse on Android
        }
        else { conn = "URI=file:" + Application.streamingAssetsPath + "/raceDB.sqlite"; }

        IDbConnection dbconn;
        dbconn = (IDbConnection)new SqliteConnection(conn);
        dbconn.Open(); //Open connection to the database.
        IDbCommand dbcmd = dbconn.CreateCommand();

        string sqlQuery;

        int count = 0;

        if (type == 0)
        {
            //셀렉트
            sqlQuery = "SELECT * " + "FROM Item";
            dbcmd.CommandText = sqlQuery;

            IDataReader reader = dbcmd.ExecuteReader();

            while (reader.Read())
            {
                csItem tmp = new csItem();

                tmp.itemCode = reader.GetString(0);
                tmp.itemType = (csItem.ItemType)reader.GetInt32(1);
                tmp.itemName = reader.GetString(2);
                tmp.rank = reader.GetInt32(3);
                tmp.legCount = reader.GetInt32(4);
                tmp.power = reader.GetInt32(5);
                tmp.balance = reader.GetInt32(6);
                tmp.max_speed = reader.GetInt32(7);
                tmp.hp = reader.GetInt32(8);
                tmp.sec_heal = reader.GetInt32(9);
                tmp.jumpPower = reader.GetInt32(10);
                tmp.cliberPower = reader.GetInt32(11);
                tmp.blueprint = reader.GetString(12);
                tmp.buy_Price = reader.GetInt32(13);
                tmp.sell_Price = reader.GetInt32(14);
                tmp.etc = reader.GetString(15);
                tmp.ability = reader.GetInt32(16);
                tmp.itemMaxAmount = 1;
                tmp.itemSpriteName = tmp.itemCode;

                tmp.itemID = count;
                count++;

                tmp.initialization();
                Database.Add(tmp);
                PartDB.Add(tmp);

                switch(tmp.rank)
                {
                    case 6:
                        RankSix.Add(tmp);
                        break;
                    case 5:
                        RankFive.Add(tmp);
                        break;
                    case 4:
                        RankFour.Add(tmp);
                        break;
                    case 3:
                        RankThree.Add(tmp);
                        break;
                    case 2:
                        RankTwo.Add(tmp);
                        break;
                    case 1:
                        RankOne.Add(tmp);
                        break;
                }

            }
            reader.Close();
            reader = null;
        }

        // 인벤읽어오기
        if (type == 1)
        {
            sqlQuery = "SELECT \"Code\", \"Amount\"" + "FROM Inventory";
            dbcmd.CommandText = sqlQuery;

            IDataReader reader = dbcmd.ExecuteReader();
            while (reader.Read())
            {
                myItem tmp;
                tmp.code = reader.GetString(0);

                tmp.amount = reader.GetInt32(1);

                inven.Add(tmp);
            }
            reader.Close();
            reader = null;
        }

        // 장비읽어오기
        if (type == 2)
        {
            sqlQuery = "SELECT \"Code\", \"Amount\"" + "FROM Equipement";
            dbcmd.CommandText = sqlQuery;

            IDataReader reader = dbcmd.ExecuteReader();
            while (reader.Read())
            {
                myItem tmp;
                tmp.code = reader.GetString(0);
                tmp.amount = reader.GetInt32(1);
                equip.Add(tmp);
            }
            reader.Close();
            reader = null;
        }

        // 설계도 읽어오기
        if (type == 3)
        {
            //셀렉트
            sqlQuery = "SELECT * " + "FROM BluePrint";
            dbcmd.CommandText = sqlQuery;

            IDataReader reader = dbcmd.ExecuteReader();

            while (reader.Read())
            {
                csItem tmp = new csItem();

                tmp.itemCode = reader.GetString(0);
                tmp.itemName = reader.GetString(1);
                tmp.rank = reader.GetInt32(2);
                tmp.itemType = (csItem.ItemType)reader.GetInt32(3);

                tmp.l_metal = reader.GetInt32(4);
                tmp.m_metal = reader.GetInt32(5);
                tmp.h_metal = reader.GetInt32(6);

                tmp.l_circuit = reader.GetInt32(7);
                tmp.m_circuit = reader.GetInt32(8);
                tmp.h_circuit = reader.GetInt32(9);

                tmp.l_junk = reader.GetInt32(10);
                tmp.m_junk = reader.GetInt32(11);
                tmp.h_junk = reader.GetInt32(12);

                tmp.sell_Price = reader.GetInt32(13);
                tmp.etc = reader.GetString(14);

                tmp.itemSpriteName = tmp.itemCode;
                tmp.itemMaxAmount = 999;
                tmp.itemID = count;
                count++;
                tmp.initialization();
                Database.Add(tmp);
                BlueprintDB.Add(tmp);

                switch (tmp.rank)
                {
                    case 6:
                        RankSix.Add(tmp);
                        break;
                    case 5:
                        RankFive.Add(tmp);
                        break;
                    case 4:
                        RankFour.Add(tmp);
                        break;
                    case 3:
                        RankThree.Add(tmp);
                        break;
                    case 2:
                        RankTwo.Add(tmp);
                        break;
                    case 1:
                        RankOne.Add(tmp);
                        break;
                }

            }
            reader.Close();
            reader = null;
        }
        // 재료 읽어오기
        if (type == 4)
        {
            //셀렉트
            sqlQuery = "SELECT * " + "FROM Material";
            dbcmd.CommandText = sqlQuery;

            IDataReader reader = dbcmd.ExecuteReader();

            while (reader.Read())
            {
                csItem tmp = new csItem();

                tmp.itemCode = reader.GetString(0);
                tmp.itemName = reader.GetString(1);
                tmp.rank = reader.GetInt32(2);
                tmp.itemType = (csItem.ItemType)reader.GetInt32(3);
                tmp.sell_Price = reader.GetInt32(4);
                tmp.subType = (csItem.SubType)reader.GetInt32(5);
                tmp.etc = reader.GetString(6);

                tmp.itemSpriteName = tmp.itemCode;
                tmp.itemMaxAmount = 999;
                tmp.itemID = count;
                count++;
                tmp.initialization();
                Database.Add(tmp);
                MaterialDB.Add(tmp);

            }
            reader.Close();
            reader = null;
        }

        dbcmd.Dispose();
        dbcmd = null;
        dbconn.Close();
        dbconn = null;
    }
コード例 #37
0
ファイル: csSlotStorage.cs プロジェクト: Reiie/Creature_Race
    // isDragOk도 재설정해야댐
    public void AddItem(csItem item)
    {
        isDragOk = true;
        items.Push(item);

        if (items.Count > 1)
        {
            itemAmount.text = items.Count.ToString();
        }

        ChangeSprite(item.itemAtlas, item.itemSpriteName);
    }