Beispiel #1
0
        public void activateStore()
        {
            PlayerWeapons.HideWeaponInstant();
            Time.timeScale = 0;
            //	GUIController.state = GUIStates.store;
            inStore = true;
            //BroadcastMessage("Unlock");
            storeActive        = true;
            Screen.lockCursor  = false;
            LockCursor.canLock = false;
            //playerW.BroadcastMessage("DeselectWeapon"); //turn off graphics/weapons on entering store
            GameObject player = GameObject.FindWithTag("Player");

            player.BroadcastMessage("Freeze", SendMessageOptions.DontRequireReceiver);
        }
Beispiel #2
0
        // This function draws the popup window to buy or equip a weapon.
        public void WeaponBuyWindow(int windowID)
        {
            WeaponInfo g;
            string     msg;
            Rect       rLeft  = new Rect(5, 20, popupRect.width / 2 - 7, popupRect.height - 25);
            Rect       rRight = new Rect(popupRect.width / 2 + 2, 20, popupRect.width / 2 - 7, popupRect.height - 25);
            int        slot   = lsEquip.selection;    // only used for equiping

            if (header.selection == (int)HeaderModes.Buy)
            {
                g = mdBuy.wi[mdBuy.selection];
            }
            else
            {
                g = mdEquip.wi[mdEquip.selection];
            }
            Upgrade[] upgrades = g.getUpgrades();
            //bool[ ] upgradeToggles = new bool[ upgrades.Length];

            GUI.Box(rLeft, "");
            GUILayout.BeginArea(rLeft);
            GUILayout.BeginHorizontal();
            GUILayout.Space(5);
            GUILayout.BeginVertical();
            GUILayout.Space(5);
            if (header.selection == (int)HeaderModes.Buy)
            {
                msg = getBuyMsg(g);
            }
            else
            {
                msg = getEquipMsg(g, slot);
            }

            GUILayout.Label(msg);
            GUILayout.Label("Available Balance = $" + store.getBalance());

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (header.selection == (int)HeaderModes.Equip)
            {
                if (store.playerW.weapons[slot] != g.gameObject)
                {
                    if (GUILayout.Button("Equip", GUILayout.Width(65)))
                    {
                        store.equipWeapon(g, slot);
                    }
                }
                else
                {
                    if (GUILayout.Button("Un-Equip", GUILayout.Width(65)))
                    {
                        store.unEquipWeapon(g, slot);
                    }
                }
                if (!g.gun.infiniteAmmo)
                {
                    if (g.gun.clips < g.gun.maxClips)
                    {
                        if (store.getBalance() >= g.ammoPrice)
                        {
                            if (GUILayout.Button(new GUIContent("Ammo ($" + g.ammoPrice + ")", "Current Ammo: " + g.gun.clips), GUILayout.Width(85)))
                            {
                                store.BuyAmmo(g);
                            }
                        }
                        else
                        {
                            GUILayout.Button(new GUIContent("Ammo ($" + g.ammoPrice + ")", "Can't Afford"), GUILayout.Width(85));
                        }
                    }
                    else
                    {
                        GUILayout.Button(new GUIContent("Ammo ($" + g.ammoPrice + ")", "Ammo Full: " + g.gun.clips), GUILayout.Width(85));
                    }
                }
            }
            else
            {
                if (g.owned)
                {
                    if (g.canBeSold)
                    {
                        if (GUILayout.Button("Sell", GUILayout.Width(70)))
                        {
                            store.sellWeapon(g);
                        }
                    }
                    else
                    {
                        GUILayout.Button("Can't Sell", GUILayout.Width(70));
                    }
                    if (!g.gun.infiniteAmmo)
                    {
                        if (g.gun.clips < g.gun.maxClips)
                        {
                            if (store.getBalance() >= g.ammoPrice)
                            {
                                if (GUILayout.Button(new GUIContent("Ammo ($" + g.ammoPrice + ")", "Current Ammo: " + g.gun.clips), GUILayout.Width(85)))
                                {
                                    store.BuyAmmo(g);
                                }
                            }
                            else
                            {
                                GUILayout.Button(new GUIContent("Ammo ($" + g.ammoPrice + ")", "Can't Afford"), GUILayout.Width(85));
                            }
                        }
                        else
                        {
                            GUILayout.Button(new GUIContent("Ammo ($" + g.ammoPrice + ")", "Ammo Full: " + g.gun.clips), GUILayout.Width(85));
                        }
                    }
                }
                else
                {
                    if (store.getBalance() >= g.buyPrice)
                    {
                        if (GUILayout.Button("Buy", GUILayout.Width(70)))
                        {
                            store.buyWeapon(g);
                        }
                    }
                    else
                    {
                        GUILayout.Button(new GUIContent("Buy", "Insufficient Funds"), GUILayout.Width(70));
                    }
                }
            }

            if (GUILayout.Button("Close", GUILayout.Width(70)))
            {
                MDSelection    = -1;
                popupActive    = false;
                popupBuyActive = false;
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Label(GUI.tooltip);
            GUILayout.EndVertical();
            GUILayout.Space(5);
            GUILayout.EndHorizontal();
            GUILayout.EndArea();


            // Display for upgrades in the right side of the window
            // The display changes for buying upgrades or equipping upgrades.

            GUI.Box(rRight, "");
            GUILayout.BeginArea(rRight);
            GUILayout.BeginHorizontal();
            GUILayout.Space(5);
            GUILayout.BeginVertical();
            GUILayout.Space(5);
            if (upgrades == null)
            {
                GUILayout.Label("No Upgrades Available for this Weapon");
            }
            else if (upgrades.Length < 0)
            {
                GUILayout.Label("No Upgrades Available for this Weapon");
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                upgradeDisplayBuy = GUILayout.Toggle(upgradeDisplayBuy, "Buy Upgrades");
                if (upgradeDisplayBuy)
                {
                    upgradeDisplayEquip = false;
                }
                upgradeDisplayEquip = GUILayout.Toggle(upgradeDisplayEquip, "Equip Upgrades");
                if (upgradeDisplayEquip)
                {
                    upgradeDisplayBuy = false;
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                if (upgradeDisplayBuy)
                {
                    GUILayout.Space(5);
                    string upgradeMsg;
                    if (g.owned)
                    {
                        upgradeMsg = "View or Buy Upgrades";
                    }
                    else
                    {
                        upgradeMsg = "You must Purchase the Weapon before buying Upgrades";
                    }
                    GUILayout.Label(upgradeMsg);
                    popupBuyScroll1 = GUILayout.BeginScrollView(popupBuyScroll1);
                    if (upgrades != null)
                    {
                        for (int i = 0; i < upgrades.Length; i++)
                        {
                            if (!upgrades[i].owned)
                            {
                                GUILayout.BeginHorizontal();
                                GUILayout.Label(upgrades[i].upgradeName);
                                GUILayout.Space(5);
                                if (GUILayout.Button(setGUIContent(upgradeInfoIcon, "View", ""), GUILayout.Width(40), GUILayout.Height(20)))
                                {
                                    if (upgradeSelected[i])
                                    {
                                        upgradeSelected[i] = false;
                                    }
                                    else
                                    {
                                        upgradeSelected[i] = true;
                                    }
                                }
                                GUILayout.Space(5);

                                GUIContent gc;

                                if (upgrades[i].locked)
                                {
                                    GUILayout.Label("(Locked)");
                                    upgradeMsg = upgrades[i].lockedDescription;
                                }
                                else
                                {
                                    if (g.owned)
                                    {
                                        float balance = store.getBalance();
                                        if (balance > upgrades[i].buyPrice)
                                        {
                                            gc = setGUIContent(upgradeBuyIcon, "Buy", "");
                                        }
                                        else
                                        {
                                            gc = new GUIContent(upgradeBuyIcon, "Insufficient Funds");
                                        }

                                        if (GUILayout.Button(gc, GUILayout.Width(40), GUILayout.Height(20)))
                                        {
                                            if (balance > upgrades[i].buyPrice)
                                            {
                                                store.buyUpgrade(g, upgrades[i]);
                                            }
                                        }
                                    }
                                }
                                upgradeMsg  = "Price :\t$" + upgrades[i].buyPrice + "\n";
                                upgradeMsg += "Description:\t" + upgrades[i].description;
                                GUILayout.FlexibleSpace();
                                GUILayout.EndHorizontal();
                                if (upgradeSelected[i])
                                {
                                    closeOtherSelections(i);
                                    GUILayout.BeginHorizontal();
                                    GUILayout.Space(10);
                                    GUILayout.BeginVertical();
                                    GUILayout.Label(upgradeMsg);
                                    GUILayout.EndVertical();
                                    GUILayout.EndHorizontal();
                                }
                            }                     // upgrade not owned
                        }                         // loop over upgrades
                    }
                    GUILayout.EndScrollView();
                    GUILayout.Label(GUI.tooltip);
                }
                else
                {
                    // Displaying Equip Window
                    GUILayout.Space(5);
                    GUILayout.Label("Select Upgrades To Apply - Note: Some upgrades disable others");
                    bool before;
                    //			bool[ ] upgradesApplied = g.getUpgradesApplied();
                    popupBuyScroll1 = GUILayout.BeginScrollView(popupBuyScroll1);
                    for (int j = 0; j < upgrades.Length; j++)
                    {
                        if (upgrades[j].owned)
                        {
                            before = g.upgradesApplied[j];                             // keep track of current state
                            g.upgradesApplied[j] = GUILayout.Toggle(g.upgradesApplied[j], upgrades[j].upgradeName);
                            if (before != g.upgradesApplied[j])
                            {
                                if (before)
                                {
                                    upgrades[j].RemoveUpgrade();
                                }
                                else
                                {
                                    upgrades[j].ApplyUpgrade();
                                    PlayerWeapons.HideWeaponInstant();                                     //turn off graphics for applied upgrade
                                }
                                g.updateApplied();
                            }
                        }
                    }
                    GUILayout.EndScrollView();
                    GUILayout.Space(8);
                }         // Displaying Equip Window
            }             //upgrades.Length !=0

            GUILayout.EndVertical();
            GUILayout.Space(5);
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }