mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:27:40 +02:00
Buggy timeline object resizing
This commit is contained in:
@ -4,74 +4,31 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
using RhythmHeavenMania.Games.ForkLifter;
|
||||
using RhythmHeavenMania.Games.ClappyTrio;
|
||||
using RhythmHeavenMania.Games.Spaceball;
|
||||
using RhythmHeavenMania.Games.KarateMan;
|
||||
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
public class EventCaller : MonoBehaviour
|
||||
{
|
||||
public Transform GamesHolder;
|
||||
private float currentBeat;
|
||||
private float currentLength;
|
||||
private float currentValA;
|
||||
private string currentSwitchGame;
|
||||
private int currentType;
|
||||
public float currentBeat;
|
||||
public float currentLength;
|
||||
public float currentValA;
|
||||
public string currentSwitchGame;
|
||||
public int currentType;
|
||||
|
||||
public delegate void EventCallback();
|
||||
|
||||
public static EventCaller instance { get; private set; }
|
||||
|
||||
public List<MiniGame> minigames = new List<MiniGame>()
|
||||
public List<Minigames.Minigame> minigames = new List<Minigames.Minigame>()
|
||||
{
|
||||
};
|
||||
|
||||
[Serializable]
|
||||
public class MiniGame
|
||||
{
|
||||
public string name;
|
||||
public string displayName;
|
||||
public string color;
|
||||
public GameObject holder;
|
||||
public List<GameAction> actions = new List<GameAction>();
|
||||
|
||||
public MiniGame(string name, string displayName, string color, List<GameAction> actions)
|
||||
{
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
this.color = color;
|
||||
this.actions = actions;
|
||||
}
|
||||
}
|
||||
|
||||
public class GameAction
|
||||
{
|
||||
public string actionName;
|
||||
public EventCallback function;
|
||||
public bool playerAction = false;
|
||||
public float defaultLength;
|
||||
public bool resizable;
|
||||
|
||||
public GameAction(string actionName, EventCallback function, float defaultLength = 1, bool playerAction = false, bool resizable = false)
|
||||
{
|
||||
this.actionName = actionName;
|
||||
this.function = function;
|
||||
this.playerAction = playerAction;
|
||||
this.defaultLength = defaultLength;
|
||||
this.resizable = resizable;
|
||||
}
|
||||
}
|
||||
|
||||
public MiniGame GetMinigame(string gameName)
|
||||
public Minigames.Minigame GetMinigame(string gameName)
|
||||
{
|
||||
return minigames.Find(c => c.name == gameName);
|
||||
}
|
||||
|
||||
public GameAction GetGameAction(MiniGame game, string action)
|
||||
public Minigames.GameAction GetGameAction(Minigames.Minigame game, string action)
|
||||
{
|
||||
return game.actions.Find(c => c.actionName == action);
|
||||
}
|
||||
@ -79,52 +36,10 @@ namespace RhythmHeavenMania
|
||||
public void Init()
|
||||
{
|
||||
instance = this;
|
||||
minigames = new List<MiniGame>()
|
||||
{
|
||||
new MiniGame("gameManager", "Game Manager", "", new List<GameAction>()
|
||||
{
|
||||
new GameAction("end", delegate { Debug.Log("end"); }),
|
||||
new GameAction("switchGame", delegate { GameManager.instance.SwitchGame(currentSwitchGame); })
|
||||
}),
|
||||
new MiniGame("forkLifter", "Fork Lifter", "FFFFFF", new List<GameAction>()
|
||||
{
|
||||
new GameAction("pea", delegate { ForkLifter.instance.Flick(currentBeat, 0); }, 3, true),
|
||||
new GameAction("topbun", delegate { ForkLifter.instance.Flick(currentBeat, 1); }, 3, true),
|
||||
new GameAction("burger", delegate { ForkLifter.instance.Flick(currentBeat, 2); }, 3, true),
|
||||
new GameAction("bottombun", delegate { ForkLifter.instance.Flick(currentBeat, 3); }, 3, true),
|
||||
new GameAction("prepare", delegate { ForkLifter.instance.ForkLifterHand.Prepare(); }, 0.5f, true),
|
||||
new GameAction("gulp", delegate { ForkLifterPlayer.instance.Eat(); }),
|
||||
new GameAction("sigh", delegate { Jukebox.PlayOneShot("sigh"); })
|
||||
}),
|
||||
new MiniGame("clappyTrio", "The Clappy Trio", "29E7FF", new List<GameAction>()
|
||||
{
|
||||
new GameAction("clap", delegate { ClappyTrio.instance.Clap(currentBeat, currentLength); }, 3, true),
|
||||
new GameAction("bop", delegate { ClappyTrio.instance.Bop(currentBeat); } ),
|
||||
new GameAction("prepare", delegate { ClappyTrio.instance.Prepare(0); } ),
|
||||
new GameAction("prepare_alt", delegate { ClappyTrio.instance.Prepare(3); } ),
|
||||
}),
|
||||
new MiniGame("spaceball", "Spaceball", "00A518", new List<GameAction>()
|
||||
{
|
||||
new GameAction("shoot", delegate { Spaceball.instance.Shoot(currentBeat, false, currentType); }, 2, true),
|
||||
new GameAction("shootHigh", delegate { Spaceball.instance.Shoot(currentBeat, true, currentType); }, 3, true),
|
||||
new GameAction("costume", delegate { Spaceball.instance.Costume(currentType); } ),
|
||||
new GameAction("alien", delegate { Spaceball.instance.alien.Show(currentBeat); } ),
|
||||
new GameAction("cameraZoom", delegate { } ),
|
||||
}),
|
||||
new MiniGame("karateman", "Karate Man", "70A8D8", new List<GameAction>()
|
||||
{
|
||||
new GameAction("bop", delegate { KarateMan.instance.Bop(currentBeat, currentLength); }, 0.5f, true, true),
|
||||
new GameAction("pot", delegate { KarateMan.instance.Shoot(currentBeat, 0); }, 2, true),
|
||||
new GameAction("bulb", delegate { KarateMan.instance.Shoot(currentBeat, 1); }, 2, true),
|
||||
new GameAction("rock", delegate { KarateMan.instance.Shoot(currentBeat, 2); }, 2, true),
|
||||
new GameAction("ball", delegate { KarateMan.instance.Shoot(currentBeat, 3); }, 2, true),
|
||||
new GameAction("kick", delegate { KarateMan.instance.Shoot(currentBeat, 4); }, 4.5f, true),
|
||||
new GameAction("bgfxon", delegate { KarateMan.instance.BGFXOn(); } ),
|
||||
new GameAction("bgfxoff", delegate { KarateMan.instance.BGFXOff(); }),
|
||||
})
|
||||
};
|
||||
|
||||
List<MiniGame> minigamesInBeatmap = new List<MiniGame>();
|
||||
Minigames.Init(this);
|
||||
|
||||
List<Minigames.Minigame> minigamesInBeatmap = new List<Minigames.Minigame>();
|
||||
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++)
|
||||
{
|
||||
if (!minigamesInBeatmap.Contains(minigames.Find(c => c.name == GameManager.instance.Beatmap.entities[i].datamodel.Split('/')[0])) && GameManager.instance.Beatmap.entities[i].datamodel.Split('/')[0] != "gameManager")
|
||||
@ -164,7 +79,7 @@ namespace RhythmHeavenMania
|
||||
public void CallEvent(string event_)
|
||||
{
|
||||
string[] details = event_.Split('/');
|
||||
MiniGame game = minigames.Find(c => c.name == details[0]);
|
||||
Minigames.Minigame game = minigames.Find(c => c.name == details[0]);
|
||||
|
||||
try
|
||||
{
|
||||
@ -174,7 +89,7 @@ namespace RhythmHeavenMania
|
||||
|
||||
if (details.Length > 2) currentSwitchGame = details[2];
|
||||
|
||||
GameAction action = game.actions.Find(c => c.actionName == details[1]);
|
||||
Minigames.GameAction action = game.actions.Find(c => c.actionName == details[1]);
|
||||
action.function.Invoke();
|
||||
|
||||
if (action.playerAction == true)
|
||||
|
@ -279,13 +279,13 @@ namespace RhythmHeavenMania
|
||||
preloadedGames.Add(g);
|
||||
}
|
||||
|
||||
public EventCaller.MiniGame GetGame(string name)
|
||||
public Minigames.Minigame GetGame(string name)
|
||||
{
|
||||
return eventCaller.minigames.Find(c => c.name == name);
|
||||
}
|
||||
|
||||
// never gonna use this
|
||||
public EventCaller.MiniGame GetCurrentGame()
|
||||
public Minigames.Minigame GetCurrentGame()
|
||||
{
|
||||
return eventCaller.minigames.Find(c => c.name == transform.GetComponentsInChildren<Transform>()[1].name);
|
||||
}
|
||||
|
@ -251,12 +251,11 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
RemovePea();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShotGame("forkLifter/stabnohit");
|
||||
}
|
||||
}
|
||||
|
||||
if (!canHit)
|
||||
Jukebox.PlayOneShotGame("forkLifter/stabnohit", false);
|
||||
|
||||
anim.Play("Player_Stab", 0, 0);
|
||||
}
|
||||
|
||||
|
@ -162,15 +162,15 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
p.isEligible = false;
|
||||
p.RemoveObject(currentHitInList);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShotGame("karateman/swingNoHit");
|
||||
}
|
||||
if (punchLeft)
|
||||
anim.Play("PunchLeft", 0, 0);
|
||||
else
|
||||
anim.Play("PunchRight", 0, 0);
|
||||
}
|
||||
|
||||
if (!canHit)
|
||||
Jukebox.PlayOneShotGame("karateman/swingNoHit");
|
||||
|
||||
if (punchLeft)
|
||||
anim.Play("PunchLeft", 0, 0);
|
||||
else
|
||||
anim.Play("PunchRight", 0, 0);
|
||||
}
|
||||
|
||||
public void HitEffectF(Vector3 pos)
|
||||
|
@ -20,7 +20,7 @@ namespace RhythmHeavenMania.Editor
|
||||
private RectTransform eventsParent;
|
||||
|
||||
[Header("Properties")]
|
||||
private EventCaller.MiniGame mg;
|
||||
private Minigames.Minigame mg;
|
||||
private bool gameOpen;
|
||||
[SerializeField] private int currentEventIndex;
|
||||
private int dragTimes;
|
||||
|
@ -21,6 +21,7 @@ namespace RhythmHeavenMania.Editor
|
||||
private bool lastFrameDrag;
|
||||
public int LayerCount = 4;
|
||||
public bool metronomeEnabled;
|
||||
public bool resizable;
|
||||
|
||||
[Header("Timeline Components")]
|
||||
[SerializeField] private RectTransform TimelineSlider;
|
||||
@ -305,13 +306,28 @@ namespace RhythmHeavenMania.Editor
|
||||
else
|
||||
eventObj.Icon.sprite = Editor.GameIcon(eventName.Split(0));
|
||||
|
||||
EventCaller.GameAction gameAction = EventCaller.instance.GetGameAction(EventCaller.instance.GetMinigame(eventName.Split(0)), eventName.Split(1));
|
||||
Minigames.GameAction gameAction = EventCaller.instance.GetGameAction(EventCaller.instance.GetMinigame(eventName.Split(0)), eventName.Split(1));
|
||||
|
||||
if (gameAction != null)
|
||||
{
|
||||
g.GetComponent<RectTransform>().sizeDelta = new Vector2(gameAction.defaultLength, LayerHeight());
|
||||
float length = gameAction.defaultLength;
|
||||
eventObj.length = length;
|
||||
if (gameAction.resizable == false)
|
||||
{
|
||||
g.GetComponent<RectTransform>().sizeDelta = new Vector2(gameAction.defaultLength, LayerHeight());
|
||||
float length = gameAction.defaultLength;
|
||||
eventObj.length = length;
|
||||
}
|
||||
else
|
||||
{
|
||||
eventObj.resizable = true;
|
||||
if (gameAction.defaultLength != GameManager.instance.Beatmap.entities[entityId].length)
|
||||
{
|
||||
g.GetComponent<RectTransform>().sizeDelta = new Vector2(GameManager.instance.Beatmap.entities[entityId].length, LayerHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
g.GetComponent<RectTransform>().sizeDelta = new Vector2(gameAction.defaultLength, LayerHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g.SetActive(true);
|
||||
@ -335,7 +351,6 @@ namespace RhythmHeavenMania.Editor
|
||||
else
|
||||
{
|
||||
var entity = GameManager.instance.Beatmap.entities[entityId];
|
||||
var e = GameManager.instance.Beatmap.entities[entityId];
|
||||
|
||||
entity.eventObj = g.GetComponent<TimelineEventObj>();
|
||||
entity.track = (int)(g.transform.localPosition.y / LayerHeight() * -1);
|
||||
@ -361,7 +376,7 @@ namespace RhythmHeavenMania.Editor
|
||||
|
||||
public bool IsEventsDragging()
|
||||
{
|
||||
return Timeline.instance.eventObjs.FindAll(c => c.isDragging == true).Count > 0;
|
||||
return eventObjs.FindAll(c => c.isDragging == true).Count > 0 || eventObjs.FindAll(c => c.resizing == true).Count > 0;
|
||||
}
|
||||
|
||||
public float SnapToLayer(float y)
|
||||
|
@ -15,6 +15,7 @@ namespace RhythmHeavenMania.Editor
|
||||
public bool isDragging;
|
||||
|
||||
private Vector3 lastPos;
|
||||
private RectTransform rectTransform;
|
||||
|
||||
[Header("Components")]
|
||||
[SerializeField] private RectTransform PosPreview;
|
||||
@ -28,15 +29,28 @@ namespace RhythmHeavenMania.Editor
|
||||
private bool lastVisible;
|
||||
public bool selected;
|
||||
public bool mouseHovering;
|
||||
public bool resizable;
|
||||
public bool resizing;
|
||||
|
||||
[Header("Colors")]
|
||||
public Color NormalCol;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
|
||||
if (!resizable)
|
||||
{
|
||||
Destroy(transform.GetChild(5).gameObject);
|
||||
Destroy(transform.GetChild(6).gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
entity = GameManager.instance.Beatmap.entities.Find(a => a.eventObj == this);
|
||||
|
||||
mouseHovering = RectTransformUtility.RectangleContainsScreenPoint(GetComponent<RectTransform>(), Input.mousePosition, Camera.main);
|
||||
mouseHovering = RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main);
|
||||
|
||||
#region Optimizations
|
||||
|
||||
@ -67,7 +81,25 @@ namespace RhythmHeavenMania.Editor
|
||||
transform.GetChild(3).gameObject.SetActive(true);
|
||||
|
||||
for (int i = 0; i < transform.GetChild(4).childCount; i++)
|
||||
{
|
||||
transform.GetChild(4).GetChild(i).GetComponent<Image>().color = Color.cyan;
|
||||
}
|
||||
|
||||
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
|
||||
Vector3[] v = new Vector3[4];
|
||||
rectTransform.GetWorldCorners(v);
|
||||
|
||||
if (mouseHovering)
|
||||
{
|
||||
if (mousePos.x > transform.position.x && mousePos.x < transform.position.x + 0.1f)
|
||||
{
|
||||
}
|
||||
else if (mousePos.x > v[3].x - 0.1f && mousePos.x < v[3].x)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -83,50 +115,143 @@ namespace RhythmHeavenMania.Editor
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (Input.GetMouseButtonDown(0) && Timeline.instance.IsMouseAboveEvents())
|
||||
if (!resizing)
|
||||
{
|
||||
if (selected)
|
||||
if (Input.GetMouseButtonDown(0) && Timeline.instance.IsMouseAboveEvents())
|
||||
{
|
||||
if (selected)
|
||||
{
|
||||
Vector3 mousePos;
|
||||
mousePos = Input.mousePosition;
|
||||
mousePos = Camera.main.ScreenToWorldPoint(mousePos);
|
||||
startPosX = mousePos.x - this.transform.position.x;
|
||||
startPosY = mousePos.y - this.transform.position.y;
|
||||
|
||||
isDragging = true;
|
||||
}
|
||||
}
|
||||
else if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
if (!mouseHovering && !isDragging && !BoxSelection.instance.selecting)
|
||||
{
|
||||
if (!Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
Selections.instance.Deselect(this);
|
||||
}
|
||||
}
|
||||
|
||||
OnUp();
|
||||
}
|
||||
if (isDragging && selected)
|
||||
{
|
||||
Vector3 mousePos;
|
||||
mousePos = Input.mousePosition;
|
||||
mousePos = Camera.main.ScreenToWorldPoint(mousePos);
|
||||
startPosX = mousePos.x - this.transform.position.x;
|
||||
startPosY = mousePos.y - this.transform.position.y;
|
||||
|
||||
isDragging = true;
|
||||
this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
|
||||
this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(this.transform.localPosition.y));
|
||||
|
||||
if (lastPos != transform.localPosition)
|
||||
OnMove();
|
||||
|
||||
lastPos = this.transform.localPosition;
|
||||
}
|
||||
}
|
||||
else if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
if (!mouseHovering && !isDragging && !BoxSelection.instance.selecting)
|
||||
{
|
||||
if (!Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
Selections.instance.Deselect(this);
|
||||
}
|
||||
}
|
||||
|
||||
OnUp();
|
||||
}
|
||||
|
||||
if (isDragging && selected)
|
||||
{
|
||||
Vector3 mousePos;
|
||||
mousePos = Input.mousePosition;
|
||||
mousePos = Camera.main.ScreenToWorldPoint(mousePos);
|
||||
|
||||
this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
|
||||
this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(this.transform.localPosition.y));
|
||||
|
||||
if (lastPos != transform.localPosition)
|
||||
OnMove();
|
||||
|
||||
lastPos = this.transform.localPosition;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region ResizeEvents
|
||||
|
||||
public void DragEnter()
|
||||
{
|
||||
if (selected)
|
||||
Cursor.SetCursor(Resources.Load<Texture2D>("Cursors/horizontal_resize"), new Vector2(8, 8), CursorMode.Auto);
|
||||
}
|
||||
|
||||
public void DragExit()
|
||||
{
|
||||
if (!resizing)
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
}
|
||||
|
||||
public void OnLeftDown()
|
||||
{
|
||||
if (selected)
|
||||
{
|
||||
SetPivot(new Vector2(1, rectTransform.pivot.y));
|
||||
resizing = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void DragLeft()
|
||||
{
|
||||
if (!resizing) return;
|
||||
|
||||
Vector2 sizeDelta = rectTransform.sizeDelta;
|
||||
|
||||
Vector2 mousePos;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Camera.main, out mousePos);
|
||||
|
||||
sizeDelta = new Vector2(-mousePos.x + 0.1f, sizeDelta.y);
|
||||
sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, 0.25f, rectTransform.localPosition.x), sizeDelta.y);
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, 0.25f), sizeDelta.y);
|
||||
}
|
||||
|
||||
public void OnLeftUp()
|
||||
{
|
||||
SetPivot(new Vector2(0, rectTransform.pivot.y));
|
||||
resizing = false;
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
public void OnRightDown()
|
||||
{
|
||||
if (selected)
|
||||
{
|
||||
SetPivot(new Vector2(0, rectTransform.pivot.y));
|
||||
resizing = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void DragRight()
|
||||
{
|
||||
if (!resizing) return;
|
||||
// if (!mouseHovering) return;
|
||||
|
||||
Vector2 sizeDelta = rectTransform.sizeDelta;
|
||||
|
||||
Vector2 mousePos;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Camera.main, out mousePos);
|
||||
|
||||
sizeDelta = new Vector2(mousePos.x, sizeDelta.y);
|
||||
sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, 0.25f, Mathf.Infinity), sizeDelta.y);
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, 0.25f), sizeDelta.y);
|
||||
}
|
||||
|
||||
public void OnRightUp()
|
||||
{
|
||||
resizing = false;
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
private void SetPivot(Vector2 pivot)
|
||||
{
|
||||
if (rectTransform == null) return;
|
||||
|
||||
Vector2 size = rectTransform.rect.size;
|
||||
Vector2 deltaPivot = rectTransform.pivot - pivot;
|
||||
Vector3 deltaPosition = new Vector3(deltaPivot.x * size.x, deltaPivot.y * size.y);
|
||||
rectTransform.pivot = pivot;
|
||||
rectTransform.localPosition -= deltaPosition;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnEvents
|
||||
|
||||
private void OnMove()
|
||||
{
|
||||
if (GameManager.instance.Beatmap.entities.FindAll(c => c.beat == this.transform.localPosition.x && c.track == GetTrack()).Count > 0)
|
||||
@ -141,11 +266,14 @@ namespace RhythmHeavenMania.Editor
|
||||
|
||||
private void OnComplete()
|
||||
{
|
||||
entity.length = rectTransform.sizeDelta.x;
|
||||
entity.beat = this.transform.localPosition.x;
|
||||
GameManager.instance.SortEventsList();
|
||||
entity.track = GetTrack();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClickEvents
|
||||
|
||||
public void OnDown()
|
||||
|
101
Assets/Scripts/Minigames.cs
Normal file
101
Assets/Scripts/Minigames.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
using RhythmHeavenMania.Games.ForkLifter;
|
||||
using RhythmHeavenMania.Games.ClappyTrio;
|
||||
using RhythmHeavenMania.Games.Spaceball;
|
||||
using RhythmHeavenMania.Games.KarateMan;
|
||||
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
public class Minigames
|
||||
{
|
||||
public class Minigame
|
||||
{
|
||||
public string name;
|
||||
public string displayName;
|
||||
public string color;
|
||||
public GameObject holder;
|
||||
public List<GameAction> actions = new List<GameAction>();
|
||||
|
||||
public Minigame(string name, string displayName, string color, List<GameAction> actions)
|
||||
{
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
this.color = color;
|
||||
this.actions = actions;
|
||||
}
|
||||
}
|
||||
|
||||
public class GameAction
|
||||
{
|
||||
public string actionName;
|
||||
public EventCallback function;
|
||||
public bool playerAction = false;
|
||||
public float defaultLength;
|
||||
public bool resizable;
|
||||
|
||||
public GameAction(string actionName, EventCallback function, float defaultLength = 1, bool playerAction = false, bool resizable = false)
|
||||
{
|
||||
this.actionName = actionName;
|
||||
this.function = function;
|
||||
this.playerAction = playerAction;
|
||||
this.defaultLength = defaultLength;
|
||||
this.resizable = resizable;
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void EventCallback();
|
||||
|
||||
public static void Init(EventCaller eventCaller)
|
||||
{
|
||||
eventCaller.minigames = new List<Minigame>()
|
||||
{
|
||||
new Minigame("gameManager", "Game Manager", "", new List<GameAction>()
|
||||
{
|
||||
new GameAction("end", delegate { Debug.Log("end"); }),
|
||||
new GameAction("switchGame", delegate { GameManager.instance.SwitchGame(eventCaller.currentSwitchGame); })
|
||||
}),
|
||||
new Minigame("forkLifter", "Fork Lifter", "FFFFFF", new List<GameAction>()
|
||||
{
|
||||
new GameAction("pea", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 0); }, 3, true),
|
||||
new GameAction("topbun", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 1); }, 3, true),
|
||||
new GameAction("burger", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 2); }, 3, true),
|
||||
new GameAction("bottombun", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 3); }, 3, true),
|
||||
new GameAction("prepare", delegate { ForkLifter.instance.ForkLifterHand.Prepare(); }, 0.5f, true),
|
||||
new GameAction("gulp", delegate { ForkLifterPlayer.instance.Eat(); }),
|
||||
new GameAction("sigh", delegate { Jukebox.PlayOneShot("sigh"); })
|
||||
}),
|
||||
new Minigame("clappyTrio", "The Clappy Trio", "29E7FF", new List<GameAction>()
|
||||
{
|
||||
new GameAction("clap", delegate { ClappyTrio.instance.Clap(eventCaller.currentBeat, eventCaller.currentLength); }, 3, true),
|
||||
new GameAction("bop", delegate { ClappyTrio.instance.Bop(eventCaller.currentBeat); } ),
|
||||
new GameAction("prepare", delegate { ClappyTrio.instance.Prepare(0); } ),
|
||||
new GameAction("prepare_alt", delegate { ClappyTrio.instance.Prepare(3); } ),
|
||||
}),
|
||||
new Minigame("spaceball", "Spaceball", "00A518", new List<GameAction>()
|
||||
{
|
||||
new GameAction("shoot", delegate { Spaceball.instance.Shoot(eventCaller.currentBeat, false, eventCaller.currentType); }, 2, true),
|
||||
new GameAction("shootHigh", delegate { Spaceball.instance.Shoot(eventCaller.currentBeat, true, eventCaller.currentType); }, 3, true),
|
||||
new GameAction("costume", delegate { Spaceball.instance.Costume(eventCaller.currentType); } ),
|
||||
new GameAction("alien", delegate { Spaceball.instance.alien.Show(eventCaller.currentBeat); } ),
|
||||
new GameAction("cameraZoom", delegate { }, 4, false, true ),
|
||||
}),
|
||||
new Minigame("karateman", "Karate Man", "70A8D8", new List<GameAction>()
|
||||
{
|
||||
new GameAction("bop", delegate { KarateMan.instance.Bop(eventCaller.currentBeat, eventCaller.currentLength); }, 0.5f, true, true),
|
||||
new GameAction("pot", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 0); }, 2, true),
|
||||
new GameAction("bulb", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 1); }, 2, true),
|
||||
new GameAction("rock", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 2); }, 2, true),
|
||||
new GameAction("ball", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 3); }, 2, true),
|
||||
new GameAction("kick", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 4); }, 4.5f, true),
|
||||
new GameAction("bgfxon", delegate { KarateMan.instance.BGFXOn(); } ),
|
||||
new GameAction("bgfxoff", delegate { KarateMan.instance.BGFXOff(); }),
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Minigames.cs.meta
Normal file
11
Assets/Scripts/Minigames.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d314b8e6c105df4b9bffa399e9c2dcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user