Example #1
0
    void FixedUpdate()
    {
        if (quit_warning)
        {
            return;
        }

        if (Input.GetButton("Score"))
        {
            if (!isdown[0])
            {
                scoreboard.SetActiveRecursively(!scoreboard.active);
                isdown[0] = true;
            }
        }
        else
        {
            isdown[0] = false;
        }

        if (Input.GetButton("Talk"))
        {
            if (!isdown[1])
            {
                isdown[1] = true;
            }
        }
        else if (!Input.GetButton("Talk") && isdown[1])
        {
            gamecontrol.GetComponent <ChatScript>().enabled = true;
            isdown[1] = false;
        }

        if (isdead)
        {
            goto end;
        }

        if (Input.GetButton("Music"))
        {
            if (!isdown[2])
            {
                if (!isplaying)
                {
                    audio.Play();
                }
                else
                {
                    audio.Stop();
                }
                isplaying = !isplaying;
                isdown[2] = true;
            }
        }
        else
        {
            isdown[2] = false;
        }

        if (Input.GetButton("AltFire"))
        {
            if (!isdown[3])
            {
                switch (player.GetComponent <WeaponScript>().weaponid)
                {
                case 4:
                case 8:
                {
                    weap_light.enabled = !weap_light.enabled;
                    break;
                }

                case 6:
                {
                    iszooming = !iszooming;
                    if (iszooming)
                    {
                        hud.enabled = false;
                        scope.SetActiveRecursively(true);
                        foreach (Camera c in cams)
                        {
                            c.fov = 5.0f;
                        }
                        foreach (MouseLook m in ms)
                        {
                            m.sensitivityX = ssens;
                            m.sensitivityY = (isinv) ? -ssens : ssens;
                        }
                    }
                    else
                    {
                        hud.enabled = true;
                        scope.SetActiveRecursively(false);
                        foreach (Camera c in cams)
                        {
                            c.fov = 60.0f;
                        }
                        foreach (MouseLook m in ms)
                        {
                            m.sensitivityX = msens;
                            m.sensitivityY = (isinv) ? -msens : msens;
                        }
                    }
                    break;
                }
                }
                isdown[3] = true;
            }
        }
        else
        {
            isdown[3] = false;
        }

        if (Input.GetButton("NextTrack"))
        {
            if (!isdown[4])
            {
                mus_tr++;
                if (mus_tr > 3 || mus_tr < 0)
                {
                    mus_tr = 0;
                }
                audio.clip = music_list[mus_tr];
                isdown[4]  = true;
                audio.Play();
                isplaying = true;
            }
        }
        else
        {
            isdown[4] = false;
        }

        if (Input.GetButton("Taunt"))
        {
            if (!isdown[5] && taunt_cooldown == 0)
            {
retry:
                t1 = Random.Range(0, quotes.Length);
                if (t1 == t2)
                {
                    goto retry;
                }
                t2 = t1;
                networkView.RPC("PlayTaunt", RPCMode.All, t1);
                taunt_cooldown = 5;
                isdown[5]      = true;
            }
        }
        else
        {
            isdown[5] = false;
        }

        if (Input.GetButton("Suicide"))
        {
            if (!isdown[6] && sc_cool == 0)
            {
                sc_cool = 30;
                gamecontrol.GetComponent <NetScore>().ServAddScore(
                    gamecontrol.GetComponent <NetworkMenu>().player_name, -1);
                SendDamage(null, 100);
                isdown[6] = true;
            }
        }
        else
        {
            isdown[6] = false;
        }

end:
        if (Input.GetButton("Respawn"))
        {
            if (!isdown[7] && isdead)
            {
                GetComponent <FPSWalkerEnhanced>().ResetFall();
                Transform tmp = gamecontrol.GetComponent <NetworkMenu>().GetSpawn();
                transform.position = tmp.position;
                transform.rotation = tmp.rotation;
                hp = 100;
                hud_hp.ChangeValue(hp, 100);
                CanControlPlayer(true);
                isdead    = false;
                isdown[7] = true;
            }
        }
        else
        {
            isdown[7] = false;
        }

        if (Input.GetButton("HideHud"))
        {
            if (!isdown[8])
            {
                hud_items.GetComponent <HudHide>().HideHud();
                isdown[8] = true;
            }
        }
        else
        {
            isdown[8] = false;
        }

        //Quit warning
        if (Input.GetKey(KeyCode.Escape) && !quit_warning)
        {
            quitmsg.enabled = true;
            quit_warning    = true;
        }
    }
Example #2
0
 public bool GivePickup(int wid, int ammount)
 {
     if (wid < 9)
     {
         if (mammo[wid + 1] < max_ammo[wid + 1])
         {
             if (max_ammo[wid + 1] - mammo[wid + 1] < ammount)
             {
                 if (autoswitch)
                 {
                     FastChangeWeapon(wid + 1);
                 }
                 mammo[wid + 1] += max_ammo[wid + 1] - mammo[wid + 1];
                 gui_mammo.text  = mammo[weaponid].ToString("000");
                 if (cammo[wid + 1] == 0)
                 {
                     mammo[wid + 1] -= (clip_ammo[wid + 1] - cammo[wid + 1]);
                     cammo[wid + 1]  = clip_ammo[wid + 1];
                     gui_cammo.text  = cammo[weaponid].ToString("00");
                     gui_mammo.text  = mammo[weaponid].ToString("000");
                 }
                 gui_ammo.ChangeValue(cammo[weaponid], clip_ammo[weaponid]);
             }
             else if (max_ammo[wid + 1] - mammo[wid + 1] >= ammount)
             {
                 if (autoswitch)
                 {
                     FastChangeWeapon(wid + 1);
                 }
                 mammo[wid + 1] += ammount;
                 gui_mammo.text  = mammo[weaponid].ToString("000");
                 if (cammo[wid + 1] == 0)
                 {
                     mammo[wid + 1] -= (clip_ammo[wid + 1] - cammo[wid + 1]);
                     cammo[wid + 1]  = clip_ammo[wid + 1];
                     gui_cammo.text  = cammo[weaponid].ToString("00");
                     gui_mammo.text  = mammo[weaponid].ToString("000");
                 }
                 gui_ammo.ChangeValue(cammo[weaponid], clip_ammo[weaponid]);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     else
     {
         if (used_grenade)
         {
             used_grenade = false;
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }