Browse Source

race game working

combinedRaceAndNameDropper
Josh 2 years ago
parent
commit
5b0077eb1f
  1. 11
      namedropper/Assets/Bouncy Physics Material 2D.physicsMaterial2D
  2. 8
      namedropper/Assets/Bouncy Physics Material 2D.physicsMaterial2D.meta
  3. 24
      namedropper/Assets/RaceGame.cs
  4. 11
      namedropper/Assets/RaceGame.cs.meta
  5. 7674
      namedropper/Assets/Scenes/RaceGame.unity
  6. 7
      namedropper/Assets/Scenes/RaceGame.unity.meta
  7. 67
      namedropper/Assets/Scripts/Game.cs
  8. 84
      namedropper/Assets/Scripts/Level.cs
  9. 20
      namedropper/Assets/Scripts/Player.cs
  10. 5
      namedropper/Assets/Scripts/Wraparound.cs
  11. BIN
      namedropper/Assets/Sprites/racetrack.png
  12. 123
      namedropper/Assets/Sprites/racetrack.png.meta
  13. 2
      namedropper/Assets/_FortuneWheel/Scripts/FortuneWheel.cs
  14. 4
      namedropper/ProjectSettings/TagManager.asset
  15. BIN
      original art assets/racetrack.psd

11
namedropper/Assets/Bouncy Physics Material 2D.physicsMaterial2D

@ -0,0 +1,11 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!62 &6200000
PhysicsMaterial2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Bouncy Physics Material 2D
friction: 0
bounciness: 1

8
namedropper/Assets/Bouncy Physics Material 2D.physicsMaterial2D.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 42358f80d05f59e4580d671c0a7dcb88
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 6200000
userData:
assetBundleName:
assetBundleVariant:

24
namedropper/Assets/RaceGame.cs

@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RaceGame : Level
{
// Start is called before the first frame update
void Start()
{
Physics2D.gravity = Vector2.zero;
base.Start();
}
private void Awake()
{
base.Awake();
}
// Update is called once per frame
void Update()
{
}
}

11
namedropper/Assets/RaceGame.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2ec43f1418f7a064b9c23ec953e222a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

7674
namedropper/Assets/Scenes/RaceGame.unity

File diff suppressed because it is too large

7
namedropper/Assets/Scenes/RaceGame.unity.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4b27426029785474c988419c9328a8ba
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

67
namedropper/Assets/Scripts/Game.cs

