mirror of
https://github.com/solcloud/Counter-Strike.git
synced 2025-01-17 06:38:16 +01:00
Tuning
This commit is contained in:
parent
2c02de8af1
commit
c5918e851b
@ -1,6 +1,6 @@
|
|||||||
import {EventProcessor} from "./EventProcessor.js";
|
import {EventProcessor} from "./EventProcessor.js";
|
||||||
import {Player} from "./Player.js";
|
import {Player} from "./Player.js";
|
||||||
import {InventorySlot, ItemId, SoundType} from "./Enums.js";
|
import {InventorySlot, SoundType} from "./Enums.js";
|
||||||
import {SoundRepository} from "./SoundRepository.js";
|
import {SoundRepository} from "./SoundRepository.js";
|
||||||
|
|
||||||
export class Game {
|
export class Game {
|
||||||
@ -21,9 +21,15 @@ export class Game {
|
|||||||
#hudDebounceTicks = 1
|
#hudDebounceTicks = 1
|
||||||
#bombTimerId = null;
|
#bombTimerId = null;
|
||||||
#eventProcessor
|
#eventProcessor
|
||||||
#dropItems = [];
|
#dropItems = {};
|
||||||
#throwables = [];
|
#throwables = {};
|
||||||
#roundIntervalIds = [];
|
#roundIntervalIds = [];
|
||||||
|
#playerSlotsVisibleModels = [
|
||||||
|
InventorySlot.SLOT_KNIFE, InventorySlot.SLOT_PRIMARY, InventorySlot.SLOT_SECONDARY,
|
||||||
|
InventorySlot.SLOT_BOMB, InventorySlot.SLOT_GRENADE_DECOY, InventorySlot.SLOT_GRENADE_MOLOTOV,
|
||||||
|
InventorySlot.SLOT_GRENADE_SMOKE, InventorySlot.SLOT_GRENADE_FLASH, InventorySlot.SLOT_GRENADE_HE,
|
||||||
|
InventorySlot.SLOT_TASER, InventorySlot.SLOT_KIT,
|
||||||
|
]
|
||||||
score = null
|
score = null
|
||||||
bombDropPosition = null
|
bombDropPosition = null
|
||||||
alivePlayers = [0, 0]
|
alivePlayers = [0, 0]
|
||||||
@ -31,19 +37,6 @@ export class Game {
|
|||||||
players = []
|
players = []
|
||||||
playerMe = null
|
playerMe = null
|
||||||
playerSpectate = null
|
playerSpectate = null
|
||||||
#playerSlotsVisibleModels = [
|
|
||||||
InventorySlot.SLOT_KNIFE,
|
|
||||||
InventorySlot.SLOT_PRIMARY,
|
|
||||||
InventorySlot.SLOT_SECONDARY,
|
|
||||||
InventorySlot.SLOT_BOMB,
|
|
||||||
InventorySlot.SLOT_GRENADE_DECOY,
|
|
||||||
InventorySlot.SLOT_GRENADE_MOLOTOV,
|
|
||||||
InventorySlot.SLOT_GRENADE_SMOKE,
|
|
||||||
InventorySlot.SLOT_GRENADE_FLASH,
|
|
||||||
InventorySlot.SLOT_GRENADE_HE,
|
|
||||||
InventorySlot.SLOT_TASER,
|
|
||||||
InventorySlot.SLOT_KIT,
|
|
||||||
]
|
|
||||||
|
|
||||||
constructor(world, hud, stats) {
|
constructor(world, hud, stats) {
|
||||||
this.#world = world
|
this.#world = world
|
||||||
@ -53,17 +46,19 @@ export class Game {
|
|||||||
this.#soundRepository = new SoundRepository((...args) => world.playSound(...args))
|
this.#soundRepository = new SoundRepository((...args) => world.playSound(...args))
|
||||||
}
|
}
|
||||||
|
|
||||||
pause(msg, score, timeMs) {
|
#roundReset() {
|
||||||
this.#paused = true
|
|
||||||
console.log("Pause: " + msg + " for " + timeMs + "ms")
|
|
||||||
clearInterval(this.#bombTimerId)
|
clearInterval(this.#bombTimerId)
|
||||||
this.#roundIntervalIds.forEach((id) => clearInterval(id))
|
this.#roundIntervalIds.forEach((id) => clearInterval(id))
|
||||||
this.#roundIntervalIds = []
|
this.#roundIntervalIds = []
|
||||||
Object.keys(this.#dropItems).forEach((id) => this.itemPickUp(id))
|
Object.keys(this.#dropItems).forEach((id) => this.itemPickUp(id))
|
||||||
this.#dropItems = []
|
|
||||||
Object.keys(this.#throwables).forEach((id) => this.removeGrenade(id))
|
Object.keys(this.#throwables).forEach((id) => this.removeGrenade(id))
|
||||||
this.#throwables = []
|
|
||||||
this.#world.reset()
|
this.#world.reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
pause(msg, score, timeMs) {
|
||||||
|
this.#paused = true
|
||||||
|
console.log("Pause: " + msg + " for " + timeMs + "ms")
|
||||||
|
this.#roundReset()
|
||||||
|
|
||||||
const game = this
|
const game = this
|
||||||
this.players.forEach(function (player) {
|
this.players.forEach(function (player) {
|
||||||
@ -175,9 +170,6 @@ export class Game {
|
|||||||
this.playerHit(data, true)
|
this.playerHit(data, true)
|
||||||
}
|
}
|
||||||
if (data.type === SoundType.ITEM_PICKUP) {
|
if (data.type === SoundType.ITEM_PICKUP) {
|
||||||
if (data.item.id === ItemId.Bomb && spectatorId === data.player) {
|
|
||||||
this.#dropItems[data.extra.id].visible = false
|
|
||||||
}
|
|
||||||
this.itemPickUp(data.extra.id)
|
this.itemPickUp(data.extra.id)
|
||||||
}
|
}
|
||||||
if (data.type === SoundType.ITEM_DROP_AIR) {
|
if (data.type === SoundType.ITEM_DROP_AIR) {
|
||||||
|
@ -225,7 +225,7 @@ export class HUD {
|
|||||||
if (player.ammo === null) {
|
if (player.ammo === null) {
|
||||||
this.#elements.ammo.innerText = Enum.ItemIdToName[player.item.id]
|
this.#elements.ammo.innerText = Enum.ItemIdToName[player.item.id]
|
||||||
} else {
|
} else {
|
||||||
this.#elements.ammo.innerText = `${Enum.ItemIdToName[player.item.id]} \u00a0 ${player.ammo} / ${player.ammoReserve}`
|
this.#elements.ammo.innerText = `${Enum.ItemIdToName[player.item.id]} \u00a0 ${player.ammo} / ${player.ammoReserve}`
|
||||||
}
|
}
|
||||||
|
|
||||||
let myTeamIndex = this.#game.playerMe.getTeamIndex()
|
let myTeamIndex = this.#game.playerMe.getTeamIndex()
|
||||||
|
@ -2,7 +2,6 @@ import {ItemId} from "./Enums.js";
|
|||||||
|
|
||||||
export class ModelRepository {
|
export class ModelRepository {
|
||||||
#gltfLoader
|
#gltfLoader
|
||||||
#objectLoader
|
|
||||||
#textureLoader
|
#textureLoader
|
||||||
#models = {}
|
#models = {}
|
||||||
#meshes = {}
|
#meshes = {}
|
||||||
@ -18,9 +17,7 @@ export class ModelRepository {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.#gltfLoader = new THREE.GLTFLoader()
|
this.#gltfLoader = new THREE.GLTFLoader()
|
||||||
this.#objectLoader = new THREE.ObjectLoader()
|
|
||||||
this.#textureLoader = new THREE.TextureLoader()
|
this.#textureLoader = new THREE.TextureLoader()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#loadModel(url) {
|
#loadModel(url) {
|
||||||
|
@ -21,6 +21,7 @@ export class World {
|
|||||||
|
|
||||||
init(mapName, setting) {
|
init(mapName, setting) {
|
||||||
const scene = new THREE.Scene()
|
const scene = new THREE.Scene()
|
||||||
|
scene.name = 'MainScene'
|
||||||
scene.background = new THREE.Color(0xdadada)
|
scene.background = new THREE.Color(0xdadada)
|
||||||
|
|
||||||
const promises = []
|
const promises = []
|
||||||
@ -204,13 +205,16 @@ export class World {
|
|||||||
reset() {
|
reset() {
|
||||||
this.clearDecals()
|
this.clearDecals()
|
||||||
const bomb = this.#modelRepository.getBomb()
|
const bomb = this.#modelRepository.getBomb()
|
||||||
if (bomb.parent && bomb.parent.type === 'Scene') {
|
if (bomb.parent && bomb.parent.name === 'MainScene') {
|
||||||
bomb.visible = false
|
bomb.visible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyObject(object) {
|
destroyObject(object) {
|
||||||
if (object.name === `item-${Enum.ItemId.Bomb}`) {
|
if (object.name === `item-${Enum.ItemId.Bomb}`) {
|
||||||
|
if (object.parent && object.parent.name === 'MainScene') {
|
||||||
|
object.visible = false
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user