101 lines
3.8 KiB
C#
101 lines
3.8 KiB
C#
using UnityEngine;
|
|
using UnityEditor;
|
|
using System.IO;
|
|
|
|
/// <summary>
|
|
/// OGG → Setup → Create Bunny Hop Boots
|
|
/// Creates the ItemDefinition and a world pickup for the bhop boots.
|
|
/// </summary>
|
|
public static class BhopBootsSetup
|
|
{
|
|
private const string ITEM_DEF_PATH = "Assets/Items/BhopBoots_Item.asset";
|
|
private const string PICKUP_PREFAB = "Assets/Prefabs/Pickups/BhopBoots_Pickup.prefab";
|
|
|
|
[MenuItem("OGG/Setup/Create Bunny Hop Boots")]
|
|
public static void Create()
|
|
{
|
|
EnsureFolder("Assets/Items");
|
|
EnsureFolder("Assets/Prefabs/Pickups");
|
|
|
|
// ── ItemDefinition ────────────────────────────────────────────
|
|
ItemDefinition item = AssetDatabase.LoadAssetAtPath<ItemDefinition>(ITEM_DEF_PATH);
|
|
bool isNew = item == null;
|
|
if (isNew) item = ScriptableObject.CreateInstance<ItemDefinition>();
|
|
|
|
item.itemName = "Bunny Hop Boots";
|
|
item.type = ItemDefinition.ItemType.Misc;
|
|
item.isEquippable = true;
|
|
item.description = "Illegal footwear. Gives 200 stamina while worn. Do not wear near cliffs.";
|
|
|
|
if (isNew)
|
|
AssetDatabase.CreateAsset(item, ITEM_DEF_PATH);
|
|
else
|
|
EditorUtility.SetDirty(item);
|
|
|
|
AssetDatabase.SaveAssets();
|
|
|
|
// ── Pickup prefab — procedural boot shape ─────────────────────
|
|
GameObject root = new GameObject("BhopBoots_Pickup");
|
|
|
|
// Simple visual: a squashed cube (boot-ish)
|
|
GameObject body = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
|
body.name = "Visual";
|
|
body.transform.SetParent(root.transform, false);
|
|
body.transform.localPosition = new Vector3(0f, 0f, 0f);
|
|
body.transform.localScale = new Vector3(0.4f, 0.2f, 0.7f);
|
|
Object.DestroyImmediate(body.GetComponent<Collider>());
|
|
|
|
// Bright accent colour so it stands out
|
|
var rend = body.GetComponent<Renderer>();
|
|
if (rend != null)
|
|
{
|
|
rend.material = new Material(Shader.Find("Universal Render Pipeline/Lit"));
|
|
rend.material.color = new Color(0.1f, 0.9f, 0.4f);
|
|
}
|
|
|
|
PickupItem pickup = root.AddComponent<PickupItem>();
|
|
pickup.definition = item;
|
|
pickup.spinSpeed = 140f;
|
|
pickup.bobHeight = 0.2f;
|
|
pickup.bobSpeed = 2.8f;
|
|
pickup.pickupRadius = 2.2f;
|
|
pickup.pickupKey = KeyCode.E;
|
|
|
|
StaminaBoostPickup boost = root.AddComponent<StaminaBoostPickup>();
|
|
boost.newMaxStamina = 200f;
|
|
|
|
if (File.Exists(Application.dataPath + "/../" + PICKUP_PREFAB))
|
|
AssetDatabase.DeleteAsset(PICKUP_PREFAB);
|
|
|
|
GameObject saved = PrefabUtility.SaveAsPrefabAsset(root, PICKUP_PREFAB);
|
|
Object.DestroyImmediate(root);
|
|
|
|
AssetDatabase.Refresh();
|
|
|
|
EditorUtility.DisplayDialog(
|
|
"Bunny Hop Boots ✓",
|
|
$"Created:\n• {ITEM_DEF_PATH}\n• {PICKUP_PREFAB}\n\n" +
|
|
"Drag BhopBoots_Pickup into the scene.\n" +
|
|
"Pick it up with [E] to unlock bunny hopping.\n\n" +
|
|
"Hold SPACE while landing to chain hops and build speed.\n" +
|
|
"Strafe left/right mid-air to steer.",
|
|
"Let's go");
|
|
|
|
EditorGUIUtility.PingObject(saved);
|
|
Selection.activeObject = saved;
|
|
}
|
|
|
|
static void EnsureFolder(string path)
|
|
{
|
|
string[] parts = path.Split('/');
|
|
string current = parts[0];
|
|
for (int i = 1; i < parts.Length; i++)
|
|
{
|
|
string next = current + "/" + parts[i];
|
|
if (!AssetDatabase.IsValidFolder(next))
|
|
AssetDatabase.CreateFolder(current, parts[i]);
|
|
current = next;
|
|
}
|
|
}
|
|
}
|