@ -9,14 +9,12 @@ public class Game : Level
public const bool USE_MVP = true; public const bool USE_MVP = true;
public const bool USE_UNLOCK = true; public const bool USE_UNLOCK = true;
const bool HIDE_SCORES = true; const bool HIDE_SCORES = true;
int _seconds = 70;
[SerializeField] Text Score1; [SerializeField] Text Score1;
[SerializeField] Text Score2; [SerializeField] Text Score2;
[SerializeField] Text Score3; [SerializeField] Text Score3;
[SerializeField] Text Score4; [SerializeField] Text Score4;
[SerializeField] Text Timer;
[SerializeField] Text RoundNumber;
[SerializeField] Text Topic; [SerializeField] Text Topic;
[SerializeField] GameObject CategoriesRound1; [SerializeField] GameObject CategoriesRound1;
@ -28,36 +26,30 @@ public class Game : Level
Category[] _categories; Category[] _categories;
int _originalFontSize;
static bool _paused = false;
[SerializeField] Canvas _canvas; [SerializeField] Canvas _canvas;
[SerializeField] GameObject _powerupPrefab; [SerializeField] GameObject _powerupPrefab;
public static bool Paused { get => _paused; set => _paused = value; }
// Start is called before the first frame update // Start is called before the first frame update
void Awake() void Awake()
{ {
Physics2D.gravity = new Vector2(0f, -4f);
base.Awake(); base.Awake();
if (GameManager.Instance.Round == 1) if (GameManager.Instance.Round == 1)
{ {
CategoriesRound1.SetActive(true); CategoriesRound1.SetActive(true);
_seconds = 35;
} }
else if (GameManager.Instance.Round == 2) else if (GameManager.Instance.Round == 2)
{ {
CategoriesRound2.SetActive(true); CategoriesRound2.SetActive(true);
_seconds = 40;
} }
else if (GameManager.Instance.Round == 3) else if (GameManager.Instance.Round == 3)
{ {
CategoriesRound3.SetActive(true); CategoriesRound3.SetActive(true);
_seconds = 45;
} }
_originalFontSize = Timer.fontSize;
_categories = FindObjectsOfType<Category>(); _categories = FindObjectsOfType<Category>();
//set the topic for testing purposes in case I start directly from this scene //set the topic for testing purposes in case I start directly from this scene
@ -74,7 +66,6 @@ public class Game : Level
category.Elements = categoryData.Elements; category.Elements = categoryData.Elements;
category.ResetElements(); category.ResetElements();
} }
StartCoroutine(Countdown());
if (GameManager.Instance.NumTeams == 1) if (GameManager.Instance.NumTeams == 1)
@ -116,7 +107,7 @@ public class Game : Level
} }
} }
RoundNumber.text = GameManager.Instance.GetRoundName();
Topic.text = GameDataManager.Instance.CurrentTopic.Topic; Topic.text = GameDataManager.Instance.CurrentTopic.Topic;
StartCoroutine("StartupProcess"); StartCoroutine("StartupProcess");
@ -162,46 +153,7 @@ public class Game : Level
} }
IEnumerator Countdown()
{
while (_seconds > 0)
{
_seconds--;
Timer.text = _seconds.ToString();
if (_seconds < 10)
{
Timer.color = Color.red;
Timer.fontSize = _originalFontSize + 50;
}
yield return new WaitForSeconds(1f);
}
Timer.text = "TIME'S UP!";
Timer.fontSize = _originalFontSize + 70;
Paused = true;
yield return new WaitForSeconds(2.5f);
Paused = false;
NextRound();
}
void NextRound()
{
GameManager.Instance.Round++;
if (GameManager.Instance.Round > 3)
{
SceneManager.LoadScene("GameOver");
}
else if (GameManager.Instance.Round == 3)
{
SceneManager.LoadScene("ChallengingStage");
}
else
{
SceneManager.LoadScene("TopicSelect");
}
}
private void Start() private void Start()
{ {
@ -261,14 +213,8 @@ public class Game : Level
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if (Input.GetKeyDown(KeyCode.F10)) base.Update();
{ /*
_seconds-=5;
}
if (Input.GetKeyDown(KeyCode.F12))
{
NextRound();
}
if (Input.GetKeyDown(KeyCode.F11)) if (Input.GetKeyDown(KeyCode.F11))
{ {
GameManager.PLAYER_SKIN++; GameManager.PLAYER_SKIN++;
@ -278,5 +224,6 @@ public class Game : Level
} }
GameManager.Instance.RestartGame(); GameManager.Instance.RestartGame();
} }
*/
} }
} }

84
namedropper/Assets/Scripts/Level.cs

@ -2,29 +2,62 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Level : MonoBehaviour public class Level : MonoBehaviour
{ {
public List<GameObject> _players; public List<GameObject> _players;
ScoreStack _blueScoreStack; ScoreStack _blueScoreStack;
ScoreStack _redScoreStack; ScoreStack _redScoreStack;
[SerializeField] protected Text Timer;
[SerializeField] protected Text RoundNumber;
int _originalFontSize;
int _seconds = 70;
static bool _paused = false;
public static bool Paused { get => _paused; set => _paused = value; }
// Start is called before the first frame update // Start is called before the first frame update
void Start() public void Start()
{ {
} }
public void Awake() public void Awake()
{ {
_blueScoreStack = GameObject.Find("/ScoreStackBlue").GetComponent<ScoreStack>(); RoundNumber.text = GameManager.Instance.GetRoundName();
_redScoreStack = GameObject.Find("/ScoreStackRed").GetComponent<ScoreStack>(); _blueScoreStack = GameObject.Find("/ScoreStackBlue")?.GetComponent<ScoreStack>();
_redScoreStack = GameObject.Find("/ScoreStackRed")?.GetComponent<ScoreStack>();
_originalFontSize = Timer.fontSize;
if (GameManager.Instance.Round == 1)
{
_seconds = 35;
}
else if (GameManager.Instance.Round == 2)
{
_seconds = 40;
}
else if (GameManager.Instance.Round == 3)
{
_seconds = 45;
}
StartCoroutine(Countdown());
} }
// Update is called once per frame // Update is called once per frame
void Update() public void Update()
{ {
if (Input.GetKeyDown(KeyCode.F10))
{
_seconds -= 5;
}
if (Input.GetKeyDown(KeyCode.F12))
{
NextRound();
}
} }
protected void ActivatePlayers(bool value) protected void ActivatePlayers(bool value)
@ -87,4 +120,45 @@ public class Level : MonoBehaviour
//UpdateScores(); //UpdateScores();
} }
IEnumerator Countdown()
{
while (_seconds > 0)
{
_seconds--;
Timer.text = _seconds.ToString();
if (_seconds < 10)
{
Timer.color = Color.red;
Timer.fontSize = _originalFontSize + 50;
}
yield return new WaitForSeconds(1f);
}
Timer.text = "TIME'S UP!";
Timer.fontSize = _originalFontSize + 70;
Paused = true;
yield return new WaitForSeconds(2.5f);
Paused = false;
NextRound();
}
void NextRound()
{
GameManager.Instance.Round++;
if (GameManager.Instance.Round > 3)
{
SceneManager.LoadScene("GameOver");
}
else if (GameManager.Instance.Round == 3)
{
SceneManager.LoadScene("ChallengingStage");
}
else
{
SceneManager.LoadScene("TopicSelect");
}
}
} }

