diff options
Diffstat (limited to 'SurvivalTest/Assets/Scripts/Equips/LightSaber')
4 files changed, 103 insertions, 0 deletions
diff --git a/SurvivalTest/Assets/Scripts/Equips/LightSaber/Equip_LightSaber.cs b/SurvivalTest/Assets/Scripts/Equips/LightSaber/Equip_LightSaber.cs new file mode 100644 index 0000000..9066884 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/Equips/LightSaber/Equip_LightSaber.cs @@ -0,0 +1,63 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Equip_LightSaber : EquipBase +{ + public override string name => "¹â½£"; + + public override string iconPath => "art/ui/equipicon/light_saber"; + + public override AutoMode autoMode => AutoMode.Condition; + + private string lightSaberPrefabPath = "prefabs/weapon/light_saber"; + + private bool isWielding = false; + + private LightSaber m_LightSaber; + + private TopDownTransform m_TopDownTransform; + + private float m_Dist = 0.2f; + + public override void OnInitialize(GameObject owner) + { + m_LightSaber = UnityEngine.Object.Instantiate<LightSaber>(ResourceManager.Instance.Load<LightSaber>(lightSaberPrefabPath)); + m_TopDownTransform = m_LightSaber.gameObject.GetComponent<TopDownTransform>(); + SetLightSaberPositionAndRotation(owner.GetComponent<CrewScript>()); + m_LightSaber.gameObject.SetActive(false); + } + + public override bool CheckCondition(GameObject owner) + { + return true; + } + + public override void OnTrigger(GameObject owner) + { + if (isWielding) + return; + isWielding = true; + + m_LightSaber.gameObject.SetActive(true); + } + + public override void OnStop(GameObject owner) + { + isWielding = false; + m_LightSaber.gameObject.SetActive(false); + } + + public override void Update(GameObject owner) + { + CrewScript crew = owner.GetComponent<CrewScript>(); + SetLightSaberPositionAndRotation(crew); + } + + void SetLightSaberPositionAndRotation(CrewScript crew) + { + m_LightSaber.transform.position = crew.arrow.position + new Vector3(crew.aimDirection.x, crew.aimDirection.y, 0) * m_Dist; + m_LightSaber.transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(crew.aimDirection.y, crew.aimDirection.x) * Mathf.Rad2Deg); + } + +}
\ No newline at end of file diff --git a/SurvivalTest/Assets/Scripts/Equips/LightSaber/Equip_LightSaber.cs.meta b/SurvivalTest/Assets/Scripts/Equips/LightSaber/Equip_LightSaber.cs.meta new file mode 100644 index 0000000..dcc1028 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/Equips/LightSaber/Equip_LightSaber.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cf80263cc579a3c46887c696a8f09d56 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/SurvivalTest/Assets/Scripts/Equips/LightSaber/LightSaber.cs b/SurvivalTest/Assets/Scripts/Equips/LightSaber/LightSaber.cs new file mode 100644 index 0000000..4db08ee --- /dev/null +++ b/SurvivalTest/Assets/Scripts/Equips/LightSaber/LightSaber.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class LightSaber : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/SurvivalTest/Assets/Scripts/Equips/LightSaber/LightSaber.cs.meta b/SurvivalTest/Assets/Scripts/Equips/LightSaber/LightSaber.cs.meta new file mode 100644 index 0000000..e8200d8 --- /dev/null +++ b/SurvivalTest/Assets/Scripts/Equips/LightSaber/LightSaber.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 72f3d28485a45ba4b8906603b170f9fa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |