Prechádzať zdrojové kódy

adding new wall tiles; adding jump

Justin Gilman 1 rok pred
rodič
commit
24a5b31b76

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
Assets/Main.rogueScene


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
Assets/Prefabs/BarrelMovable.roguePrefab


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
Assets/Prefabs/WallHalfTile.roguePrefab


+ 1 - 0
Assets/Prefabs/WallHalfTile.roguePrefab.meta

@@ -0,0 +1 @@
+{"uuid":"a586c2a5-7ee2-4d74-ad2d-37674dc7ecb5","type":"Prefab"}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
Assets/Prefabs/WallTile.roguePrefab


+ 1 - 0
Assets/Prefabs/WallTile.roguePrefab.meta

@@ -0,0 +1 @@
+{"uuid":"8ad32786-fa37-44f9-ae51-ae4583d1b801","type":"Prefab"}

+ 8 - 0
Assets/rogue_packages/EyeOfMidas/rapier-movement-controller/PlayerPawnInput.re.ts

@@ -50,6 +50,14 @@ export default class PlayerPawnInput extends RE.Component {
       this.movementController.rotateRight = true
       }
     }
+    if (RE.Input.keyboard.getKeyPressed("Space")) {
+      this.movementController.jump = true
+    }
+
+    if (RE.Input.keyboard.getKeyUp("Space")) {
+      this.movementController.jump = false
+      this.movementController.hasJumped = false
+    }
   }
 }
 

+ 18 - 2
Assets/rogue_packages/EyeOfMidas/rapier-movement-controller/RapierMovementController.re.ts

@@ -29,6 +29,9 @@ export default class RapierMovementController extends RE.Component {
   @RE.props.checkbox() autostepIncludeDynamicBodies: boolean = true
 
   @RE.props.num() gravityScale: number = 2
+  @RE.props.num() jumpHeight: number = 5
+  isFalling: boolean = false
+  hasJumped: boolean = false
 
   @RE.props.num() minimumHeight: number = -10
   @RE.props.vector3() resetPosition: THREE.Vector3 = new THREE.Vector3(0,0,0)
@@ -45,6 +48,7 @@ export default class RapierMovementController extends RE.Component {
   @RE.props.checkbox() strafeRight = false
   @RE.props.checkbox() rotateLeft = false
   @RE.props.checkbox() rotateRight = false
+  @RE.props.checkbox() jump = false
 
   config: RapierConfig
 
@@ -121,11 +125,17 @@ export default class RapierMovementController extends RE.Component {
       this.moveRight(1 * this.speed)
     }
 
+    const fixedStep = RE.Runtime.deltaTime
+    if(this.jump && !this.isFalling && !this.hasJumped) {
+      this.velocity.y += (this.jumpHeight * 1000) * fixedStep
+      this.hasJumped = true
+    }
+
     // console.log(this.config)
     this.gravityAcceleration.set(this.config.gravity.x, this.config.gravity.y, this.config.gravity.z)
-    this.velocity.add(this.gravityAcceleration.multiplyScalar(this.gravityScale * RE.Runtime.deltaTime))
+    this.velocity.add(this.gravityAcceleration.multiplyScalar(this.gravityScale * fixedStep))
 
-    const fixedStep = RE.Runtime.deltaTime
+    
     const nextPosition = this.bodyComponent.body.translation()
     const nextVelocity = this.convertRapierToThreeVec3(this.bodyComponent.body.linvel())
 
@@ -150,6 +160,12 @@ export default class RapierMovementController extends RE.Component {
 
     const characterMovement = this.characterController.computedMovement()
 
+    if(this.characterController.computedGrounded()) {
+      this.isFalling = false
+    } else {
+      this.isFalling = true
+    }
+
     nextPosition.x += characterMovement.x
     nextPosition.y += characterMovement.y
     // nextPosition.y = 0

+ 62 - 8
dist/rogue-engine-user-scripts.js

@@ -127,12 +127,23 @@ __webpack_require__.r(__webpack_exports__);
 /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! three */ "three");
 /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(three__WEBPACK_IMPORTED_MODULE_1__);
 var __defProp = Object.defineProperty;
+var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
 var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
+var __decorateClass = (decorators, target, key, kind) => {
+  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
+  for (var i = decorators.length - 1, decorator; i >= 0; i--)
+    if (decorator = decorators[i])
+      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
+  if (kind && result)
+    __defProp(target, key, result);
+  return result;
+};
 
 
 class DirectionalLightShadowFixForMobileCamera extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
   constructor() {
     super(...arguments);
+    this.normalBias = 0.04;
     this.initialOffset = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
     this.currentOffset = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
   }
@@ -146,20 +157,31 @@ class DirectionalLightShadowFixForMobileCamera extends rogue_engine__WEBPACK_IMP
   }
   start() {
     const directionalLight = this.getDirectionalLight();
-    this.initialOffset.copy(directionalLight.position);
-    this.initialOffset.sub(new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0));
-    this.updatePositions();
-    directionalLight.target = this.getCamera();
+    if (this.target) {
+      this.initialOffset.copy(directionalLight.position);
+      this.initialOffset.sub(new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0));
+      directionalLight.target = this.target;
+    } else {
+      this.initialOffset.copy(directionalLight.position);
+      this.initialOffset.sub(new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0));
+      directionalLight.target = this.getCamera();
+    }
     if (directionalLight.shadow) {
-      directionalLight.shadow.normalBias = 0.04;
+      directionalLight.shadow.normalBias = this.normalBias;
     }
