Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Andres agudelo #33

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class GameManager : MonoBehaviour
{
{

public static GameManager Instance { get; private set; }
private void Awake() // singleton stuff. it makes sure this is the only instance of the gamemanager.
{
Expand All @@ -17,6 +19,7 @@ private void Awake() // singleton stuff. it makes sure this is the only instance
{
Instance = this;
}

}
// for info on how to use the gamemanager and what it is for,
// read this: https://gamedevbeginner.com/singletons-in-unity-the-right-way/
Expand All @@ -29,7 +32,7 @@ private void Awake() // singleton stuff. it makes sure this is the only instance
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,54 @@ public class RigidBodyMovement : MonoBehaviour
private Vector3 playerMovementInput;

[Header("Dependencies")]
[SerializeField] private PlayerInput playerInput; // component that handles input
[SerializeField] private Rigidbody playerBody; //reference to player's rigidbody
[SerializeField] private PlayerInput playerInput;
[SerializeField] private Rigidbody playerBody;
public RobotData robotData;

[Space]
[Header("Options")]
[SerializeField] private float basePlayerSpeed; // the base speed, before the specific speed modifiers for each robot
[SerializeField] private float basePlayerSpeed;

[Space]
[Header("Player Settings")]
[SerializeField] private int playerNumber; // Set this in the inspector

private void Start()
{
RespawnPlayer();
}

// Update is called once per frame
void Update()
{
//records the input for the main movement keys
playerMovementInput = playerInput.playerMovementInput;

if (Input.GetKey(KeyCode.X)) // running mode. experimental feature for some extra movement mechanics
{
movePlayer(basePlayerSpeed * 2 * robotData.playerSpeed);
}
else
{
movePlayer(basePlayerSpeed * robotData.playerSpeed);
}
float speedMultiplier = Input.GetKey(KeyCode.X) ? 2f : 1f;
movePlayer(basePlayerSpeed * speedMultiplier * robotData.playerSpeed);
}

//for moving the player
private void movePlayer(float mSpeed)
{
//Vector3 moveVector = transform.TransformDirection(playerMovementInput) * playerSpeed;
//playerBody.velocity = new Vector3(moveVector.x, playerBody.velocity.y, moveVector.z);
Vector3 moveVector = playerMovementInput * mSpeed;
playerBody.velocity = new Vector3(moveVector.x, playerBody.velocity.y, moveVector.z);

if (moveVector != Vector3.zero)
{
playerBody.transform.forward = moveVector; // Changes rotation to match movement direction
playerBody.transform.forward = moveVector;
}
}
//spawns the player at the certain points
public void RespawnPlayer()
{
Transform spawnPoint = SpawnManager.Instance.GetPlayerSpawnPoint(playerNumber);
if(spawnPoint != null)
{
Debug.Log("Spawn Point Found: " + spawnPoint.position);
playerBody.position = spawnPoint.position;
playerBody.rotation = spawnPoint.rotation;
}
else
{
Debug.Log("Spawn Point Not Found");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnManager : MonoBehaviour
{
public static SpawnManager Instance { get; private set; }

public Transform player1SpawnPoint;
public Transform player2SpawnPoint;

private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
}

public Transform GetPlayerSpawnPoint(int playerNumber)
{
Debug.Log("Getting Spawn Point for Player " + playerNumber);

switch (playerNumber)
{
case 1:
Debug.Log("Player 1 Spawn Point: " + player1SpawnPoint.position);
return player1SpawnPoint;
case 2:
Debug.Log("Player 2 Spawn Point: " + player2SpawnPoint.position);
return player2SpawnPoint;
default:
Debug.LogError("Invalid player number");
return null;
}
}

}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnPoint : MonoBehaviour
{
[SerializeField] GameObject graphics;

void Awake()
{
//make it so spawnpoints are invisible
graphics.SetActive(false);
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Spawnpoint
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 0.99296916, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

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

Loading