Update 4Today I wrote a better class for handling assets:
public static class Resource
{
private static bool loaded = false;
private static Dictionary<string, AudioClip> rAudio;
private static Dictionary<string, Mesh> rModels;
private static Dictionary<string, Object> rPrefabs;
public static AudioClip sound(string name)
{
return rAudio[name];
}
public static Mesh model(string name)
{
return rModels[name];
}
public static Mesh wireModel(string name)
{
var n = rModels[name];
return WireframeGenerator.Generate(ref n, WIRE_INSIDE.Color);
}
public static Object prefab(string name)
{
return rPrefabs[name];
}
public static void LoadAll()
{
if (!loaded)
{
//Audio
var tAudio = Resources.LoadAll<AudioClip>("rAudio");
foreach (AudioClip item in tAudio)
{
rAudio.Add(item.name, item);
}
//Models
var tModels = Resources.LoadAll<Mesh>("rModels");
foreach (Mesh item in tModels)
{
rModels.Add(item.name, item);
}
//Prefabs
var tPrefabs = Resources.LoadAll<Object>("rPrefabs");
foreach (Object item in tPrefabs)
{
rPrefabs.Add(item.name, item);
}
loaded = true;
}
}
}
This works for pretty much any project I'd say, it just requires that you have folders in your \Resources called "rAudio", "rModels", and "rPrefabs" with appropriately typed assets in them. Use if you want.
Oh yeah and I guess the
wireModel() method is only useful if you use the wireframe thing I use. Just ignore that I guess.
I've also mostly implemented the
bomb secondary weapon:
Here's it's trail:
And the awe-inspiring explosion:
(I think I might add some sort of expanding wireframe sphere to explosion effect to keep in theme...)
So, there you go. The
first secondary weapon! The bomb works like this: you fire it, it has momentum but eventually slows down. After two seconds it blows up, or if it hits a target. The closer enemies are, the more damage they take. The maximum damage from an indirect hit is 50, and a direct hit is 100. Most of the time, though, enemies are hit with less than 10 damage due to the way it attenuates. The explosion also acts as force on all rigid bodies, pushing them away.
Including you!
Oh yeah, I also did this little experiment:
Anyways, tomorrow I'll work on the next secondary weapon, a kind of guided rocket. It'll be the Raptor Class default secondary. Stay tuned for that!