HeavenStudio/Assets/Scripts/Games/DogNinja/SpawnHalves.cs
minenice55 caf7d9465f
Play Mode Features Part 1 (#413)
* add pause menu assets

* layout and animation for pause

* make play mode prefab function

re-assign unused class inheritance

* remove filepath

* don't init medals twice

* remove PlayerActionObject

* initial attempt at anti-note lock

TODO: circumvent inputs clearing themselves making the functionality not work

* properly implement input lock prevention

* fix error on editor open

* functional pause menu

* bugfix

* make unpausing not reset current play statistics

* serialize initializer components in inspector instead of procedurally generating

* sanity check

* note for fade

* make flashes in the camera prefabs instead of in world space

remove / reorganize script files
address issue #411

* fix bug with perfect campaign

make minigame transitions hide the game canvas
adjust animation of the song credits textbox

* fully functional intro scene (placeholder for future title screen)

refactored entire game loading procedure
re-organized some files

* add interaction query to disclaimer text

* reword legal

* anchor section medals to section display

more tempo change placement controls

* operation order bugfix

* prep for future ratings and stats

* loading text

* autoload opening scene

* splash screen adjustments

added setting to force enable splash screen

* adjust setting entry
2023-05-07 20:33:15 +00:00

64 lines
2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using NaughtyBezierCurves;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_DogNinja
{
public class SpawnHalves : MonoBehaviour
{
public float startBeat;
public Vector3 objPos;
private Vector3 posModifier;
public bool lefty;
float bpmModifier;
float songPos;
[SerializeField] float rotSpeed;
[Header("References")]
[SerializeField] BezierCurve3D fallLeftCurve;
[SerializeField] BezierCurve3D fallRightCurve;
BezierCurve3D curve;
[SerializeField] Transform halvesParent;
private DogNinja game;
private void Awake()
{
game = DogNinja.instance;
bpmModifier = Conductor.instance.songBpm / 100;
songPos = Conductor.instance.songPositionInBeats;
}
private void Start()
{
curve = lefty ? fallRightCurve : fallLeftCurve;
}
private void Update()
{
float flyPosHalves = (Conductor.instance.GetPositionFromBeat(songPos, 3f)*(Conductor.instance.GetPositionFromBeat(songPos, 2f)))+Conductor.instance.GetPositionFromBeat(songPos, 1f);
flyPosHalves = (flyPosHalves*0.2f)+0.35f;
transform.position = curve.GetPoint(flyPosHalves)+objPos;
float rot = rotSpeed;
rot *= lefty ? bpmModifier : -1 * bpmModifier;
transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z + (rot * Time.deltaTime));
// clean-up logic
if (flyPosHalves > 1f) {
GameObject.Destroy(gameObject);
};
if ((!Conductor.instance.isPlaying && !Conductor.instance.isPaused)
|| GameManager.instance.currentGame != "dogNinja") {
GameObject.Destroy(gameObject);
};
}
}
}