+    rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Debug.log(`initial: ${this.initialOffset.x}, ${this.initialOffset.y}, ${this.initialOffset.z}`);
   }
   update() {
     this.updatePositions();
   }
   updatePositions() {
     const directionalLight = this.getDirectionalLight();
-    this.currentOffset.copy(this.initialOffset).add(this.getCamera().position);
+    if (this.target) {
+      this.currentOffset.copy(this.target.position).add(this.initialOffset);
+    } else {
+      this.currentOffset.copy(this.getCamera().position).add(this.initialOffset);
+    }
+    rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Debug.log(`update: ${this.currentOffset.x}, ${this.currentOffset.y}, ${this.currentOffset.z}`);
     directionalLight.position.set(this.currentOffset.x, this.currentOffset.y, this.currentOffset.z);
     if (directionalLight.shadow) {
       directionalLight.shadow.camera.position.set(this.currentOffset.x, this.currentOffset.y, this.currentOffset.z);
@@ -167,6 +189,12 @@ class DirectionalLightShadowFixForMobileCamera extends rogue_engine__WEBPACK_IMP
   }
 }
 __name(DirectionalLightShadowFixForMobileCamera, "DirectionalLightShadowFixForMobileCamera");
+__decorateClass([
+  rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
+], DirectionalLightShadowFixForMobileCamera.prototype, "normalBias", 2);
+__decorateClass([
+  rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.object3d()
+], DirectionalLightShadowFixForMobileCamera.prototype, "target", 2);
 rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(DirectionalLightShadowFixForMobileCamera);
 
 
@@ -289,6 +317,13 @@ class PlayerPawnInput extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Componen
         this.movementController.rotateRight = true;
       }
     }
+    if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("Space")) {
+      this.movementController.jump = true;
+    }
+    if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyUp("Space")) {
+      this.movementController.jump = false;
+      this.movementController.hasJumped = false;
+    }
   }
 }
 __name(PlayerPawnInput, "PlayerPawnInput");
@@ -354,6 +389,9 @@ class RapierMovementController extends rogue_engine__WEBPACK_IMPORTED_MODULE_1__
     this.autostepMinWidth = 0.3;
     this.autostepIncludeDynamicBodies = true;
     this.gravityScale = 2;
+    this.jumpHeight = 5;
+    this.isFalling = false;
+    this.hasJumped = false;
     this.minimumHeight = -10;
     this.resetPosition = new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, 0, 0);
     this.scaledVelocity = new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, 0, 0);
@@ -365,6 +403,7 @@ class RapierMovementController extends rogue_engine__WEBPACK_IMPORTED_MODULE_1__
     this.strafeRight = false;
     this.rotateLeft = false;
     this.rotateRight = false;
+    this.jump = false;
   }
   awake() {
     this.bodyComponent = rogue_engine__WEBPACK_IMPORTED_MODULE_1__.getComponent(_RE_RogueEngine_rogue_rapier_Components_RapierBody_re__WEBPACK_IMPORTED_MODULE_3__["default"], this.object3d);
@@ -409,9 +448,13 @@ class RapierMovementController extends rogue_engine__WEBPACK_IMPORTED_MODULE_1__
     if (this.strafeRight) {
       this.moveRight(1 * this.speed);
     }
-    this.gravityAcceleration.set(this.config.gravity.x, this.config.gravity.y, this.config.gravity.z);
-    this.velocity.add(this.gravityAcceleration.multiplyScalar(this.gravityScale * rogue_engine__WEBPACK_IMPORTED_MODULE_1__.Runtime.deltaTime));
     const fixedStep = rogue_engine__WEBPACK_IMPORTED_MODULE_1__.Runtime.deltaTime;
+    if (this.jump && !this.isFalling && !this.hasJumped) {
+      this.velocity.y += this.jumpHeight * 1e3 * fixedStep;
+      this.hasJumped = true;
+    }
+    this.gravityAcceleration.set(this.config.gravity.x, this.config.gravity.y, this.config.gravity.z);
+    this.velocity.add(this.gravityAcceleration.multiplyScalar(this.gravityScale * fixedStep));
     const nextPosition = this.bodyComponent.body.translation();
     const nextVelocity = this.convertRapierToThreeVec3(this.bodyComponent.body.linvel());
     nextVelocity.x *= 1 - this.drag.x;
@@ -425,6 +468,11 @@ class RapierMovementController extends rogue_engine__WEBPACK_IMPORTED_MODULE_1__
     nextVelocity.z += this.velocity.z;
     this.characterController.computeColliderMovement(this.bodyComponent.body.collider(0), nextVelocity.clone().multiplyScalar(fixedStep));
     const characterMovement = this.characterController.computedMovement();
+    if (this.characterController.computedGrounded()) {
+      this.isFalling = false;
+    } else {
+      this.isFalling = true;
+    }
     nextPosition.x += characterMovement.x;
     nextPosition.y += characterMovement.y;
     nextPosition.z += characterMovement.z;
@@ -538,6 +586,9 @@ __decorateClass([
 __decorateClass([
   rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.num()
 ], RapierMovementController.prototype, "gravityScale", 2);
+__decorateClass([
+  rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.num()
+], RapierMovementController.prototype, "jumpHeight", 2);
 __decorateClass([
   rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.num()
 ], RapierMovementController.prototype, "minimumHeight", 2);
@@ -562,6 +613,9 @@ __decorateClass([
 __decorateClass([
   rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.checkbox()
 ], RapierMovementController.prototype, "rotateRight", 2);
+__decorateClass([
+  rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.checkbox()
+], RapierMovementController.prototype, "jump", 2);
 rogue_engine__WEBPACK_IMPORTED_MODULE_1__.registerComponent(RapierMovementController);
 
 

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
dist/rogue-engine-user-scripts.js.map


Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov