From 8409176e0872e9cb14ae35f4d94784372517a205 Mon Sep 17 00:00:00 2001 From: danqiye1 <5430399+danqiye1@users.noreply.github.com> Date: Fri, 18 Dec 2020 17:48:14 +0800 Subject: [PATCH] Win menu hack --- Assets/Scenes/Play Level.unity | 7 ++++++- Assets/Scripts/Player.cs | 26 +++++++++----------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Assets/Scenes/Play Level.unity b/Assets/Scenes/Play Level.unity index 7b03101..959b1e3 100644 --- a/Assets/Scenes/Play Level.unity +++ b/Assets/Scenes/Play Level.unity @@ -358711,7 +358711,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1882031589} - m_LocalRotation: {x: 0.1064902, y: -0.0022560386, z: 0.00024162054, w: 0.99431115} + m_LocalRotation: {x: 0.1064902, y: -0.0022560388, z: 0.00024162055, w: 0.99431115} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: @@ -409024,6 +409024,11 @@ PrefabInstance: propertyPath: GodModeIndicator value: objectReference: {fileID: 250873899} + - target: {fileID: 1220512134839435321, guid: b5fe2a65e2bbb491da9870f9767ebdc6, + type: 3} + propertyPath: flag + value: + objectReference: {fileID: 1412293294} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: b5fe2a65e2bbb491da9870f9767ebdc6, type: 3} --- !u!1001 &6575436717421826410 diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index d600e6c..ce0fa71 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -30,6 +30,7 @@ public class Player : MonoBehaviour // Winning Mechanics public GameObject WinMenu; public GameObject LoseMenu; + public GameObject flag; public bool GodMode = true; public GameObject GodModeIndicator; @@ -61,12 +62,6 @@ void Update() moveSpeed = 2.0f; } - // Death - // if (Input.GetKey("mouse 1")) - // { - // anim.SetInteger(deathHash, Random.Range(1, 4)); - // } - if (direction.magnitude >= 0.1f && isDead == false) { // Player Rotation. @@ -108,6 +103,14 @@ void Update() GodModeIndicator.SetActive(GodMode); } + // Toggle Win + Vector3 DistToFlag = transform.position - flag.transform.position; + if (DistToFlag.magnitude <= 1){ + // Win + WinMenu.SetActive(true); + GodMode = true; + } + } @@ -129,15 +132,4 @@ void OnCollisionEnter(Collision collision){ } } - // Death from hitting a bullet - void OnCollisionTrigger(Collision collision){ - - if(collision.transform.CompareTag("Flag")) - { - // Win - WinMenu.SetActive(true); - Debug.Log("Win"); - } - } - }