diff --git a/namedropper/Assets/Join.cs b/namedropper/Assets/Join.cs index 16197a9..5e567ad 100644 --- a/namedropper/Assets/Join.cs +++ b/namedropper/Assets/Join.cs @@ -53,7 +53,7 @@ public class Join : MonoBehaviour StartGame(); } - if (Input.GetKeyDown(KeyCode.Alpha2)) + if (Input.GetKeyDown(KeyCode.Alpha2) || Input.GetMouseButtonDown(0)) { GameManager.Instance.Competitive = true; StartGame(); diff --git a/namedropper/Assets/Prefabs/Powerup Prefab.prefab b/namedropper/Assets/Prefabs/Powerup Prefab.prefab new file mode 100644 index 0000000..f7e3d84 --- /dev/null +++ b/namedropper/Assets/Prefabs/Powerup Prefab.prefab @@ -0,0 +1,128 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2355887706657292512 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2355887706657292524} + - component: {fileID: 2355887706657292515} + - component: {fileID: 2355887706657292514} + - component: {fileID: 2355887706657292513} + - component: {fileID: 2355887706657292525} + m_Layer: 0 + m_Name: Powerup Prefab + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2355887706657292524 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2355887706657292512} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 833.31, y: 809.7, z: -9.3} + m_LocalScale: {x: 0.38822, y: 0.38822, z: 0.38822} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &2355887706657292515 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2355887706657292512} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: d6c3531494da6b64fba26dea94bc6098, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 160, y: 218} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!58 &2355887706657292514 +CircleCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2355887706657292512} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + serializedVersion: 2 + m_Radius: 109 +--- !u!114 &2355887706657292513 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2355887706657292512} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 02d335f1af9cc3e47837750dc736c2ba, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &2355887706657292525 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2355887706657292512} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 37dfc580ad57d894caaababe502afb5b, type: 3} + m_Name: + m_EditorClassIdentifier: + _useWorldSpace: 0 diff --git a/namedropper/Assets/Prefabs/Powerup Prefab.prefab.meta b/namedropper/Assets/Prefabs/Powerup Prefab.prefab.meta new file mode 100644 index 0000000..6193762 --- /dev/null +++ b/namedropper/Assets/Prefabs/Powerup Prefab.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: fe820c2aff8b39b4e9017b4b0e042dae +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/Scenes/Game.unity b/namedropper/Assets/Scenes/Game.unity index e60dce9..af3f6c1 100644 --- a/namedropper/Assets/Scenes/Game.unity +++ b/namedropper/Assets/Scenes/Game.unity @@ -3614,6 +3614,8 @@ MonoBehaviour: CategoriesRound1: {fileID: 554321082} CategoriesRound2: {fileID: 1146299634} CategoriesRound3: {fileID: 1391939818} + _canvas: {fileID: 1666960091} + _powerupPrefab: {fileID: 2355887706657292512, guid: fe820c2aff8b39b4e9017b4b0e042dae, type: 3} --- !u!4 &1641253473 Transform: m_ObjectHideFlags: 0 @@ -5168,7 +5170,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 9049015333349338420, guid: 56b5ab1b6ee02794ab9664e282d1930a, type: 3} propertyPath: m_AnchoredPosition.x - value: -99.4 + value: 985 objectReference: {fileID: 0} - target: {fileID: 9049015333349338420, guid: 56b5ab1b6ee02794ab9664e282d1930a, type: 3} propertyPath: m_AnchoredPosition.y diff --git a/namedropper/Assets/Scenes/Title.unity b/namedropper/Assets/Scenes/Title.unity index b41d090..380f7c6 100644 --- a/namedropper/Assets/Scenes/Title.unity +++ b/namedropper/Assets/Scenes/Title.unity @@ -833,7 +833,13 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: "\nPress 1 to start Co-op mode\n or 2 to start VS. mode" + m_text: ' + + + + + + Press START!' m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 4fe6d5308385b4341885d0d510c8e2aa, type: 2} m_sharedMaterial: {fileID: 1001970574707011636, guid: 4fe6d5308385b4341885d0d510c8e2aa, type: 2} diff --git a/namedropper/Assets/Scripts/Game.cs b/namedropper/Assets/Scripts/Game.cs index 101d87f..1a5d7fe 100644 --- a/namedropper/Assets/Scripts/Game.cs +++ b/namedropper/Assets/Scripts/Game.cs @@ -30,6 +30,8 @@ public class Game : Level int _originalFontSize; static bool _paused = false; + [SerializeField] Canvas _canvas; + [SerializeField] GameObject _powerupPrefab; public static bool Paused { get => _paused; set => _paused = value; } @@ -131,6 +133,22 @@ public class Game : Level ActivatePlayers(true); yield return new WaitForSeconds(1f); Topic.gameObject.SetActive(false); + Invoke("SpawnPowerup", Random.Range(8f, 12f)); + } + + void SpawnPowerup() + { + if (GameManager.Instance.Round >= 2) + { + GameObject powerup = Instantiate(_powerupPrefab); + powerup.transform.parent = _canvas.gameObject.transform; + powerup.transform.position = new Vector3(0, Random.Range(225f, 820f), powerup.transform.position.z); + + if (GameManager.Instance.Round == 3) + Invoke("SpawnPowerup", Random.Range(7f, 16f)); + else + Invoke("SpawnPowerup", Random.Range(10f, 20f)); + } } void StartGame() @@ -208,7 +226,7 @@ public class Game : Level } else if (player == 3) { - _redScoreStack.AddChecker(amount / 10, true); + _redScoreStack.AddChecker(amount / 10, true ); GameManager.Instance.Score4 += amount; } diff --git a/namedropper/Assets/Scripts/Player.cs b/namedropper/Assets/Scripts/Player.cs index c9b308e..25428f2 100644 --- a/namedropper/Assets/Scripts/Player.cs +++ b/namedropper/Assets/Scripts/Player.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; +using UnityEngine.UIElements; public class Player : MonoBehaviour { @@ -26,10 +27,17 @@ public class Player : MonoBehaviour float _timeToFlip = 0f; GameObject _spriteChild; GameObject _spriteChildTop; - Vector3 _originalScale; + Vector3 _originalSpriteChildTopScale; Vector3 _originalTextScale; string _categoryName; public int? DeviceId = null; + float _curSpeed = SPEED; + + Vector3 _originalScale; + float _originalMass; + float _originalSpeed; + bool _poweredUp = false; + float _powerupTimeLeft = 0f; public enum Team { @@ -41,13 +49,18 @@ public class Player : MonoBehaviour private void Awake() { + _rigidbody = GetComponent(); + + _originalScale = this.transform.localScale; + _originalMass = _rigidbody.mass; + _originalSpeed = _curSpeed; _spriteChildTop = transform.Find("sprite_top").gameObject; - _originalScale = _spriteChildTop.transform.localScale; + _originalSpriteChildTopScale = _spriteChildTop.transform.localScale; _spriteChild = transform.Find("sprite").gameObject; _spriteChild.GetComponent().sprite = _spriteOptions[GameManager.PLAYER_SKIN]; - _rigidbody = GetComponent(); + _text = transform.GetChild(0).GetComponent(); _originalTextScale = _text.transform.localScale; _game = FindObjectOfType(); @@ -228,6 +241,18 @@ public class Player : MonoBehaviour calibrationBox.Calibrate(DeviceId); this.gameObject.SetActive(false); } + + // powerup + Powerup powerup = collision.gameObject.GetComponent(); + if (powerup != null) + { + GameObject.Destroy(powerup.gameObject); + this.transform.localScale = _originalScale * 1.25f; + _rigidbody.mass = _originalMass * 2f; + _curSpeed = _originalSpeed * 1.5f; + _poweredUp = true; + _powerupTimeLeft = 10f; + } } // Update is called once per frame @@ -247,7 +272,7 @@ public class Player : MonoBehaviour _spriteChild.transform.localScale = new Vector3(_spriteChild.transform.localScale.x * -1f, _spriteChild.transform.localScale.y, _spriteChild.transform.localScale.z); _timeToFlip = .1f; - _spriteChildTop.transform.localScale = new Vector3(_originalScale.x * Random.Range(.95f,1.05f), _originalScale.y * Random.Range(.95f, 1.05f), _spriteChild.transform.localScale.z); + _spriteChildTop.transform.localScale = new Vector3(_originalSpriteChildTopScale.x * Random.Range(.95f,1.05f), _originalSpriteChildTopScale.y * Random.Range(.95f, 1.05f), _spriteChild.transform.localScale.z); _text.transform.localScale = new Vector3(_originalTextScale.x * Random.Range(.95f, 1.05f), _originalTextScale.y * Random.Range(.95f, 1.05f), _text.transform.localScale.z); } @@ -257,15 +282,15 @@ public class Player : MonoBehaviour if (Input.GetKey(_keyLeft)) { - _rigidbody.velocity += new Vector2(SPEED * Time.deltaTime * -1f, 0f); + _rigidbody.velocity += new Vector2(_curSpeed * Time.deltaTime * -1f, 0f); } if (Input.GetKey(_keyRight)) { - _rigidbody.velocity += new Vector2(SPEED * Time.deltaTime, 0f); + _rigidbody.velocity += new Vector2(_curSpeed * Time.deltaTime, 0f); } if (Input.GetKey(_keyDown)) { - _rigidbody.velocity += new Vector2(0f, SPEED * Time.deltaTime * -1f); + _rigidbody.velocity += new Vector2(0f, _curSpeed * Time.deltaTime * -1f); } if (Input.GetKey(_keyDrop) && ALLOW_DROP) @@ -275,7 +300,18 @@ public class Player : MonoBehaviour if (_dropping) { - _rigidbody.velocity += new Vector2(0f, SPEED * 5f * Time.deltaTime * -1f); + _rigidbody.velocity += new Vector2(0f, _curSpeed * 5f * Time.deltaTime * -1f); + } + + _powerupTimeLeft -= Time.deltaTime; + + if (_powerupTimeLeft < 0f && _poweredUp) + { + _poweredUp = false; + _powerupTimeLeft = 0f; + this.transform.localScale = _originalScale; + _rigidbody.mass = _originalMass; + _curSpeed = _originalSpeed; } } diff --git a/namedropper/Assets/Scripts/Powerup.cs b/namedropper/Assets/Scripts/Powerup.cs new file mode 100644 index 0000000..f84ec41 --- /dev/null +++ b/namedropper/Assets/Scripts/Powerup.cs @@ -0,0 +1,48 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Powerup : MonoBehaviour +{ + const float SPEED = 200f; + List _players = new List(); + float _direction = 1f; + // Start is called before the first frame update + void Start() + { + _players = new List(FindObjectsOfType()); + if (Random.Range(0, 2) == 0) + _direction = -1f; + + } + + // Update is called once per frame + void Update() + { + Player closestPlayer = null; + float closestDistance = 9999999f; + foreach (Player player in _players) + { + float distance = Vector3.Distance(player.transform.position, transform.position); + if (distance < closestDistance) + { + closestDistance = distance; + closestPlayer = player; + } + } + + Vector3 direction = new Vector3(_direction, 0, 0); + //move away from closest player + if (closestPlayer != null && closestDistance < 300f) + { + direction = closestPlayer.transform.position - transform.position; + direction.Normalize(); + direction.z = 0f; + + + } + + transform.position += direction * Time.deltaTime * -1 * SPEED; + + } +} diff --git a/namedropper/Assets/Scripts/Powerup.cs.meta b/namedropper/Assets/Scripts/Powerup.cs.meta new file mode 100644 index 0000000..cc9bfff --- /dev/null +++ b/namedropper/Assets/Scripts/Powerup.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 02d335f1af9cc3e47837750dc736c2ba +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/Scripts/Wraparound.cs b/namedropper/Assets/Scripts/Wraparound.cs index 07b303e..46b9853 100644 --- a/namedropper/Assets/Scripts/Wraparound.cs +++ b/namedropper/Assets/Scripts/Wraparound.cs @@ -5,6 +5,8 @@ using UnityEngine.SceneManagement; public class Wraparound : MonoBehaviour { + public bool _useWorldSpace = false; //set to true for gameobjects that are not part of the GUI + // Start is called before the first frame update void Start() {