Beispiel #1
0
    private void Weapon(int num)
    {
        HMWeaponItem item = (HMWeaponItem)StateManager.Instance.weaponItems[num];

        weaponDurabilityText.GetComponent <Text>().text = "내구도: " + StateManager.Instance.weaponDurability[StateManager.Instance.wUse];
        weaponNameText.GetComponent <Text>().text       = item.Name + " 공격력: " + item.AttackPoint.ToString();

        weaponImage.GetComponent <Image>().sprite = (Sprite)Resources.Load(item.Image, typeof(Sprite));

        GameObject gameObj = Instantiate(WeaponUse) as GameObject;

        gameObj.transform.SetParent(grid.transform);
        gameObj.transform.localScale    = new Vector3(1, 1, 1);
        StateManager.Instance.useWeapon = (Sprite)Resources.Load(item.Image, typeof(Sprite));

        for (int wNum = 0; wNum < 5; wNum++)
        {
            if (StateManager.Instance.weaponSpace[wNum] == null)
            {
                gameObj.name = item.Name + wNum;
                StateManager.Instance.weaponDurability[wNum] = item.Durability;
                StateManager.Instance.weaponSpace[wNum]      = gameObj;
                StateManager.Instance.weaponSpace[wNum].transform.FindChild("weaponUseIcon").GetComponentInChildren <Image>().enabled = true;

                return;
            }
        }
    }
Beispiel #2
0
    public void _setupWeapon(int itemIndex)
    {
        HMWeaponItem item = (HMWeaponItem)wItems[itemIndex];

        string str;
        string strGold;
        string gold = item.Price.ToString();

        strGold = String.Format(itemPrice, gold);

        string str1 = item.Name;
        string str2 = item.Explain;
        string str3 = "공격력: ";
        string str4 = item.AttackPoint.ToString();

        // 문자열 포맷을 지정하여 저장
        str = String.Format(itemDescFormat, str1, str2, str3, str4);


        weaponPoolPriceText.GetComponent <Text>().text = strGold;
        weaponPoolNameText.GetComponent <Text>().text  = str;

        weaponBackgroundImage.GetComponent <Image>().sprite = (Sprite)Resources.Load(item.Image, typeof(Sprite));

        weaponPoolSet[itemIndex] = Instantiate(weaponPool) as GameObject;
        weaponPoolSet[itemIndex].transform.SetParent(gridPool.transform);
        weaponPoolSet[itemIndex].transform.localScale = new Vector3(1, 1, 1);

        weaponPoolSet[itemIndex].name = item.WeaponName;

        weaponPoolSet[itemIndex].GetComponent <Button>().onClick.AddListener(delegate { onClickWeaponButton(itemIndex); });

        weaponPoolSet[itemIndex].SetActive(false);
    }
Beispiel #3
0
    private void _itemWeapon(GameObject gameObj, int itemIndex, String weaponName)
    {
        if (StateManager.Instance.bagSize == 5)
        {
            return;
        }
        StateManager.Instance.bagSize++;
        //StateManager.Instance.bagNum = wNum;
        HMWeaponItem item = (HMWeaponItem)wItems[itemIndex];

        weaponDurabilityText.GetComponent <Text>().text = "내구도: " + item.Durability.ToString();
        weaponNameText.GetComponent <Text>().text       = item.Name + " 공격력: " + item.AttackPoint.ToString();

        weaponImage.GetComponent <Image>().sprite = (Sprite)Resources.Load(item.Image, typeof(Sprite));

        gameObj = Instantiate(WeaponUse) as GameObject;
        gameObj.transform.SetParent(grid.transform);
        gameObj.transform.localScale = new Vector3(1, 1, 1);

        for (wNum = 0; wNum < 5; wNum++)
        {
            if (StateManager.Instance.weaponSpace[wNum] == null)
            {
                gameObj.name = weaponName + wNum;
                StateManager.Instance.weaponDurability[wNum] = item.Durability;
                StateManager.Instance.weaponSpace[wNum]      = gameObj;
                return;
            }
        }
    }
