commit 30048e5593c8986c4ac83aa38a8eb5053be4511c
parent 81c5ef34681243fa045a294b4bbdd5ac6a0bce3c
Author: PlutoTank <qwolkensperg@gmail.com>
Date: Thu, 16 Apr 2020 04:07:34 -0400
Orbital Dropping
Diffstat:
4 files changed, 68 insertions(+), 11 deletions(-)
diff --git a/Assets/Prefabs/Swords/TesterSword1.prefab b/Assets/Prefabs/Swords/TesterSword1.prefab
@@ -13,6 +13,7 @@ GameObject:
- component: {fileID: 2364959692505286347}
- component: {fileID: 7899141307266342912}
- component: {fileID: 1642684556973010571}
+ - component: {fileID: 4445292035447795239}
m_Layer: 10
m_Name: TesterSword1
m_TagString: Sword
@@ -111,6 +112,19 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
+--- !u!114 &4445292035447795239
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 2311679785310360297}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: c493037ae95819d4fa0c1961a904570a, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ rigidbody: {fileID: 2364959692505286347}
--- !u!1 &2311745251963663901
GameObject:
m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/Slimecing/Swords/DropBehaviour.meta b/Assets/Scripts/Slimecing/Swords/DropBehaviour.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: cb8a1161c5d8a5543a828e692df0faad
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/TakesOrbitals.cs b/Assets/Scripts/Slimecing/Swords/Orbitals/TakesOrbitals.cs
@@ -1,8 +1,5 @@
using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Collections.Specialized;
-using System.Linq;
-using Slimecing.Swords.Orbitals.OrbitalLogicScripts;
+using Slimecing.Swords.DropBehaviour;
using UnityEngine;
namespace Slimecing.Swords.Orbitals
@@ -15,7 +12,6 @@ namespace Slimecing.Swords.Orbitals
private Collider _collider;
private List<GameObject> _spawnedOrbitalObjects = new List<GameObject>();
- private int _currentListCount = 0;
private void OnEnable()
{
@@ -50,11 +46,9 @@ namespace Slimecing.Swords.Orbitals
public void InitializeOrbital(OrbitalPackage orbital)
{
- Debug.Log("started");
AddCollisions(orbital.orbitalObject);
orbital.OrbitalLogic = Instantiate(orbital.OrbitalLogic);
orbital.OrbitalLogic.Initialize(gameObject, orbital.orbitalObject);
- _currentListCount = orbitals.Count;
ResetSpawnedOrbitalObjects();
}
@@ -100,6 +94,7 @@ namespace Slimecing.Swords.Orbitals
private void RemoveOrbital(OrbitalPackage orbital)
{
+ DropOrbital(orbital);
orbitals.Remove(orbital);
}
@@ -115,18 +110,48 @@ namespace Slimecing.Swords.Orbitals
private void ValidateOrbitals()
{
- for (int i = 0; i < _spawnedOrbitalObjects.Count; i++)
+ float loopCount = _spawnedOrbitalObjects.Count;
+ bool resetLoop = false;
+
+ if (orbitals.Count != _spawnedOrbitalObjects.Count)
+ {
+ resetLoop = true;
+ if (orbitals.Count < _spawnedOrbitalObjects.Count)
+ {
+ loopCount = orbitals.Count;
+ }
+ }
+
+ for (int i = 0; i < loopCount; i++)
{
if (orbitals[i].orbitalObject != _spawnedOrbitalObjects[i])
{
+ DropOrbital(orbitals[i]);
InitializeOrbital(orbitals[i]);
}
}
-
- if (orbitals.Count > _currentListCount)
+
+ if (resetLoop)
{
ResetSpawnedOrbitalObjects();
}
}
+
+ private void DropOrbital(OrbitalPackage orbital)
+ {
+ DropLogic dropLogic = orbital.orbitalObject.GetComponent<DropLogic>();
+ if (dropLogic == null)
+ {
+ if (orbital.orbitalSticky)
+ {
+ orbital.orbitalObject.SetActive(false);
+ return;
+ }
+ Destroy(orbital.orbitalObject);
+ return;
+ }
+
+ dropLogic.Drop();
+ }
}
}
\ No newline at end of file
diff --git a/Assets/_Scenes/Testing/SLope.unity b/Assets/_Scenes/Testing/SLope.unity
@@ -2089,7 +2089,7 @@ PrefabInstance:
- target: {fileID: 2314149755559057351, guid: 4e346bd7fa8310847b295522d78bb540,
type: 3}
propertyPath: m_LocalPosition.y
- value: 0
+ value: -25
objectReference: {fileID: 0}
- target: {fileID: 2314149755559057351, guid: 4e346bd7fa8310847b295522d78bb540,
type: 3}
@@ -2136,6 +2136,16 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
+ - target: {fileID: 2364959692505286347, guid: 4e346bd7fa8310847b295522d78bb540,
+ type: 3}
+ propertyPath: m_IsKinematic
+ value: 1
+ objectReference: {fileID: 0}
+ - target: {fileID: 2364959692505286347, guid: 4e346bd7fa8310847b295522d78bb540,
+ type: 3}
+ propertyPath: m_UseGravity
+ value: 0
+ objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4e346bd7fa8310847b295522d78bb540, type: 3}
--- !u!1 &1087962991