コード例 #1
0
    void SelectWeapon(int weaponID, int selectRectIndex)
    {
        bool alreadySelected = false;

        for (int j = 0; j < SELECTION_NUM; j++)
        {
            if (rectToWeaponMap[j] != -1)
            {
                if (rectToWeaponMap[j] == weaponID)
                {
                    alreadySelected = true;
                }
            }
        }

        if (!alreadySelected)
        {
            int oldWeaponID = rectToWeaponMap[selectRectIndex];
            if (oldWeaponID != -1)
            {
                weaponList[oldWeaponID].IsSelectedForBattle = false;
            }
            weaponList[weaponID].IsSelectedForBattle = true;
            Material weaponIconMaterial = UIResourceMgr.GetInstance().GetMaterial("Weapons3");
            Rect     rect = WeaponsLogoTexturePosition.GetWeaponIconTextureRect(weaponID);
            battleWeaponGrid.SetGridTexture(selectRectIndex, weaponIconMaterial, rect);
            battleWeaponGrid.SetGridTexturePosition(selectRectIndex, selectRectIndex);
            rectToWeaponMap[selectRectIndex] = weaponID;

            avatarFrame.ChangeAvatar(GameApp.GetInstance().GetGameState().Avatar);
        }
    }
コード例 #2
0
 void PutBattleWeapons()
 {
     for (int i = 0; i < SELECTION_NUM; i++)
     {
         int weaponID = rectToWeaponMap[i];
         if (weaponID != -1)
         {
             Material weaponIconMaterial = UIResourceMgr.GetInstance().GetMaterial("Weapons3");
             Rect     rect = WeaponsLogoTexturePosition.GetWeaponIconTextureRect(weaponID);
             battleWeaponGrid.SetGridTexture(i, weaponIconMaterial, rect);
         }
     }
 }
コード例 #3
0
    public void HandleEvent(UIControl control, int command, float wparam, float lparam)
    {
        if (control == returnButton)
        {
            AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>());
            GameApp.GetInstance().Save();
            Hide();
            GameObject.Find("ArenaMenuUI").GetComponent <ArenaMenuUI>().GetPanel(MenuName.ARENA).Show();
        }
        else if (control == weaponScroller)
        {
            int index = (int)wparam;
            //scroller at
            if (command == (int)UIImageScroller.Command.ScrollSelect)
            {
                currentSelectionWeaponIndex = gameState.GetWeaponByOwnedIndex(index);
                UpdateWeaponInfo();
            }
            // long press
            else if (command == (int)UIImageScroller.Command.PressSelect)
            {
                if (gameState != null)
                {
                    Material weaponIconMaterial = UIResourceMgr.GetInstance().GetMaterial("Weapons3");
                    Rect     rect = WeaponsLogoTexturePosition.GetWeaponIconTextureRect(currentSelectionWeaponIndex);
                    selectionImage.SetTexture(weaponIconMaterial, rect, AutoRect.AutoSize(rect));
                    selectionImage.Rect = weaponScroller.GetCenterRect();
                }
            }
            //long end
            else if (command == (int)UIImageScroller.Command.PressEnd)
            {
                selectionImage.Rect = new Rect(-1000, -1000, 200, 200);
                for (int i = 0; i < SELECTION_NUM; i++)
                {
                    if (selectionRect[i].Contains(new Vector2(wparam, lparam)))
                    {
                        SelectWeapon(currentSelectionWeaponIndex, i);
                        break;
                    }
                }
            }
            //drag move
            else if (command == (int)UIImageScroller.Command.DragMove)
            {
                selectionImage.Rect = new Rect(wparam - 438 * 1.2f / 2, lparam - 192 * 1.2f / 2, 438 * 1.2f, 192 * 1.2f);
            }
        }
        else if (control == battleWeaponGrid)
        {
            if (command == (int)UIDragGrid.Command.DragOutSide)
            {
                int i = (int)wparam;
                if (InBattleWeaponCount() > 1)
                {
                    int weaponID = rectToWeaponMap[i];
                    if (weaponID != -1)
                    {
                        weaponList[weaponID].IsSelectedForBattle = false;

                        rectToWeaponMap[i] = -1;
                        battleWeaponGrid.HideGridTexture(i);
                        avatarFrame.ChangeAvatar(GameApp.GetInstance().GetGameState().Avatar);
                    }
                }
                else
                {
                    battleWeaponGrid.SetGridTexturePosition(i, i);
                }
            }
            else if (command == (int)UIDragGrid.Command.DragExchange)
            {
                int i = (int)wparam;
                int j = (int)lparam;

                int temp = rectToWeaponMap[i];
                rectToWeaponMap[i] = rectToWeaponMap[j];
                rectToWeaponMap[j] = temp;

                if (rectToWeaponMap[i] != -1)
                {
                    Material weaponIconMaterial = UIResourceMgr.GetInstance().GetMaterial("Weapons3");
                    Rect     rect = WeaponsLogoTexturePosition.GetWeaponIconTextureRect(rectToWeaponMap[i]);
                    battleWeaponGrid.SetGridTexture(i, weaponIconMaterial, rect);


                    battleWeaponGrid.SetGridTexturePosition(i, i);
                }
                else
                {
                    battleWeaponGrid.HideGridTexture(i);
                }

                if (rectToWeaponMap[j] != -1)
                {
                    Material weaponIconMaterial = UIResourceMgr.GetInstance().GetMaterial("Weapons3");
                    Rect     rect = WeaponsLogoTexturePosition.GetWeaponIconTextureRect(rectToWeaponMap[j]);
                    battleWeaponGrid.SetGridTexture(j, weaponIconMaterial, rect);


                    battleWeaponGrid.SetGridTexturePosition(j, j);
                }
                else
                {
                    battleWeaponGrid.HideGridTexture(j);
                }
                avatarFrame.ChangeAvatar(GameApp.GetInstance().GetGameState().Avatar);
            }
        }
        else if (control == getMoreMoneyButton)
        {
            AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>());
            Hide();
            ShopUI shopUI = GameObject.Find("ArenaMenuUI").GetComponent <ArenaMenuUI>().GetPanel(MenuName.SHOP) as ShopUI;
            shopUI.SetFromPanel(this);
            shopUI.Show();
        }
    }