Beispiel #4
0
    private void weaponSet()
    {
        wNum = StateManager.Instance.bagNum;

        HMWeaponItem item = (HMWeaponItem)StateManager.Instance.weaponItems[wNum];

        if (d == 0)
        {
            ynPop.SetActive(false);
            dText.text = StateManager.Instance.weaponDurability[wNum].ToString();
            StateManager.Instance.weaponSpace[wNum].GetComponent <Button>().enabled = false;
            StateManager.Instance.weaponSpace[wNum].transform.FindChild("weaponUseIcon").GetComponentInChildren <Image>().enabled = true;
            StateManager.Instance.playUseAtk        = csUseEquip.attackPoint;
            StateManager.Instance.wUse              = wNum;
            useWeapon.GetComponent <Image>().sprite = StateManager.Instance.weaponSpace[wNum].transform.FindChild("weaponImage").GetComponent <Image>().sprite;
            StateManager.Instance.useWeapon         = useWeapon.GetComponent <Image>().sprite;
        }

        else if (d > 0)
        {
            ynPop.SetActive(false);
            rPop.SetActive(true);
            uText.text = "내 구 가 " + d + "\n" + "사 용 하 시 겠 습 니 까?";
        }
    }
Beispiel #5
0
    //무기 사기 위한 버튼
    public void onClickWeaponButton(int num)
    {
        if (StateManager.Instance.bagSize == 5)
        {
            return;
        }
        HMWeaponItem item = (HMWeaponItem)wItems[num];

        if (StateManager.Instance.playGold >= item.Price)
        {
            StateManager.Instance.playGold -= item.Price;
            this._itemWeapon(weaponSetObj, num, weaponPoolSet[num].name);
        }
    }
Beispiel #6
0
 public void EquipWeapon()
 {
     for (int j = 0; j < wItems.Count; j++)
     {
         HMWeaponItem item = (HMWeaponItem)wItems[j];
         for (int i = 0; i < 10; i++)
         {
             if (gameObject.name == item.WeaponName + i)
             {
                 equipNum       = 1;
                 itemUsePopBool = true;
                 StateManager.Instance.bagNum = i;
                 attackPoint = item.AttackPoint;
             }
         }
     }
 }
Beispiel #7
0
    void LoadAssetfromJson()
    {
        wItems = new ArrayList();
        aItems = new ArrayList();
        bItems = new ArrayList();

        Hashtable itemTable = (Hashtable)HMJson.objectFromJsonString(textAsset.text);

        foreach (String itemName in itemTable.Keys)
        {
            itemInfos  = (ArrayList)itemTable["weapon"];
            itemInfosA = (ArrayList)itemTable["armor"];
            itemInfosB = (ArrayList)itemTable["boots"];
            //Debug.Log("[Item " + itemName + "]" + "\n");

            foreach (Hashtable itemInfo in itemInfos)
            {
                String name          = (String)itemInfo["name"];
                String price         = (String)itemInfo["weaponPrice"];
                String atkPoint      = (String)itemInfo["weaponATK"];
                String durability    = (String)itemInfo["weaponDurability"];
                String weaponExplain = (String)itemInfo["weaponExplain"];
                String weaponName    = (String)itemInfo["weaponName"];
                String weaponImage   = (String)itemInfo["weaponImage"];

                HMWeaponItem weaponItem = new HMWeaponItem();
                weaponItem.Name        = name;
                weaponItem.Price       = Int32.Parse(price);
                weaponItem.AttackPoint = Int32.Parse(atkPoint);
                weaponItem.Durability  = Int32.Parse(durability);
                weaponItem.Explain     = weaponExplain;
                weaponItem.WeaponName  = weaponName;
                weaponItem.Image       = weaponImage;
                wItems.Add(weaponItem);
            }

            foreach (Hashtable itemInfo in itemInfosA)
            {
                String name          = (String)itemInfo["name"];
                String price         = (String)itemInfo["price"];
                String aromorExplain = (String)itemInfo["armorExplain"];
                String defPoint      = (String)itemInfo["armorDef"];
                String armorName     = (String)itemInfo["armorName"];
                String armorImage    = (String)itemInfo["armorImage"];

                HMArmorItem armorItem = new HMArmorItem();
                armorItem.Name      = name;
                armorItem.Price     = Int32.Parse(price);
                armorItem.Def       = Int32.Parse(defPoint);
                armorItem.ArmorName = armorName;
                armorItem.Explain   = aromorExplain;
                armorItem.Image     = armorImage;
                aItems.Add(armorItem);
            }

            foreach (Hashtable itemInfo in itemInfosB)
            {
                String name         = (String)itemInfo["name"];
                String price        = (String)itemInfo["price"];
                String bootsExplain = (String)itemInfo["bootsExplain"];
                String bootsSpd     = (String)itemInfo["bootsSpd"];
                String bootsName    = (String)itemInfo["bootsName"];
                String bootsImage   = (String)itemInfo["bootsImage"];

                HMBootsItem bootsItem = new HMBootsItem();
                bootsItem.Name      = name;
                bootsItem.Price     = Int32.Parse(price);
                bootsItem.Spd       = float.Parse(bootsSpd);
                bootsItem.Explain   = bootsExplain;
                bootsItem.BootsName = bootsName;
                bootsItem.Image     = bootsImage;
                bItems.Add(bootsItem);
            }
        }
    }
