slimecing

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit e34956c16affec77beee4f07ac41d7b066525e8c
parent af96ac317400569f6fb23297d9a3f24590d2b69d
Author: PlutoTank <qwolkensperg@gmail.com>
Date:   Fri, 17 Apr 2020 19:28:07 -0400

Added orbital stats for editing at runtime

Diffstat:
MAssets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogic.cs | 30++----------------------------
MAssets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/InputOrbitalLogic.cs | 14++++++++------
MAssets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/TimerOrbitalLogic.cs | 12++++++------
MAssets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalLogic/InputOrbitalLogic.asset | 5+----
MAssets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalLogic/TimerOrbitalLogic.asset | 5+----
AAssets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/InputOrbitalStats.asset | 18++++++++++++++++++
AAssets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/InputOrbitalStats.asset.meta | 8++++++++
AAssets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/TimerOrbitalStats.asset | 18++++++++++++++++++
AAssets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/TimerOrbitalStats.asset.meta | 8++++++++
9 files changed, 70 insertions(+), 48 deletions(-)

diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogic.cs b/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogic.cs @@ -5,34 +5,8 @@ namespace Slimecing.Swords.Orbitals { public abstract class OrbitalLogic : ScriptableObject { - [SerializeField] private float rotSpeed; - [SerializeField] private float yOffset; - [SerializeField] private float xAxis = 5f; - [SerializeField] private float zAxis = 5f; - - public float RotSpeed - { - get => rotSpeed; - set => rotSpeed = value; - } - - public float YOffset - { - get => yOffset; - set => yOffset = value; - } - - public float XAxis - { - get => xAxis; - set => xAxis = value; - } - - public float ZAxis - { - get => zAxis; - set => zAxis = value; - } + [SerializeField] private OrbitalStats orbitalStats; + public OrbitalStats currentOrbitalStats => orbitalStats; public abstract void Initialize(GameObject owner, GameObject orbital); diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/InputOrbitalLogic.cs b/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/InputOrbitalLogic.cs @@ -16,7 +16,7 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts private void OnEnable() { - _swordEllipse = new Ellipse(XAxis, ZAxis); + _swordEllipse = new Ellipse(currentOrbitalStats.radiusX, currentOrbitalStats.radiusY); _operatingOrbitalInputTrigger = Instantiate(orbitalInputTrigger); } @@ -36,11 +36,13 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts { Vector3 center = owner.transform.position; - float step = Time.fixedDeltaTime * RotSpeed; + float step = Time.fixedDeltaTime * currentOrbitalStats.rotationSpeed; Vector2 circlePos = _swordEllipse.EvaluateEllipse(_finalSwordTarget.x); - Vector3 targetPos = new Vector3(circlePos.x, YOffset, circlePos.y); - Vector3 smoothPos = Vector3.RotateTowards(orbital.transform.position - center, targetPos, step, 0f); - Vector3 orbitPos = new Vector3(smoothPos.normalized.x * XAxis, YOffset, smoothPos.normalized.z * ZAxis); + Vector3 targetPos = new Vector3(circlePos.x, currentOrbitalStats.verticalOffset, circlePos.y); + Vector3 smoothPos = Vector3.RotateTowards(orbital.transform.position - center, targetPos, + step, 0f); + Vector3 orbitPos = new Vector3(smoothPos.normalized.x * currentOrbitalStats.radiusX, + currentOrbitalStats.verticalOffset, smoothPos.normalized.z * currentOrbitalStats.radiusY); if (orbitPos != orbital.transform.position) { orbital.transform.position = orbitPos + center; @@ -49,7 +51,7 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts SetLook(owner, orbital); } - private void SetLook(GameObject owner, GameObject orbital) + private static void SetLook(GameObject owner, GameObject orbital) { Vector3 position = orbital.transform.position; Vector3 ownerPos = owner.transform.position; diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/TimerOrbitalLogic.cs b/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/TimerOrbitalLogic.cs @@ -17,7 +17,7 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts private void OnEnable() { - _orbitPath = new Ellipse(XAxis, ZAxis); + _orbitPath = new Ellipse(currentOrbitalStats.radiusX, currentOrbitalStats.radiusY); } public override void Initialize(GameObject owner, GameObject orbital) @@ -27,9 +27,9 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts } public override void Tick(GameObject owner, GameObject orbital) { - if (Mathf.Abs(RotSpeed) < 0.1) + if (Mathf.Abs(currentOrbitalStats.rotationSpeed) < 0.1) { - RotSpeed = 0.1f; + currentOrbitalStats.rotationSpeed = 0.1f; } Rotate(owner, orbital); SetLook(owner, orbital); @@ -38,11 +38,11 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts private void SetOrbitalPos(GameObject owner, GameObject orbital) { Vector2 orbitPos = _orbitPath.EvaluateEllipse(orbitalProgress); - Vector3 pos = new Vector3(orbitPos.x, YOffset, orbitPos.y); + Vector3 pos = new Vector3(orbitPos.x, currentOrbitalStats.verticalOffset, orbitPos.y); orbital.transform.position = pos + owner.transform.position; } - private void SetLook(GameObject owner, GameObject orbital) + private static void SetLook(GameObject owner, GameObject orbital) { Vector3 position = orbital.transform.position; Vector3 ownerPos = owner.transform.position; @@ -51,7 +51,7 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts private void Rotate(GameObject owner, GameObject orbital) { - float orbitSpeed = 1f / RotSpeed; + float orbitSpeed = 1f / currentOrbitalStats.rotationSpeed; orbitalProgress += Time.fixedDeltaTime * orbitSpeed; orbitalProgress %= 1f; SetOrbitalPos(owner, orbital); diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalLogic/InputOrbitalLogic.asset b/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalLogic/InputOrbitalLogic.asset @@ -12,9 +12,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5d7968acda84baa4fa1a7008b6f01265, type: 3} m_Name: InputOrbitalLogic m_EditorClassIdentifier: - rotSpeed: 10 - yOffset: 1 - xAxis: 2.5 - zAxis: 2.5 + orbitalStats: {fileID: 11400000, guid: 40ca913627790f546a70a7cc2f14ac69, type: 2} orbitalInputTrigger: {fileID: 11400000, guid: 8e538a3d690d3d446aaf393f3d8319f3, type: 2} diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalLogic/TimerOrbitalLogic.asset b/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalLogic/TimerOrbitalLogic.asset @@ -12,9 +12,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a01e1cbc5c4e6e7418ba67b90bf0fce4, type: 3} m_Name: TimerOrbitalLogic m_EditorClassIdentifier: - rotSpeed: 4 - yOffset: 1 - xAxis: 2.2 - zAxis: 2.2 + orbitalStats: {fileID: 11400000, guid: ca7798574e6d9ea4aaf5df7ed0081254, type: 2} randomProgress: 1 orbitalProgress: 0.83612007 diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/InputOrbitalStats.asset b/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/InputOrbitalStats.asset @@ -0,0 +1,18 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0a37f7d239ec14245970c23702857274, type: 3} + m_Name: InputOrbitalStats + m_EditorClassIdentifier: + orbitalSpeed: 10 + yOffset: 1 + xAxis: 2.5 + yAxis: 2.5 diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/InputOrbitalStats.asset.meta b/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/InputOrbitalStats.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 40ca913627790f546a70a7cc2f14ac69 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/TimerOrbitalStats.asset b/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/TimerOrbitalStats.asset @@ -0,0 +1,18 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0a37f7d239ec14245970c23702857274, type: 3} + m_Name: TimerOrbitalStats + m_EditorClassIdentifier: + orbitalSpeed: 4 + yOffset: 1 + xAxis: 2.2 + yAxis: 2.2 diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/TimerOrbitalStats.asset.meta b/Assets/Scripts/Slimecing/Swords/Orbitals/SOOrbitalStats/TimerOrbitalStats.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ca7798574e6d9ea4aaf5df7ed0081254 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: