Example #1
0
    void managePickingUpItem()
    {
        if (offeredPickup != "")
        {
            if (offeredPickup == "Health")
            {
                if (User.Health < 100f)
                {
                    net.ConsumeHealth(User.viewID);
                    net.LocEnt.Health = 100f;
                    User.Health       = 100f;
                    PlaySound("guncocked");

                    currentOfferedPickup.Pickup();
                    hud.Log.AddEntry("+", offeredPickup, S.ColToVec(Color.gray));
                }
            }
            else               // must be a weapon
            {
                for (int i = 0; i < arse.Guns.Length; i++)
                {
                    if (offeredPickup == arse.Guns[i].Name)
                    {
                        if (!arse.Guns[i].Carrying)
                        {
                            arse.Guns[i].Carrying = true;
                            arse.Guns[i].Instance = (GameObject)GameObject.Instantiate(arse.Guns[i].Prefab);
                            arse.Guns[i].Renderer = arse.Guns[i].Instance.GetComponentInChildren <Renderer>();
                            arse.Guns[(int)GunOnBack].Cooldown =
                                arse.Guns[(int)GunInHand].Cooldown;
                            GunOnBack = GunInHand;

                            GunInHand = (Gun)i;
                            arse.Guns[(int)GunInHand].Cooldown = 0f;
                            weaponSwitchingSoundAndVisual();
                            currentOfferedPickup.Pickup();
                            hud.Log.AddEntry("+", offeredPickup, S.ColToVec(Color.gray));
                        }
                    }
                }
            }
        }
    }