mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 11:57:40 +02:00
Initialize game with one script
This commit is contained in:
@ -20,7 +20,7 @@ namespace RhythmHeavenMania
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Cursor.visible = false;
|
||||
// Cursor.visible = false;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -38,7 +38,7 @@ namespace RhythmHeavenMania
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
Cursor.visible = false;
|
||||
// Cursor.visible = false;
|
||||
Circle.transform.DOScale(0, 0.5f).SetEase(Ease.OutExpo);
|
||||
InnerCircle.SetActive(true);
|
||||
outerCircleTween.Kill();
|
||||
|
@ -7,7 +7,7 @@ using Starpelly;
|
||||
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
// [RequireComponent(typeof(AudioSource))]
|
||||
public class Conductor : MonoBehaviour
|
||||
{
|
||||
//Song beats per minute
|
||||
|
@ -49,6 +49,7 @@ namespace RhythmHeavenMania
|
||||
CreateDebugUI(out graphicsDeviceName, true); SetText(graphicsDeviceName, SystemInfo.graphicsDeviceName);
|
||||
CreateDebugUI(out fps, true);
|
||||
|
||||
transform.GetChild(0).GetComponent<Canvas>().worldCamera = GameManager.instance.CursorCam;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
@ -95,9 +95,9 @@ namespace RhythmHeavenMania
|
||||
new GameAction("alien", delegate { Spaceball.instance.alien.Show(currentBeat); } ),
|
||||
new GameAction("cameraZoom", delegate { } ),
|
||||
}),
|
||||
new MiniGame("karateman", "F6C135", new List<GameAction>()
|
||||
new MiniGame("karateman", "70A8D8", new List<GameAction>()
|
||||
{
|
||||
new GameAction("bop", delegate { KarateMan.instance.Bop(); } ),
|
||||
new GameAction("bop", delegate { KarateMan.instance.Bop(currentBeat, currentLength); } ),
|
||||
new GameAction("pot", delegate { KarateMan.instance.Shoot(currentBeat, 0); }, true ),
|
||||
new GameAction("bulb", delegate { KarateMan.instance.Shoot(currentBeat, 1); }, true ),
|
||||
new GameAction("rock", delegate { KarateMan.instance.Shoot(currentBeat, 2); }, true ),
|
||||
|
@ -16,7 +16,7 @@ namespace RhythmHeavenMania
|
||||
private EventCaller eventCaller;
|
||||
|
||||
public Beatmap Beatmap;
|
||||
[HideInInspector] public List<Beatmap.Entity> playerEntities;
|
||||
[HideInInspector] public List<Beatmap.Entity> playerEntities = new List<Beatmap.Entity>();
|
||||
|
||||
public int currentEvent, currentPlayerEvent;
|
||||
|
||||
@ -37,15 +37,23 @@ namespace RhythmHeavenMania
|
||||
|
||||
private List<GameObject> preloadedGames = new List<GameObject>();
|
||||
|
||||
[HideInInspector] public GameObject GamesHolder;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
// before Start() since this is very important
|
||||
private void OnEnable()
|
||||
private void Start()
|
||||
{
|
||||
SortEventsList();
|
||||
this.transform.localScale = new Vector3(3000, 3000);
|
||||
SpriteRenderer sp = this.gameObject.AddComponent<SpriteRenderer>();
|
||||
sp.enabled = false;
|
||||
sp.color = Color.black;
|
||||
sp.sprite = Resources.Load<Sprite>("Sprites/GeneralPurpose/Square");
|
||||
sp.sortingOrder = 30000;
|
||||
this.gameObject.layer = 3;
|
||||
|
||||
string json = txt.text;
|
||||
Beatmap = JsonConvert.DeserializeObject<Beatmap>(json);
|
||||
@ -54,7 +62,8 @@ namespace RhythmHeavenMania
|
||||
|
||||
GlobalGameManager.Init();
|
||||
|
||||
eventCaller = GetComponent<EventCaller>();
|
||||
eventCaller = this.gameObject.AddComponent<EventCaller>();
|
||||
eventCaller.GamesHolder = GamesHolder.transform;
|
||||
eventCaller.Init();
|
||||
Conductor.instance.SetBpm(Beatmap.bpm);
|
||||
|
||||
@ -136,9 +145,12 @@ namespace RhythmHeavenMania
|
||||
if (Beatmap.entities.Count > 0)
|
||||
{
|
||||
List<float> entities = Beatmap.entities.Select(c => c.beat).ToList();
|
||||
List<float> entities_p = playerEntities.Select(c => c.beat).ToList();
|
||||
if (playerEntities != null)
|
||||
{
|
||||
List<float> entities_p = playerEntities.Select(c => c.beat).ToList();
|
||||
currentPlayerEvent = entities_p.IndexOf(Mathp.GetClosestInList(entities_p, beat));
|
||||
}
|
||||
currentEvent = entities.IndexOf(Mathp.GetClosestInList(entities, beat));
|
||||
currentPlayerEvent = entities_p.IndexOf(Mathp.GetClosestInList(entities_p, beat));
|
||||
|
||||
print(currentEvent);
|
||||
|
||||
|
@ -22,6 +22,9 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
private bool bgEnabled;
|
||||
private int newBeat;
|
||||
|
||||
private float bopLength;
|
||||
private float bopBeat;
|
||||
|
||||
[System.Serializable]
|
||||
public class BGSpriteC
|
||||
{
|
||||
@ -35,17 +38,26 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (bgEnabled)
|
||||
|
||||
if (Conductor.instance.songPositionInBeats > newBeat)
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats > newBeat)
|
||||
if (bgEnabled)
|
||||
{
|
||||
if (newBeat % 2 == 0)
|
||||
BGSprite.sprite = BGSprites[0].Sprites[1];
|
||||
else
|
||||
BGSprite.sprite = BGSprites[0].Sprites[2];
|
||||
|
||||
newBeat++;
|
||||
}
|
||||
|
||||
if (Conductor.instance.songPositionInBeats >= bopBeat && Conductor.instance.songPositionInBeats < bopBeat + bopLength)
|
||||
{
|
||||
if (KarateJoe.anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1 && !KarateJoe.anim.IsInTransition(0))
|
||||
KarateJoe.anim.Play("Bop", 0, 0);
|
||||
|
||||
print("bop");
|
||||
}
|
||||
|
||||
newBeat++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +116,10 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
}
|
||||
}
|
||||
|
||||
public void Bop()
|
||||
public void Bop(float beat, float length)
|
||||
{
|
||||
KarateJoe.anim.Play("Bop", 0, 0);
|
||||
bopLength = length;
|
||||
bopBeat = beat;
|
||||
}
|
||||
}
|
||||
}
|
44
Assets/Scripts/Initializer.cs
Normal file
44
Assets/Scripts/Initializer.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
public class Initializer : MonoBehaviour
|
||||
{
|
||||
public TextAsset level;
|
||||
public AudioClip music;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameObject Cameras = Instantiate(Resources.Load<GameObject>("Prefabs/Cameras")); Cameras.name = "Cameras";
|
||||
GameObject MainCamera = Cameras.transform.GetChild(0).gameObject;
|
||||
GameObject CursorCamera = Cameras.transform.GetChild(1).gameObject;
|
||||
|
||||
GameObject Cursor = Instantiate(Resources.Load<GameObject>("Prefabs/Cursor"));
|
||||
Cursor.name = "Cursor";
|
||||
|
||||
GameObject Games = new GameObject();
|
||||
Games.name = "Games";
|
||||
|
||||
GameObject GameManager = new GameObject();
|
||||
GameManager.name = "GameManager";
|
||||
GameManager gameManager = GameManager.AddComponent<GameManager>();
|
||||
|
||||
gameManager.txt = level;
|
||||
gameManager.GamesHolder = Games;
|
||||
gameManager.CircleCursor = Cursor.transform.GetChild(0).GetComponent<CircleCursor>();
|
||||
gameManager.GameCamera = MainCamera.GetComponent<Camera>();
|
||||
gameManager.CursorCam = CursorCamera.GetComponent<Camera>();
|
||||
|
||||
GameObject Profiler = Instantiate(Resources.Load<GameObject>("Prefabs/GameProfiler"));
|
||||
Profiler.name = "GameProfiler";
|
||||
|
||||
GameObject Conductor = new GameObject();
|
||||
Conductor.name = "Conductor";
|
||||
Conductor.AddComponent<AudioSource>().clip = music;
|
||||
Conductor.AddComponent<Conductor>();
|
||||
Conductor.AddComponent<AudioDspTimeKeeper>();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Initializer.cs.meta
Normal file
11
Assets/Scripts/Initializer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f86858990a87c764892672104bdaef1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -50
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/LevelEditor.meta
Normal file
8
Assets/Scripts/LevelEditor.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20cdf044bf1f13b42af96f23ac825cff
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
26
Assets/Scripts/LevelEditor/Editor.cs
Normal file
26
Assets/Scripts/LevelEditor/Editor.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RhythmHeavenMania.Editor
|
||||
{
|
||||
public class Editor : MonoBehaviour
|
||||
{
|
||||
private Initializer Initializer;
|
||||
|
||||
[Header("Rect")]
|
||||
[SerializeField] private RenderTexture ScreenRenderTexture;
|
||||
[SerializeField] private RawImage Screen;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Initializer = GetComponent<Initializer>();
|
||||
|
||||
GameManager.instance.GameCamera.targetTexture = ScreenRenderTexture;
|
||||
GameManager.instance.CursorCam.targetTexture = ScreenRenderTexture;
|
||||
Screen.texture = ScreenRenderTexture;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/LevelEditor/Editor.cs.meta
Normal file
11
Assets/Scripts/LevelEditor/Editor.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28c29f0a107b3e14bb0493419464c89f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user