mirror of
https://github.com/solcloud/Counter-Strike.git
synced 2025-02-22 02:42:51 +01:00
Wip
This commit is contained in:
parent
8d4a3a50f6
commit
5b76b39ead
@ -18,7 +18,9 @@ $socket->write('login ' . $loginCode);
|
||||
while (true) {
|
||||
$response = $socket->read(10241024);
|
||||
if ($command) {
|
||||
$socket->write($command);
|
||||
if ($command !== 'afk') {
|
||||
$socket->write($command);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
54
src/Map/AimMap.php
Normal file
54
src/Map/AimMap.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace cs\Map;
|
||||
|
||||
use cs\Core\Box;
|
||||
use cs\Core\Point;
|
||||
use cs\Core\Setting;
|
||||
use cs\Core\Util;
|
||||
|
||||
class AimMap extends BoxMap
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->addBox(new Box(new Point(), 2000, Setting::playerHeadHeightStand() * 4, 2000));
|
||||
}
|
||||
|
||||
public function getWalls(): array
|
||||
{
|
||||
return $this->getBoxes()[0]->getWalls();
|
||||
}
|
||||
|
||||
public function getFloors(): array
|
||||
{
|
||||
return $this->getBoxes()[0]->getFloors();
|
||||
}
|
||||
|
||||
public function getBuyArea(bool $forAttackers): Box
|
||||
{
|
||||
return $this->getBoxes()[0];
|
||||
}
|
||||
|
||||
public function getSpawnPositionAttacker(): array
|
||||
{
|
||||
return [new Point(rand(950, 1050), 0, rand(950, 1050))];
|
||||
}
|
||||
|
||||
public function getSpawnPositionDefender(): array
|
||||
{
|
||||
[$x, $z] = Util::rotatePointY(rand(0, 359), rand(300, 800), rand(300, 800), 1000, 1000);
|
||||
return [new Point($x, 0, $z)];
|
||||
}
|
||||
|
||||
public function getSpawnRotationAttacker(): int
|
||||
{
|
||||
return rand(0, 359);
|
||||
}
|
||||
|
||||
public function getSpawnRotationDefender(): int
|
||||
{
|
||||
return rand(0, 359);
|
||||
}
|
||||
|
||||
}
|
@ -80,6 +80,7 @@ class UtilTest extends BaseTestCase
|
||||
public function testRotatePointY(): void
|
||||
{
|
||||
$data = [
|
||||
0 => [-45, 32],
|
||||
45 => [-10, 67],
|
||||
65 => [11, 73],
|
||||
149 => [79, 18],
|
||||
@ -90,6 +91,14 @@ class UtilTest extends BaseTestCase
|
||||
foreach ($data as $angle => $xz) {
|
||||
$this->assertSame($xz, Util::rotatePointY($angle, -45, 32, 15, 8));
|
||||
}
|
||||
|
||||
$data = [
|
||||
111 => [830, 2013],
|
||||
];
|
||||
|
||||
foreach ($data as $angle => $xz) {
|
||||
$this->assertSame($xz, Util::rotatePointY($angle, 115, 478, 1000, 1000));
|
||||
}
|
||||
}
|
||||
|
||||
public function testPointToPointDistance(): void
|
||||
|
@ -25,10 +25,15 @@
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
#hud #equipped-item img {
|
||||
#hud #equipped-item img[data-slot] {
|
||||
width: 30vw;
|
||||
}
|
||||
|
||||
#hud #equipped-item img[data-shot] {
|
||||
position: absolute;
|
||||
bottom: -160px;
|
||||
}
|
||||
|
||||
#hud #cross {
|
||||
position: absolute;
|
||||
color: #d31b1b;
|
||||
|
@ -130,7 +130,7 @@ export class Game {
|
||||
}
|
||||
|
||||
attack() {
|
||||
// TODO attack feedback (audiovisual)
|
||||
this.#hud.showShot()
|
||||
}
|
||||
|
||||
equip(slotId) {
|
||||
|
@ -18,6 +18,7 @@ export class HUD {
|
||||
canBuyIcon: null,
|
||||
equippedItem: null,
|
||||
slotModel: null,
|
||||
shotModel: null,
|
||||
inventory: null,
|
||||
money: null,
|
||||
health: null,
|
||||
@ -32,6 +33,7 @@ export class HUD {
|
||||
time: null,
|
||||
killFeed: null,
|
||||
}
|
||||
#shotAnimationInterval = null;
|
||||
#countDownIntervalId = null;
|
||||
#scoreObject = null;
|
||||
#lastBuyMenuPlayerMoney = null;
|
||||
@ -354,6 +356,12 @@ export class HUD {
|
||||
`;
|
||||
}
|
||||
|
||||
showShot() {
|
||||
clearTimeout(this.#shotAnimationInterval)
|
||||
this.#elements.shotModel.classList.remove('hidden');
|
||||
this.#shotAnimationInterval = setTimeout(() => this.#elements.shotModel.classList.add('hidden'), 30)
|
||||
}
|
||||
|
||||
updateHud(player) {
|
||||
this.#updateScoreBoard()
|
||||
const hs = this.#setting
|
||||
@ -399,7 +407,12 @@ export class HUD {
|
||||
|
||||
elementHud.innerHTML = `
|
||||
<div id="cross">✛</div>
|
||||
<div id="equipped-item"><img src="/resources/slot_2.png"></div>
|
||||
<div id="equipped-item">
|
||||
<div style="position:relative">
|
||||
<img data-shot class="hidden" src="/resources/shot.gif">
|
||||
<img data-slot src="/resources/slot_2.png">
|
||||
</div>
|
||||
</div>
|
||||
<div id="scoreboard" class="hidden">
|
||||
<div id="scoreboard-detail"></div>
|
||||
</div>
|
||||
@ -462,7 +475,8 @@ export class HUD {
|
||||
this.#elements.canBuyIcon = elementHud.querySelector('[data-can-buy]')
|
||||
this.#elements.scoreDetail = elementHud.querySelector('#scoreboard-detail')
|
||||
this.#elements.equippedItem = elementHud.querySelector('#equipped-item')
|
||||
this.#elements.slotModel = elementHud.querySelector('#equipped-item img')
|
||||
this.#elements.slotModel = elementHud.querySelector('#equipped-item img[data-slot]')
|
||||
this.#elements.shotModel = elementHud.querySelector('#equipped-item img[data-shot]')
|
||||
this.#elements.inventory = elementHud.querySelector('.inventory')
|
||||
this.#elements.money = elementHud.querySelector('[data-money]')
|
||||
this.#elements.health = elementHud.querySelector('[data-health]')
|
||||
|
@ -64,7 +64,7 @@
|
||||
const modal = document.getElementById('modal')
|
||||
const ui = document.getElementById('ui')
|
||||
const hud = document.getElementById('hud')
|
||||
const validMaps = ['default']
|
||||
const validMaps = ['default', 'aim']
|
||||
const defaultSetting = {
|
||||
prefer_performance: false,
|
||||
fov: 70
|
||||
|
@ -40,7 +40,7 @@ foreach ($map->getBoxes() as $box) {
|
||||
<textarea class="extra">Generating...</textarea>
|
||||
</div>
|
||||
<script>
|
||||
let camera, scene, renderer, controls;
|
||||
let camera, scene, renderer, controls, extra;
|
||||
const worldMaterial = new THREE.MeshLambertMaterial({color: 0x9f998e})
|
||||
const material = new THREE.MeshLambertMaterial({color: 0x664b17})
|
||||
|
||||
@ -72,7 +72,7 @@ foreach ($map->getBoxes() as $box) {
|
||||
function object() {
|
||||
const json = '<?= json_encode($boxes, JSON_THROW_ON_ERROR) ?>';
|
||||
const data = JSON.parse(json);
|
||||
const extra = new THREE.Group()
|
||||
extra = new THREE.Group()
|
||||
extra.name = 'extra'
|
||||
const map = new THREE.Group()
|
||||
map.name = 'map'
|
||||
@ -127,9 +127,6 @@ foreach ($map->getBoxes() as $box) {
|
||||
const d1 = new THREE.DirectionalLight(0xffeac2, 0.6);
|
||||
const a1 = new THREE.AmbientLight(0xDADADA, .8)
|
||||
extra.add(s1, d1, a1, lightTarget, bulb);
|
||||
const ramp1 = createRamp()
|
||||
ramp1.position.z = -80.1
|
||||
extra.add(ramp1)
|
||||
|
||||
scene.add(map, extra)
|
||||
renderer.render(scene, camera);
|
||||
@ -137,6 +134,14 @@ foreach ($map->getBoxes() as $box) {
|
||||
document.querySelector('textarea.extra').innerText = JSON.stringify(extra.toJSON())
|
||||
}
|
||||
|
||||
function extraGeometry() {
|
||||
if (<?= (int)($map::class === Map\DefaultMap::class) ?>) {
|
||||
const ramp1 = createRamp()
|
||||
ramp1.position.z = -80.1
|
||||
extra.add(ramp1)
|
||||
}
|
||||
}
|
||||
|
||||
function spawns() {
|
||||
const spawnMaterialAttackers = new THREE.MeshStandardMaterial({color: 0xFF0000, wireframe: true, transparent: true, opacity: 0.1})
|
||||
const spawnMaterialDefenders = new THREE.MeshStandardMaterial({color: 0x0000FF, wireframe: true, transparent: true, opacity: 0.1})
|
||||
@ -196,6 +201,7 @@ foreach ($map->getBoxes() as $box) {
|
||||
|
||||
init()
|
||||
object()
|
||||
extraGeometry()
|
||||
spawns()
|
||||
buyAreas()
|
||||
animate()
|
||||
|
1
www/resources/map/aim-extra.json
Normal file
1
www/resources/map/aim-extra.json
Normal file
@ -0,0 +1 @@
|
||||
{"metadata":{"version":4.5,"type":"Object","generator":"Object3D.toJSON"},"geometries":[{"uuid":"703f18c2-9eb2-4d40-b4c0-3947a2888c34","type":"SphereGeometry","radius":90,"widthSegments":32,"heightSegments":16,"phiStart":0,"phiLength":6.283185307179586,"thetaStart":0,"thetaLength":3.141592653589793}],"materials":[{"uuid":"6d512917-0c8f-41b6-95e9-9bd73b3b7da9","type":"MeshBasicMaterial","color":16777215,"reflectivity":1,"refractionRatio":0.98,"depthFunc":3,"depthTest":true,"depthWrite":true,"colorWrite":true,"stencilWrite":false,"stencilWriteMask":255,"stencilFunc":519,"stencilRef":0,"stencilFuncMask":255,"stencilFail":7680,"stencilZFail":7680,"stencilZPass":7680}],"object":{"uuid":"69642949-5d62-426c-ad2a-234934d2e04b","type":"Group","name":"extra","layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"children":[{"uuid":"e1da6713-042b-446b-b937-b1a86bb863c6","type":"SpotLight","castShadow":true,"layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,1000,1897.5,-1000,1],"color":16777215,"intensity":0.6,"distance":0,"angle":1.0471975511965976,"decay":1,"penumbra":0,"shadow":{"mapSize":[2048,2048],"camera":{"uuid":"b8fb0623-ce7c-47ff-93c1-16ffc81ef597","type":"PerspectiveCamera","layers":1,"fov":119.99999999999999,"zoom":1,"near":1,"far":7590,"focus":10,"aspect":1,"filmGauge":35,"filmOffset":0}}},{"uuid":"278a025d-0a44-4629-a65b-16babfccee99","type":"DirectionalLight","layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,1],"color":16771778,"intensity":0.6,"shadow":{"camera":{"uuid":"b1796c52-3bba-4a8e-8ace-2d5e33b62ef0","type":"OrthographicCamera","layers":1,"zoom":1,"left":-5,"right":5,"top":5,"bottom":-5,"near":0.5,"far":500}}},{"uuid":"eb18206d-f9b5-4e52-8da4-585a4fdcd102","type":"AmbientLight","layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"color":14342874,"intensity":0.8},{"uuid":"40c82cc7-0354-4759-95c9-a6f2eaac989c","type":"Object3D","name":"light-target","layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,1000,0,-1000,1]},{"uuid":"199c0fb6-b2f6-476e-82dc-b387fe55706b","type":"Mesh","layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,1000,789,-1000,1],"geometry":"703f18c2-9eb2-4d40-b4c0-3947a2888c34","material":"6d512917-0c8f-41b6-95e9-9bd73b3b7da9"}]}}
|
1
www/resources/map/aim.json
Normal file
1
www/resources/map/aim.json
Normal file
@ -0,0 +1 @@
|
||||
{"metadata":{"version":4.5,"type":"Object","generator":"Object3D.toJSON"},"geometries":[{"uuid":"3c71534e-5dba-43e5-bdcf-ecf7826e12e2","type":"BoxGeometry","width":2000,"height":760,"depth":2000,"widthSegments":1,"heightSegments":1,"depthSegments":1}],"materials":[{"uuid":"f2b8edb9-b91a-48b0-9954-9c7cce493d69","type":"MeshLambertMaterial","color":10459534,"emissive":0,"reflectivity":1,"refractionRatio":0.98,"side":1,"depthFunc":3,"depthTest":true,"depthWrite":true,"colorWrite":true,"stencilWrite":false,"stencilWriteMask":255,"stencilFunc":519,"stencilRef":0,"stencilFuncMask":255,"stencilFail":7680,"stencilZFail":7680,"stencilZPass":7680}],"object":{"uuid":"f4c9aa3b-5c2c-4ec9-a943-d889309b1aef","type":"Group","name":"map","layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"children":[{"uuid":"7a2a9995-47d4-460e-a15f-83389ac7514d","type":"Group","name":"center","visible":false,"layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,1000,380,-1000,1]},{"uuid":"6c88b8a9-3cf3-40b3-aa1f-30d4b2b6e202","type":"Mesh","name":"world","receiveShadow":true,"layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,1000,380,-1000,1],"geometry":"3c71534e-5dba-43e5-bdcf-ecf7826e12e2","material":"f2b8edb9-b91a-48b0-9954-9c7cce493d69"}]}}
|
BIN
www/resources/shot.gif
Normal file
BIN
www/resources/shot.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 115 KiB |
Loading…
x
Reference in New Issue
Block a user