Laser Shooter Mod

Allows the player to shoot lasers with a time limit

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Laser Shooter Mod
// @description  Allows the player to shoot lasers with a time limit
// @match        *://*/*
// @version 0.0.1.20230814222938
// @namespace https://greasyfork.org/users/1151605
// ==/UserScript==

(function() {
    'use strict';

    const TIME_LIMIT = 60; // Time limit in seconds
    let remainingTime = TIME_LIMIT;
    let isShooting = false;

    console.log("Hold 'O' to shoot lasers!");

    function startShootingLasersOnHold() {
        document.addEventListener('keydown', function(event) {
            if (event.key === 'o' || event.key === 'O') {
                isShooting = true;
                console.log("Shooting lasers!");
            }
        });

        document.addEventListener('keyup', function(event) {
            if (event.key === 'o' || event.key === 'O') {
                isShooting = false;
                console.log("Stopped shooting lasers!");
            }
        });
    }

    function stopShootingLasers() {
        console.log("Time's up! Stop shooting lasers!");
        isShooting = false;
    }

    // Call this function when the player dies
    function playerDied() {
        console.log("Player died! Cannot shoot lasers anymore.");
    }

    // Start shooting lasers when holding 'O'
    startShootingLasersOnHold();

    // Run the game for the specified time limit
    setTimeout(function() {
        stopShootingLasers();
    }, TIME_LIMIT * 1000);

})();