Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
556 changes: 466 additions & 90 deletions Assets/Scenes/GameTest.unity

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions Assets/Scripts/GameTest/BottomScreenTextScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using UnityEngine;

public class BottomScreenTextScript : MonoBehaviour
{
bool frameTextSet;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}

// Update is called once per frame
void Update()
{
if(!frameTextSet)
GetComponent<TMPro.TextMeshProUGUI>().text = "";
else
frameTextSet = false;
}

public void SetText(string text)
{
GetComponent<TMPro.TextMeshProUGUI>().text = text;
frameTextSet = true;
}
}
2 changes: 2 additions & 0 deletions Assets/Scripts/GameTest/BottomScreenTextScript.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions Assets/Scripts/GameTest/CameraMain.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using UnityEngine;

public static class CameraMain
{
static public GameObject mainCamera;

static CameraMain()
{
GameObject[] cameraObjects = GameObject.FindGameObjectsWithTag("MainCamera");
mainCamera = cameraObjects[0];
}

static public void ShowObj(RGScriptedObject o, Vector3 camOffset, Vector3 targetOffset, bool follow)
{
mainCamera.transform.SetParent(null);
Vector3 objectPos = o.transform.position;
mainCamera.transform.position = objectPos+camOffset;
mainCamera.transform.LookAt(objectPos+targetOffset);

Debug.Log($"ShowObj pos: {objectPos}+{camOffset} = {objectPos+camOffset}; LA:{objectPos}+{targetOffset} = {objectPos+targetOffset}");

// if follow = true parent camera to object
// might not be accurate, attr 45 camera_move is not set on cyrus, but camera follows him anyways
if(follow)
{
mainCamera.transform.SetParent(o.transform);
}

}
}
2 changes: 2 additions & 0 deletions Assets/Scripts/GameTest/CameraMain.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 6 additions & 16 deletions Assets/Scripts/GameTest/LoadWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,12 @@ void Update()
{
if(true)
{
/*
ModelLoader.scriptedObjects[0x82BDF408].allowScripting = true; // OB_PLT04
ModelLoader.scriptedObjects[0x82BDBC58].allowScripting = true; // OB_PLT07
ModelLoader.scriptedObjects[0x82BDB598].allowScripting = true; // OB_PLT05
ModelLoader.scriptedObjects[0x82BDB9F0].allowScripting = true; // OB_PLT06
ModelLoader.scriptedObjects[0x82BDE3C0].allowScripting = true; // OB_PLT03
ModelLoader.scriptedObjects[0x82BDE968].allowScripting = true; // OB_PLT02
ModelLoader.scriptedObjects[0x82BDEAD8].allowScripting = true; // OB_PLT01
ModelLoader.scriptedObjects[0x82BDF098].allowScripting = true; // OB_PLT08
ModelLoader.scriptedObjects[0x82BE2D08].allowScripting = true; // OB_PLT00
*/
ModelLoader.scriptedObjects[0x82BDA9B0].allowScripting = true; // OB_STEPR
ModelLoader.scriptedObjects[0x82BDCE60].allowScripting = true; // OB_STEP2
ModelLoader.scriptedObjects[0x82BDCF98].allowScripting = true; // OB_STEP1
// ModelLoader.scriptedObjects[0x82BD9E40].allowScripting = true; // EXTOBSRV
ModelLoader.scriptedObjects[0x82BDA6A0].allowScripting = true; // OB_ENG21
ModelLoader.scriptedObjects[0x82BDA330].allowScripting = true; // OB_DOR02
ModelLoader.scriptedObjects[0x82BDA470].allowScripting = true; // OB_DOR01
}
if(true)
if(false)
{
// ModelLoader.scriptedObjects[0x82BD3750].allowScripting = true; // X
// ModelLoader.scriptedObjects[0x82BD9D00].allowScripting = true; // X
Expand All @@ -91,7 +81,7 @@ void Update()
// ModelLoader.scriptedObjects[0x82BE7CA0].allowScripting = true; // OB_ERS10
// ModelLoader.scriptedObjects[0x82BDBC58].allowScripting = true; // OB_PLT07
// ModelLoader.scriptedObjects[0x82BDBD98].allowScripting = true; // ERASMO
// ModelLoader.scriptedObjects[0x82BDBF70].allowScripting = true; // OB_GEAR
ModelLoader.scriptedObjects[0x82BDBF70].allowScripting = true; // OB_GEAR
// ModelLoader.scriptedObjects[0x82BDC140].allowScripting = true; // OB_ENG03
// ModelLoader.scriptedObjects[0x82BDC378].allowScripting = true; // OB_PIPE
// ModelLoader.scriptedObjects[0x82BDE730].allowScripting = true; // GEARSND
Expand Down
19 changes: 19 additions & 0 deletions Assets/Scripts/GameTest/MainUIScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using UnityEngine;

public static class MainUIScript
{
static BottomScreenTextScript bottomScreenText;

static MainUIScript()
{
GameObject[] textObjects = GameObject.FindGameObjectsWithTag("BottomScreenText");
bottomScreenText = textObjects[0].GetComponent<BottomScreenTextScript >();
}

static public void SetActivateText(string text)
{
// TODO: don't set when RTX subtitle are shown (?)
bottomScreenText.SetText(text);
}
}
2 changes: 2 additions & 0 deletions Assets/Scripts/GameTest/MainUIScript.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 27 additions & 27 deletions Assets/Scripts/GameTest/PlayerMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class PlayerMain: MonoBehaviour
{
[SerializeField] private CharacterController cc;
[SerializeField] private PlayerMovementConfig config;
[SerializeField] private InputData input;

// General CC properties
private PlayerMovementStates _currentMovementState = PlayerMovementStates.Walking;
Expand Down Expand Up @@ -48,16 +47,16 @@ private void FixedUpdate()
_currentMovementState = PlayerMovementStates.Airborne;
}

if (input.jump
if (Game.Input.jump
&& _currentMovementState == PlayerMovementStates.Walking)
{
input.jump = false;
Game.Input.jump = false;
_currentMovementState = PlayerMovementStates.Airborne;
Jump();
}
else if (input.jump)
else if (Game.Input.jump)
{
input.jump = false;
Game.Input.jump = false;
}

if (_isGrounded
Expand Down Expand Up @@ -93,7 +92,7 @@ private void FixedUpdate()
}

if (_currentMovementState == PlayerMovementStates.Climbing
&& input.dropDown)
&& Game.Input.dropDown)
{
_currentMovementState = PlayerMovementStates.Walking;
_velocity = Vector3.zero;
Expand All @@ -102,7 +101,7 @@ private void FixedUpdate()
// OR shorten the ledge detection ray.
}
else if (_currentMovementState == PlayerMovementStates.Climbing
&& input.climbUp)
&& Game.Input.climbUp)
{
PullUpLedge();
// Todo: Check if the player has enough space to climb up
Expand Down Expand Up @@ -145,22 +144,22 @@ private void WalkMode()
//Debug.DrawRay(transform.position + Vector3.down, _forwardOnSurface, Color.yellow);

// Movement when moveModifier is pressed / is true
if (input.moveModifier)
if (Game.Input.moveModifier)
{
if (input.move.y != 0)
if (Game.Input.move.y != 0)
{
// Walk forward or backwards
_velocity = _forwardOnSurface * (input.move.y * config.walkSpeed / 60);
_velocity = _forwardOnSurface * (Game.Input.move.y * config.walkSpeed / 60);

// Turn the player
float yRotation = input.move.x * config.turnSpeed * Time.deltaTime * 60;
float yRotation = Game.Input.move.x * config.turnSpeed * Time.deltaTime * 60;
transform.Rotate(0, yRotation, 0);
}
else if (input.move.x != 0
&& input.move.y == 0)
else if (Game.Input.move.x != 0
&& Game.Input.move.y == 0)
{
// Strafe left or right
_velocity = _rightOnSurface * (input.move.x * config.walkSpeed / 60);
_velocity = _rightOnSurface * (Game.Input.move.x * config.walkSpeed / 60);
}
else
{
Expand All @@ -171,22 +170,22 @@ private void WalkMode()
else
{
// Run Forward
if (input.move.y > 0)
if (Game.Input.move.y > 0)
{
_velocity = _forwardOnSurface * (input.move.y * config.runSpeed / 60);
_velocity = _forwardOnSurface * (Game.Input.move.y * config.runSpeed / 60);
}
// Walk backwards
else if (input.move.y < 0)
else if (Game.Input.move.y < 0)
{
_velocity = _forwardOnSurface * (input.move.y * config.walkSpeed / 60);
_velocity = _forwardOnSurface * (Game.Input.move.y * config.walkSpeed / 60);
}
else
{
_velocity = Vector3.zero;
}

// Turn the player
float yRotation = input.move.x * config.turnSpeed * Time.deltaTime * 60;
float yRotation = Game.Input.move.x * config.turnSpeed * Time.deltaTime * 60;
transform.Rotate(0, yRotation, 0);
}

Expand Down Expand Up @@ -235,17 +234,17 @@ private void ClimbMode()
Vector3 wallRight = Vector3.Cross(transform.up, -_ledgeWallNormal);

// Move on ledge
if (input.move.x > 0 && CanClimbRight())
if (Game.Input.move.x > 0 && CanClimbRight())
{
_velocity = wallRight - _ledgeWallNormal;
}
else if (input.move.x < 0 && CanClimbLeft())
else if (Game.Input.move.x < 0 && CanClimbLeft())
{
_velocity = -wallRight - _ledgeWallNormal;
}

// Keep the value positive and also hammer it towards full numbers
float moveDir = Mathf.Sign(Mathf.Abs(input.move.x));
float moveDir = Mathf.Sign(Mathf.Abs(Game.Input.move.x));
_velocity *= moveDir * 0.0334f * config.ledgeStrafeSpeed;
}

Expand All @@ -270,7 +269,7 @@ private void SlideMode()
private void HandleStepOffset()
{
float distance = cc.radius + cc.skinWidth + config.rayDistance;
Vector3 targetDirection = _forwardOnSurface * input.move.y + transform.right * input.move.x;
Vector3 targetDirection = _forwardOnSurface * Game.Input.move.y + transform.right * Game.Input.move.x;

//Raycast at player's ground level in direction of movement
bool bottomRaycast = Physics.Raycast(_playerRootPosition, targetDirection, out _, distance);
Expand Down Expand Up @@ -306,15 +305,15 @@ private void Jump()
return;
}

if (input.move.y > 0
if (Game.Input.move.y > 0
&& _speed > config.longJumpThreshold)
{
// Long forward jump
_velocity = _forwardOnSurface * config.longJumpDistance / 10;
_velocity.y = config.jumpHeight / 10;
_isGrounded = false;
}
else if (input.move.y > 0
else if (Game.Input.move.y > 0
&& _speed > config.shortJumpThreshold)
{
// Short forward jump
Expand All @@ -338,8 +337,9 @@ private void GroundCheck()
Vector3 surfaceDownhillRay = default;

float castRadius = 0.34f;
float castDistance = cc.height/2-(castRadius-0.14f);

float castDistance = cc.height / 2 - (castRadius - 0.14f);
//Debug.DrawRay(transform.position, new Vector3(0, (castDistance + castRadius)*-1, 0), Color.darkOrange);

if (Physics.SphereCast(transform.position, castRadius, Vector3.down, out RaycastHit sphereHit, castDistance, config.groundLayers))
{
_isGrounded = true;
Expand Down
3 changes: 3 additions & 0 deletions Assets/Scripts/RGFileImport/RGMData/RGObjectStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,15 @@ public static RGScriptedObject GetPlayer()
{
return player;
}

public static void SetCamera(RGScriptedObject newCamera)
{
GameObject[] cameraObjects = GameObject.FindGameObjectsWithTag("MainCamera");
camera = newCamera;
}
public static RGScriptedObject GetCamera()
{
//return CameraMain.mainCamera;
return camera;
}

Expand Down
Loading