magique
Full Member
 
Posts: 194
Posts: 194
|
Post by magique on Sept 28, 2017 21:47:39 GMT
I'm looking at the API for WaveSyncoSpawner and it seems like I should be able to make it work with that. I will try that tonight and see how it goes. If it works then I'll remove my custom code and perform the version update. Thanks for your help.
|
|
|
Post by DarkTonic Dev on Sept 28, 2017 23:42:44 GMT
Basically you'd use a Listener subclass like this:
using UnityEngine; using System.Collections; using DarkTonic.CoreGameKit;
public class SpawnerCurvyListener : WaveSyncroSpawnerListener { public Transform curvySplinePrefab;
private Transform curvySplineGameObjectForWave;
public override void WaveStart(WaveSpecifics spec) { base.WaveStart (spec);
curvySplineGameObjectForWave = PoolBoss.Spawn (curvySplinePrefab, Vector3.zero, Quaternion.identity, null); // pass parent Transform if needed }
public override void ItemSpawned (Transform spawnedTrans) { base.ItemSpawned (spawnedTrans);
// attach to curvy spline spawnedTrans.parent = curvySplineGameObjectForWave; } }
This does create a new curvy spline game object for each wave and parent everything spawned for the wave under it. It doesn't destroy / despawn the curvy spline at end of wave but you could add code to do that easily.
Make sure you hook up the Listener to the spawner, by putting it on the same game object as the spawner.
|
|
magique
Full Member
 
Posts: 194
Posts: 194
|
Post by magique on Sept 29, 2017 0:35:44 GMT
Thanks. That's pretty much what I was thinking once you gave the idea of a Listener. I will be trying soon. Hopefully, it'll all work and I can get rid of the custom code.
|
|
|
Post by DarkTonic Dev on Sept 29, 2017 1:28:44 GMT
That would be good 
|
|
magique
Full Member
 
Posts: 194
Posts: 194
|
Post by magique on Sept 29, 2017 3:01:49 GMT
I'm happy to report that the listener idea worked perfectly. Thanks for the great suggestion. I'm now just working on converting all my spawners over and then I'll be removing the custom code and upgrading.
|
|
|
Post by DarkTonic Dev on Sept 29, 2017 5:56:52 GMT
That's awesome! We use them for the same sort of thing in our game (extra fields that need Inspector support). If you identity something that can't be done with them, we can always add more methods to the Listener to accommodate.
|
|
magique
Full Member
 
Posts: 194
Posts: 194
|
Post by magique on Sept 29, 2017 14:20:43 GMT
Unfortunately, I've encountered one issue with this. For some reason, on any spawner that I have this new listener on it no longer honors the Repeat Wave functionality. I have a couple of spawners that used to repeat 3 times and now they only run a single time. Any ideas what could be wrong?
|
|
magique
Full Member
 
Posts: 194
Posts: 194
|
Post by magique on Sept 29, 2017 15:08:42 GMT
Also, I'm not seeing a new version of Core GameKit on the asset store so it looks like the fix is still pending.
|
|
|
Post by DarkTonic Dev on Sept 29, 2017 16:09:15 GMT
Unfortunately, I've encountered one issue with this. For some reason, on any spawner that I have this new listener on it no longer honors the Repeat Wave functionality. I have a couple of spawners that used to repeat 3 times and now they only run a single time. Any ideas what could be wrong? Please first verify that removing the listener fixes the spawner. Adding a listener will should not affect the spawner, unlike a spawner subclass could. Send me your listener code if it is indeed breaking the spawner. I will publish the update soon.
|
|
magique
Full Member
 
Posts: 194
Posts: 194
|
Post by magique on Sept 29, 2017 16:15:03 GMT
Unfortunately, I've encountered one issue with this. For some reason, on any spawner that I have this new listener on it no longer honors the Repeat Wave functionality. I have a couple of spawners that used to repeat 3 times and now they only run a single time. Any ideas what could be wrong? Please first verify that removing the listener fixes the spawner. Adding a listener will should not affect the spawner, unlike a spawner subclass could. Send me your listener code if it is indeed breaking the spawner. I will publish the update soon. In effect I've already done that because it worked before I added the listener and now no longer works with the listener. It's not as easy as just removing it though since all the code needed to make the spawners actually work is in the Listener where it used to be in the custom code I had elsewhere. However, I will make a skeleton Listener and attach to a spawner that doesn't have a Listener but also has repeats on. If that breaks it then I will know. I'll try that tonight and let you know.
|
|
|
Post by DarkTonic Dev on Sept 29, 2017 16:25:32 GMT
Yeah but even without the Listener it should still spawn all the prefabs, even if they aren't in the correct location or whatever. Then finish the wave by killing all and see if it repeats.
|
|
magique
Full Member
 
Posts: 194
Posts: 194
|
Post by magique on Sept 29, 2017 16:27:21 GMT
Yeah but even without the Listener it should still spawn all the prefabs, even if they aren't in the correct location or whatever. Then finish the wave by killing all and see if it repeats. OK, I'll also try that when I get home.
|
|
|
Post by DarkTonic Dev on Sept 29, 2017 16:52:07 GMT
ok
|
|
magique
Full Member
 
Posts: 194
Posts: 194
|
Post by magique on Sept 30, 2017 3:03:17 GMT
My first test was to remove the Listener from both spawners that are not repeating and then I see them repeating once again. So the Listener is somehow responsible for this.
Here is the code for that:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using DarkTonic.CoreGameKit;
using DarkTonic.MasterAudio;
using FluffyUnderware.Curvy;
namespace Magique
{
public class SpawnerCurvyListener : WaveSyncroSpawnerListener
{
public List<SpawnerSoundData> soundData = new List<SpawnerSoundData>();
public Transform curvySplinePrefab;
public float pathScaleMin = 1.0f;
public float pathScaleMax = 1.0f;
public float pathScaleFactor = 1.0f;
private Transform _curvySplinePath;
IEnumerator PlaySounds(int index)
{
yield return new WaitForSeconds(soundData[index].soundsDelay);
int currLoop = soundData[index].loopCount;
while (currLoop > 0)
{
MasterAudio.PlaySound(soundData[index].soundName);
yield return new WaitForSeconds(soundData[index].loopdelay);
--currLoop;
} // while
yield return null;
} // PlaySounds()
public override void WaveStart(WaveSpecifics spec)
{
base.WaveStart(spec);
if (curvySplinePrefab)
_curvySplinePath = PoolBoss.Spawn(curvySplinePrefab, curvySplinePrefab.transform.position, curvySplinePrefab.transform.rotation, null);
else
_curvySplinePath = null;
for (int i = 0; i < soundData.Count; ++i)
StartCoroutine(PlaySounds(i));
} // WaveStart()
public override void ItemSpawned(Transform spawnedTrans)
{
base.ItemSpawned(spawnedTrans);
if (!_curvySplinePath) return;
// attach to curvy spline
PathFollower pathFollower = spawnedTrans.GetComponent<PathFollower>();
if (pathFollower)
{
pathFollower.AssignPath(_curvySplinePath.GetComponent<CurvySpline>());
pathFollower.PathScaleMin = pathScaleMin;
pathFollower.PathScaleMax = pathScaleMax;
pathFollower.PathScaleFactor = pathScaleFactor;
pathFollower.Reset();
}
} // ItemSpawned()
public override void EliminationWaveCompleted(WaveSpecifics spec)
{
Debug.Log("EliminationWaveCompleted");
base.EliminationWaveCompleted(spec);
if (_curvySplinePath)
PoolBoss.Despawn(_curvySplinePath);
} // EliminationWaveCompleted()
} // class SpawnerCurvyListener
} // namespace Magique
|
|
magique
Full Member
 
Posts: 194
Posts: 194
|
Post by magique on Sept 30, 2017 18:00:34 GMT
Update. It looks like the WaveRepeat is triggering like it should. The spawners are even spawning, but they are just offscreen and not attached to the curvy splines. So this seems to be some issue with my conversion to the new Listener method for curvy integration. I'll keep digging to find what I did wrong. Sorry for the false alarm.
|
|