20
namedropper/Assets/Scripts/Player.cs

@ -47,6 +47,8 @@ public class Player : MonoBehaviour
} }
public Rigidbody2D _rigidbody; public Rigidbody2D _rigidbody;
private bool _touchedMidpoint;
private RaceGame _raceGame;
private void Awake() private void Awake()
{ {
@ -65,6 +67,7 @@ public class Player : MonoBehaviour
_text = transform.GetChild(0).GetComponent<TMPro.TextMeshProUGUI>(); _text = transform.GetChild(0).GetComponent<TMPro.TextMeshProUGUI>();
_originalTextScale = _text.transform.localScale; _originalTextScale = _text.transform.localScale;
_game = FindObjectOfType<Game>(); _game = FindObjectOfType<Game>();
_raceGame = FindObjectOfType<RaceGame>();
_originalPosition = transform.position; _originalPosition = transform.position;
@ -346,6 +349,23 @@ public class Player : MonoBehaviour
} }
//RACE GAME
//midpoint
if (collision.gameObject.CompareTag("Midpoint"))
{
_touchedMidpoint = true;
}
//finish line
if (collision.gameObject.CompareTag("FinishLine"))
{
if (_touchedMidpoint)
{
Debug.Log("scored!");
_raceGame.AddScore(1, _playerNumber);
}
_touchedMidpoint = false;
}
} }

5
namedropper/Assets/Scripts/Wraparound.cs

@ -26,6 +26,11 @@ public class Wraparound : MonoBehaviour
} }
if (SceneManager.GetActiveScene().name == "RaceGame")
{
return;
}
if (SceneManager.GetActiveScene().name == "TopicSelect" || SceneManager.GetActiveScene().name == "Calibration" || SceneManager.GetActiveScene().name == "Title" || SceneManager.GetActiveScene().name == "GameOver" || SceneManager.GetActiveScene().name == "ChallengingStage") if (SceneManager.GetActiveScene().name == "TopicSelect" || SceneManager.GetActiveScene().name == "Calibration" || SceneManager.GetActiveScene().name == "Title" || SceneManager.GetActiveScene().name == "GameOver" || SceneManager.GetActiveScene().name == "ChallengingStage")
{ {
if (this.transform.position.x < 0) if (this.transform.position.x < 0)

BIN
namedropper/Assets/Sprites/racetrack.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

123
namedropper/Assets/Sprites/racetrack.png.meta

@ -0,0 +1,123 @@
fileFormatVersion: 2
guid: 6a5bea06084896543ad84ad8023b0a31
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

2
namedropper/Assets/_FortuneWheel/Scripts/FortuneWheel.cs

@ -160,7 +160,7 @@
} }
else if (_gameName == "Sumo") else if (_gameName == "Sumo")
{ {
sceneName = "Sumo"; sceneName = "RoundIntro";
} }
else else
{ {

4
namedropper/ProjectSettings/TagManager.asset

@ -3,7 +3,9 @@
--- !u!78 &1 --- !u!78 &1
TagManager: TagManager:
serializedVersion: 2 serializedVersion: 2
tags: [] tags:
- FinishLine
- Midpoint
layers: layers:
- Default - Default
- TransparentFX - TransparentFX

BIN
original art assets/racetrack.psd

Binary file not shown.
Loading…
Cancel
Save