コード例 #4
0
    void Init()
    {
        Cursor.visible = true;

        selectionRect[0] = AutoRect.AutoPos(new Rect(28, 88, 112, 112));

        selectionRect[1] = AutoRect.AutoPos(new Rect(28 + 150, 88, 112, 112));

        selectionRect[2] = AutoRect.AutoPos(new Rect(28 + 150 * 2, 88, 112, 112));


        gameState = GameApp.GetInstance().GetGameState();

        weaponUI = UIResourceMgr.GetInstance().GetMaterial("Weapons");
        Material weapon3Material = UIResourceMgr.GetInstance().GetMaterial("Weapons3");
        Rect     gridbackRect    = WeaponsLogoTexturePosition.GetWeaponIconTextureRect(13);

        battleWeaponGrid = new UIDragGrid(0);

        rectToWeaponMap = GameApp.GetInstance().GetGameState().GetRectToWeaponMap();

        for (int i = 0; i < SELECTION_NUM; i++)
        {
            battleWeaponGrid.AddGrid(selectionRect[i], weapon3Material, gridbackRect);
        }


        GameApp.GetInstance().Init();
        weaponList = GameApp.GetInstance().GetGameState().GetWeapons();


        PutBattleWeapons();


        weaponScroller = new UIImageScroller(AutoRect.AutoPos(new Rect(400, 0, 550, 640)), AutoRect.AutoPos(new Rect(440, 180, 500, 369)), 1, AutoRect.AutoSize(WeaponsLogoTexturePosition.WeaponLogoSize), ScrollerDir.Vertical, true);
        weaponScroller.SetImageSpacing(AutoRect.AutoSize(WeaponsLogoTexturePosition.WeaponLogoSpacing));
        weaponScroller.EnableLongPress();


        for (int i = 0; i < weaponList.Count; i++)
        {
            if (weaponList[i].Exist == WeaponExistState.Owned)
            {
                UIImage uiImage = new UIImage();

                TexturePosInfo info = WeaponsLogoTexturePosition.GetWeaponTextureRect(i);


                uiImage.SetTexture(info.m_Material, info.m_TexRect, AutoRect.AutoSize(info.m_TexRect));
                weaponScroller.Add(uiImage);
            }
        }

        this.Add(weaponScroller);
        weaponScroller.EnableScroll();
        Material shopMaterial = UIResourceMgr.GetInstance().GetMaterial("ShopUI");

        weaponScroller.AddOverlay(shopMaterial, ShopTexturePosition.LockedLogo);
        Material avatarLogoMaterial = UIResourceMgr.GetInstance().GetMaterial("Avatar");

        weaponScroller.SetMaskImage(avatarLogoMaterial, AvatarTexturePosition.Mask);

        Material avatarMaterial = UIResourceMgr.GetInstance().GetMaterial("Avatar");

        weaponScroller.SetCenterFrameTexture(avatarMaterial, AvatarTexturePosition.Frame);



        weaponScroller.Show();
        battleWeaponGrid.Show();
        this.Add(battleWeaponGrid);



        getMoreMoneyButton = new UITextButton();
        getMoreMoneyButton.SetTexture(UIButtonBase.State.Normal, arenaMenuMaterial,

                                      ArenaMenuTexturePosition.GetMoneyButtonNormal, AutoRect.AutoSize(ArenaMenuTexturePosition.GetMoneyButtonSmallSize));
        getMoreMoneyButton.SetTexture(UIButtonBase.State.Pressed, arenaMenuMaterial,

                                      ArenaMenuTexturePosition.GetMoneyButtonPressed, AutoRect.AutoSize(ArenaMenuTexturePosition.GetMoneyButtonSmallSize));
        getMoreMoneyButton.Rect = AutoRect.AutoPos(uiPos.GetMoreMoneyButton);

        this.Add(getMoreMoneyButton);


        cashPanel = new CashPanel();
        cashPanel.Show();
        this.Add(cashPanel);

        weaponInfoPanel = new WeaponInfoPanel();
        this.Add(weaponInfoPanel);


        if (AutoRect.GetPlatform() == Platform.IPad)
        {
            avatarFrame = new Avatar3DFrame(AutoRect.AutoPos(new Rect(0, 200, 500, 600)), new Vector3(-1.499798f * 0.9f, -0.6672753f * 0.9f, 4.420711f), new Vector3(1.3f, 1.3f, 1.3f) * 0.85f);
        }
        else
        {
            avatarFrame = new Avatar3DFrame(AutoRect.AutoPos(new Rect(0, 200, 500, 600)), new Vector3(-1.499798f, -0.6672753f, 4.420711f), new Vector3(1.3f, 1.3f, 1.3f));
        }



        this.Add(avatarFrame);
    }