Пример #1
0
 // Update is called once per frame
 void Update()
 {
     if (Menu)
     {
         if (Menu.isSelect(out v))
         {
             if (v.y > 0 && v.y < 4)
             {
                 Menu.Cancel();
             }
             else if (v.y == 4)
             {
                 Application.Quit();
             }
             else
             {
                 GotoScene(Menu.IconTr[(int)v.y].GetComponentInChildren <Image>().name);
             }
         }
         else
         {
             if (v != PrevV)
             {
                 changer.TriggerOn();
                 Image PrevText = Menu.IconTr[(int)PrevV.y].GetChild(0).transform.GetChild(0).GetComponent <Image>();
                 Image TempText = Menu.IconTr[(int)v.y].GetChild(0).transform.GetChild(0).GetComponent <Image>();
                 PrevText.gameObject.SetActive(false);
                 TempText.gameObject.SetActive(true);
                 Menu.IconTr[(int)PrevV.y].GetChild(0).GetComponent <Image>().enabled = true;
                 Menu.IconTr[(int)v.y].GetChild(0).GetComponent <Image>().enabled     = false;
                 PrevV = v;
                 //  PrevV //정상화
                 //  v // 미백
             }
         }
     }
 }
Пример #2
0
    IEnumerator ItemSelect(int i)
    {
        ItemIconCtrl.switchs[i]();
        bool[]     ItemsOK = { false, false };
        SelectMenu Sm      = TempMenu[i] = ItemSelecter[i];

        TempMenu[i].isRun = true;

        Vector2 v;

        yield return(StartCoroutine("MoveMenu", new object[] { Sm, DownMenuY }));

        ItemDes[i].gameObject.SetActive(true);
        while (true)
        {
            if (Sm.isSelect(out v))
            {
                if (false)//예외적 아이템 클릭.
                {
                    Sm.Cancel();
                    continue;
                }
                if (!ItemsOK[1])
                {
                    EffectManager.ins.EffectRun(TempMenu[i].CursorTr.GetComponent <RectTransform>().position, Vector3.one, SmallSelectEffect[i], 0.63f, true);
                }

                if (!ItemsOK[0])
                {
                    //1번아이템
                    int index = (int)v.x + (int)v.y * Sm.XLength;
                    MenuItemIndex.GetItemIndexToCode(out ItemCode[i], MenuItemIndex.RESULTTYPE.EQULPMENT, index);
                    if (ItemCode[i] != Item.ITEMCODE.NONE)
                    {
                        Item.ItemData data = Item.GetItem(ItemCode[i]);
                        if (Duration[i] + data.weight <= MAXDURATION)
                        {
                            GameData.ins.EquipmentCode[i] = ItemCode[i];
                            Duration[i] += data.weight;
                            ItemsOK[0]   = true;
                            Sm.Cancel();
                            ItemDes[i].gameObject.SetActive(false);
                            yield return(StartCoroutine("MoveMenu", new object[] { Sm, UpMenuY }));

                            ItemIconCtrl.switchs[i]();
                            //이미지교체
                            yield return(StartCoroutine("MoveMenu", new object[] { Sm, DownMenuY }));

                            ItemDes[i].gameObject.SetActive(true);
                        }
                        else
                        {
                            Sm.Cancel();
                        }
                    }
                    else
                    {
                        Sm.Cancel();
                    }
                }
                else if (!ItemsOK[1])
                {
                    //2번아이템
                    int index = (int)v.x + (int)v.y * Sm.XLength;
                    MenuItemIndex.GetItemIndexToCode(out ItemCode[i + 2], MenuItemIndex.RESULTTYPE.POTION, index);

                    if (ItemCode[i + 2] != Item.ITEMCODE.NONE)
                    {
                        Item.ItemData data = Item.GetItem(ItemCode[i + 2]);
                        if (Duration[i] + data.weight <= MAXDURATION)
                        {
                            GameData.ins.PotionCode[i] = ItemCode[i + 2];
                            Duration[i] += data.weight;
                            AllOK[i]     = true;
                            CheckingCharacterIndex(i);
                            ItemsOK[1] = true;

                            ItemDes[i].gameObject.SetActive(false);
                            yield return(StartCoroutine("MoveMenu", new object[] { Sm, UpMenuY }));

                            ItemIconCtrl.switchs[i]();
                        }
                        else
                        {
                            Sm.Cancel();
                        }
                    }
                    else
                    {
                        Sm.Cancel();
                    }
                }
            }
            ItemDes[i].SetItemIndex((int)(v.x + v.y * TempMenu[i].XLength), ItemsOK[0] ? MenuItemIndex.RESULTTYPE.POTION : MenuItemIndex.RESULTTYPE.EQULPMENT);
            if (Input.GetKeyDown(Sm.KeysData[Sm.KeysData.Length - 1]))
            //exit눌렀을때
            {
                AllOK[i] = false;
                bool isCancel = false;
                for (int j = 1; j >= 0; j--)
                {
                    if (ItemsOK[j])
                    {
                        ItemsOK[j] = !ItemsOK[j];
                        isCancel   = true;
                        Item.ItemData data = Item.GetItem(ItemCode[i + 2 * j]);
                        Duration[i] -= data.weight;
                        ItemDes[i].gameObject.SetActive(false);
                        if (j != 1)
                        {
                            yield return(StartCoroutine("MoveMenu", new object[] { Sm, UpMenuY }));
                        }
                        ItemIconCtrl.switchs[i]();
                        yield return(StartCoroutine("MoveMenu", new object[] { Sm, DownMenuY }));

                        ItemDes[i].gameObject.SetActive(true);
                        if (j == 1)
                        {
                            GameData.ins.PotionCode[i] = Item.ITEMCODE.NONE;
                        }
                        else
                        {
                            GameData.ins.EquipmentCode[i] = Item.ITEMCODE.NONE;
                        }
                        break;
                    }
                }
                if (!isCancel)
                {
                    PlayerStasis[i]--;
                    Sm.isRun = false;
                    CharacterSelecter[i].Cancel();
                    ItemDes[i].gameObject.SetActive(false);
                    yield return(StartCoroutine("MoveMenu", new object[] { Sm, UpMenuY }));

                    ItemIconCtrl.switchs[i]();
                    StartCoroutine("StasisChecker", i);
                    yield break;
                }
            }

            yield return(null);
        }
    }