Beispiel #8
0
    private void GetWeapon(GameObject gameObj, int itemIndex)
    {
        int WeaponNum = Random.Range(0, 4);

        if (WeaponNum == 3)
        {
            WeaponNum = 2;
        }

        Debug.Log(WeaponNum + "무기 번호");
        switch (itemIndex)
        {
        case 0:
            //망가진 무기을 발견(꽝)
            if (cBoxOpen.activeSelf.Equals(false))
            {
                StartCoroutine(findObj(8, 0, "망 가 진 \n 무 기 를  발 견 "));
            }
            else if (cBoxOpen.activeSelf.Equals(true))
            {
                getItemText.text = "획득 아이템 \n: 망가진 무기 발견 ";
            }
            break;

        case 1:
            HMWeaponItem witem = (HMWeaponItem)StateManager.Instance.weaponItems[WeaponNum];
            if (StateManager.Instance.bagSize == 5)
            {
                getItemText.text = "획득 아이템 \n: 가방이 꽉 찼다.";
                return;
            }
            if (cBoxOpen.activeSelf.Equals(false))
            {
                StartCoroutine(findObj(8, 0, witem.Name + " 내 구 도: " + (witem.Durability / 2).ToString() + "\n의 무 기  발 견"));
            }
            else if (cBoxOpen.activeSelf.Equals(true))
            {
                getItemText.text = "획득 아이템 \n: " + witem.Name + "\n 내 구 도: " + witem.Durability.ToString();
                getItem.GetComponent <Image>().sprite = (Sprite)Resources.Load(witem.Image, typeof(Sprite));
            }

            StateManager.Instance.bagSize++;
            weaponDurabilityText.GetComponent <Text>().text = "내구도: " + (witem.Durability / 2).ToString();
            weaponNameText.GetComponent <Text>().text       = witem.Name + " 공격력: " + witem.AttackPoint.ToString();

            weaponImage.GetComponent <Image>().sprite = (Sprite)Resources.Load(witem.Image, typeof(Sprite));

            gameObj = Instantiate(WeaponUse) as GameObject;
            gameObj.transform.SetParent(weaponGrid.transform);
            gameObj.transform.localScale = new Vector3(1, 1, 1);

            for (int wNum = 0; wNum < 5; wNum++)
            {
                if (StateManager.Instance.weaponSpace[wNum] == null)
                {
                    gameObj.name = witem.WeaponName + wNum;
                    StateManager.Instance.weaponDurability[wNum] = witem.Durability / 2;
                    StateManager.Instance.weaponSpace[wNum]      = gameObj;
                    return;
                }
            }


            break;

        case 2:
            HMWeaponItem item = (HMWeaponItem)StateManager.Instance.weaponItems[WeaponNum];

            if (StateManager.Instance.bagSize == 5)
            {
                getItemText.text = "획득 아이템 \n: 가방이 꽉 찼다.";
                return;
            }
            if (cBoxOpen.activeSelf.Equals(false))
            {
                StartCoroutine(findObj(8, 0, item.Name + " 내 구 도: " + item.Durability.ToString() + "\n의 무 기  발 견"));
            }
            else if (cBoxOpen.activeSelf.Equals(true))
            {
                getItem.GetComponent <Image>().sprite = (Sprite)Resources.Load(item.Image, typeof(Sprite));
                getItemText.text = "획득 아이템 \n: " + item.Name + "\n 내 구 도: " + item.Durability.ToString();
            }
            StateManager.Instance.bagSize++;
            weaponDurabilityText.GetComponent <Text>().text = "내구도: " + item.Durability.ToString();
            weaponNameText.GetComponent <Text>().text       = item.Name + " 공격력: " + item.AttackPoint.ToString();

            weaponImage.GetComponent <Image>().sprite = (Sprite)Resources.Load(item.Image, typeof(Sprite));

            gameObj = Instantiate(WeaponUse) as GameObject;
            gameObj.transform.SetParent(weaponGrid.transform);
            gameObj.transform.localScale = new Vector3(1, 1, 1);

            for (int wNum = 0; wNum < 5; wNum++)
            {
                if (StateManager.Instance.weaponSpace[wNum] == null)
                {
                    gameObj.name = item.WeaponName + wNum;
                    StateManager.Instance.weaponDurability[wNum] = item.Durability;
                    StateManager.Instance.weaponSpace[wNum]      = gameObj;
                    return;
                }
            }

            break;
        }
    }