示例#1
0
    void Update()
    {
        // Set up keycommands for selecting weapon
        // 1 for pistol, 2 for machinegun, 3 for flamethrower.
        // Sets Pistol texture and shoot command to active.
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            currentWeapon = "Pistol";
            inventory.ActiveWeapon(pistol);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            currentWeapon = "MG";
            inventory.ActiveWeapon(mgun);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            currentWeapon = "Flamethrower";
            inventory.ActiveWeapon(flamer);
        }

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            // Shoots pistol
            pistol.Shoot(shot, shotSpawn1, shotSpawn1, shotSpawn2);
            // Shoots machine gun
            mgun.Shoot(shot, MGSpawn, MGSpawn, MGSpawn);
        }
        if (Input.GetKey(KeyCode.Mouse0))
        {
            // Shoots flamethrower
            flamer.Shoot(shot, FTSpawn, FTSpawn2, FTSpawm3);
        }

        if (playerHealth <= 0)
        {
            pAlive = false;
            this.gameObject.SetActive(false);
        }
    }