prefab done

fixes to camera, bops and player input
This commit is contained in:
minenice55 2024-01-04 20:50:57 -05:00
parent 481a6c77f9
commit dea7f8a521
8 changed files with 4918 additions and 360 deletions

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View file

@ -51,7 +51,7 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1 spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1 alphaUsage: 1
alphaIsTransparency: 0 alphaIsTransparency: 1
spriteTessellationDetail: -1 spriteTessellationDetail: -1
textureType: 0 textureType: 0
textureShape: 1 textureShape: 1

View file

@ -2,14 +2,17 @@
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000 --- !u!21 &2100000
Material: Material:
serializedVersion: 6 serializedVersion: 8
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: ball_trail m_Name: ball_trail
m_Shader: {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON _GLOSSYREFLECTIONS_OFF m_ValidKeywords: []
m_InvalidKeywords:
- _ALPHAPREMULTIPLY_ON
- _GLOSSYREFLECTIONS_OFF
m_LightmapFlags: 4 m_LightmapFlags: 4
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0 m_DoubleSidedGI: 0
@ -49,7 +52,7 @@ Material:
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- _MainTex: - _MainTex:
m_Texture: {fileID: 0} m_Texture: {fileID: 2800000, guid: bc88d6ad84763e146a8a1618d386f8e4, type: 3}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- _MetallicGlossMap: - _MetallicGlossMap:
@ -80,6 +83,7 @@ Material:
m_Texture: {fileID: 0} m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats: m_Floats:
- PixelSnap: 0 - PixelSnap: 0
- _AlphaClip: 0 - _AlphaClip: 0

View file

@ -16,6 +16,9 @@ namespace HeavenStudio.Games.Scripts_RhythmRally
private Animator opponentAnim; private Animator opponentAnim;
private Conductor cond; private Conductor cond;
public bool PlayerDown { get { return playerDown; } }
bool playerDown = false;
public void Init() public void Init()
{ {
game = RhythmRally.instance; game = RhythmRally.instance;
@ -31,20 +34,23 @@ namespace HeavenStudio.Games.Scripts_RhythmRally
if (PlayerInput.GetIsAction(RhythmRally.InputAction_BasicPress)) if (PlayerInput.GetIsAction(RhythmRally.InputAction_BasicPress))
{ {
playerAnim.Play("Ready1"); playerAnim.Play("Ready1");
playerDown = true;
} }
if (PlayerInput.GetIsAction(RhythmRally.InputAction_BasicRelease)) if (PlayerInput.GetIsAction(RhythmRally.InputAction_BasicRelease))
{ {
playerAnim.Play("UnReady1"); playerAnim.Play("UnReady1");
playerDown = false;
} }
} }
else else
{ {
if (!game.served || game.missed || !game.started) return; if (!game.started) return;
} }
if (PlayerInput.GetIsAction(RhythmRally.InputAction_FlickPress) && !game.IsExpectingInputNow(RhythmRally.InputAction_FlickPress)) if (PlayerInput.GetIsAction(RhythmRally.InputAction_FlickPress) && !game.IsExpectingInputNow(RhythmRally.InputAction_FlickPress))
{ {
// Play "whoosh" sound here // Play "whoosh" sound here
playerAnim.DoScaledAnimationAsync("Swing", 0.5f); playerAnim.DoScaledAnimationAsync("Swing", 0.5f);
playerDown = false;
} }
} }
@ -65,7 +71,8 @@ namespace HeavenStudio.Games.Scripts_RhythmRally
bounceBeat = game.serveBeat + game.targetBeat + 0.5f; bounceBeat = game.serveBeat + game.targetBeat + 0.5f;
} }
playerAnim.DoScaledAnimationAsync("Swing", 0.5f); ; playerAnim.DoScaledAnimationAsync("Swing", 0.5f);
playerDown = false;
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("rhythmRally/Return", hitBeat), new MultiSound.Sound("rhythmRally/ReturnBounce", bounceBeat) }); MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("rhythmRally/Return", hitBeat), new MultiSound.Sound("rhythmRally/ReturnBounce", bounceBeat) });
BounceFX(bounceBeat); BounceFX(bounceBeat);
game.ball.SetActive(true); game.ball.SetActive(true);
@ -75,7 +82,8 @@ namespace HeavenStudio.Games.Scripts_RhythmRally
{ {
MissBall(); MissBall();
SoundByte.PlayOneShot("miss"); SoundByte.PlayOneShot("miss");
playerAnim.DoScaledAnimationAsync("Swing", 0.5f); ; playerAnim.DoScaledAnimationAsync("Swing", 0.5f);
playerDown = false;
game.missCurve.KeyPoints[0].Position = game.ball.transform.position; game.missCurve.KeyPoints[0].Position = game.ball.transform.position;
game.missCurve.transform.localScale = new Vector3(-state, 1f, 1f); game.missCurve.transform.localScale = new Vector3(-state, 1f, 1f);

View file

@ -2,11 +2,12 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using NaughtyBezierCurves; using NaughtyBezierCurves;
using DG.Tweening;
using HeavenStudio.Util; using HeavenStudio.Util;
using HeavenStudio.InputSystem; using HeavenStudio.InputSystem;
using Jukebox;
namespace HeavenStudio.Games.Loaders namespace HeavenStudio.Games.Loaders
{ {
using static Minigames; using static Minigames;
@ -88,16 +89,16 @@ namespace HeavenStudio.Games.Loaders
{ {
function = delegate { function = delegate {
var e = eventCaller.currentEntity; var e = eventCaller.currentEntity;
var rotation = new Vector3(0, e["valA"], 0); // var rotation = new Vector3(0, e["valA"], 0);
RhythmRally.instance.ChangeCameraAngle(rotation, e["valB"], e.length, (Ease)e["type"], (RotateMode)e["type2"]); RhythmRally.instance.ChangeCameraAngle(e.beat, e["valA"], e["valB"], e.length, (Util.EasingFunction.Ease)e["type"]);
}, },
defaultLength = 4, defaultLength = 4,
resizable = true, resizable = true,
parameters = new List<Param>() { parameters = new List<Param>() {
new Param("valA", new EntityTypes.Integer(-360, 360, 0), "Angle", "The rotation of the camera around the center of the table"), new Param("valA", new EntityTypes.Integer(-360, 360, 0), "Angle", "The rotation of the camera around the center of the table"),
new Param("valB", new EntityTypes.Float(0.5f, 4f, 1), "Zoom", "The camera's level of zoom (Lower value = Zoomed in)"), new Param("valB", new EntityTypes.Float(0.5f, 4f, 1), "Zoom", "The camera's level of zoom (Lower value = Zoomed in)"),
new Param("type", Ease.Linear, "Ease", "The easing function to use"), new Param("type", Util.EasingFunction.Ease.Linear, "Ease", "The easing function to use"),
new Param("type2", RotateMode.Fast, "Rotation Mode", "The rotation mode to use") // new Param("type2", RotateMode.Fast, "Rotation Mode", "The rotation mode to use")
} }
}, },
}, },
@ -125,7 +126,7 @@ namespace HeavenStudio.Games
[Header("Ball and curve info")] [Header("Ball and curve info")]
public GameObject ball; public GameObject ball;
public GameObject ballShadow; public GameObject ballShadow;
public TrailRenderer ballTrail; public ParticleSystem ballTrail;
public BezierCurve3D serveCurve; public BezierCurve3D serveCurve;
public BezierCurve3D returnCurve; public BezierCurve3D returnCurve;
public BezierCurve3D tossCurve; public BezierCurve3D tossCurve;
@ -167,8 +168,19 @@ namespace HeavenStudio.Games
SetupBopRegion("rhythmRally", "bop", "bopAuto"); SetupBopRegion("rhythmRally", "bop", "bopAuto");
} }
private void Start()
{
EntityPreCheck(Conductor.instance.songPositionInBeatsAsDouble);
}
const float tableHitTime = 0.58f; const float tableHitTime = 0.58f;
bool opponentServing = false; // Opponent serving this frame? bool opponentServing = false; // Opponent serving this frame?
double cameraRotateBeat = double.MaxValue;
double cameraRotateLength;
Util.EasingFunction.Ease cameraRotateEase;
float cameraRotateLast = 0, cameraScaleLast = 1;
float cameraRotateNext = 0, cameraScaleNext = 1;
void Update() void Update()
{ {
var cond = Conductor.instance; var cond = Conductor.instance;
@ -274,10 +286,8 @@ namespace HeavenStudio.Games
} }
} }
// TODO: Make conditional so ball shadow only appears when over table.
ballShadow.transform.position = new Vector3(ball.transform.position.x, -0.399f, ball.transform.position.z); ballShadow.transform.position = new Vector3(ball.transform.position.x, -0.399f, ball.transform.position.z);
var timeBeforeNextHit = hitBeat + beatDur1 + beatDur2 - currentBeat; var timeBeforeNextHit = hitBeat + beatDur1 + beatDur2 - currentBeat;
// Check if the opponent should swing. // Check if the opponent should swing.
@ -342,7 +352,8 @@ namespace HeavenStudio.Games
} }
// If player never swung and is still in ready state, snap them out of it. // If player never swung and is still in ready state, snap them out of it.
if (missed && playerState.IsName("Ready1")) // only if they're not manually preparing via touch controls
if (missed && playerState.IsName("Ready1") && (!paddlers.PlayerDown))
playerAnim.Play("Beat"); playerAnim.Play("Beat");
} }
} }
@ -358,6 +369,47 @@ namespace HeavenStudio.Games
opponentServing = false; opponentServing = false;
//update camera //update camera
UpdateCamera(currentBeat);
}
public override void OnPlay(double beat)
{
EntityPreCheck(beat);
}
void EntityPreCheck(double beat)
{
cameraRotateBeat = double.MaxValue;
cameraRotateLength = 0;
cameraRotateEase = Util.EasingFunction.Ease.Linear;
cameraRotateLast = 0; cameraScaleLast = 1;
cameraRotateNext = 0; cameraScaleNext = 1;
List<RiqEntity> prevEntities = GameManager.instance.Beatmap.Entities.FindAll(c => c.beat < beat && c.datamodel.Split(0) == "rhythmRally");
RiqEntity lastGameSwitch = GameManager.instance.Beatmap.Entities.FindLast(c => c.beat <= beat && c.datamodel == "gameManager/switchGame/rhythmRally");
if (lastGameSwitch == null) return;
List<RiqEntity> cameraEntities = prevEntities.FindAll(c => c.beat >= lastGameSwitch.beat && c.datamodel == "rhythmRally/camera");
foreach (var entity in cameraEntities)
{
ChangeCameraAngle(entity.beat, entity["valA"], entity["valB"], entity.length, (Util.EasingFunction.Ease)entity["type"]);
}
UpdateCamera(beat);
}
void UpdateCamera(double beat)
{
if (beat >= cameraRotateBeat)
{
Util.EasingFunction.Function func = Util.EasingFunction.GetEasingFunction(cameraRotateEase);
float rotProg = Conductor.instance.GetPositionFromBeat(cameraRotateBeat, cameraRotateLength, true);
float rot = func(cameraRotateLast, cameraRotateNext, rotProg);
cameraPivot.rotation = Quaternion.Euler(0, rot, 0);
cameraPivot.localScale = Vector3.one * func(cameraScaleLast, cameraScaleNext, rotProg);
}
GameCamera.AdditionalPosition = cameraPos.position + (Quaternion.Euler(cameraPos.rotation.eulerAngles) * Vector3.forward * 10f); GameCamera.AdditionalPosition = cameraPos.position + (Quaternion.Euler(cameraPos.rotation.eulerAngles) * Vector3.forward * 10f);
GameCamera.AdditionalRotEuler = cameraPos.rotation.eulerAngles; GameCamera.AdditionalRotEuler = cameraPos.rotation.eulerAngles;
GameCamera.AdditionalFoV = cameraFOV; GameCamera.AdditionalFoV = cameraFOV;
@ -395,10 +447,10 @@ namespace HeavenStudio.Games
bool playerPrepping = false; // Player using prep animation? bool playerPrepping = false; // Player using prep animation?
bool opponentPrepping = false; // Opponent using prep animation? bool opponentPrepping = false; // Opponent using prep animation?
if (!playerPrepping && (playerAnim.IsAnimationNotPlaying() || playerState.IsName("Idle") || playerState.IsName("Beat"))) if ((!playerPrepping) && (!paddlers.PlayerDown) && (playerAnim.IsAnimationNotPlaying() || playerState.IsName("Idle") || playerState.IsName("Beat")))
playerAnim.DoScaledAnimationAsync("Beat", 0.5f); playerAnim.DoScaledAnimationAsync("Beat", 0.5f);
if (!opponentPrepping && !opponentServing && !tossing && (opponentAnim.IsAnimationNotPlaying() || opponentState.IsName("Idle") || opponentState.IsName("Beat"))) if ((!opponentPrepping) && (!opponentServing) && (!tossing) && (opponentAnim.IsAnimationNotPlaying() || opponentState.IsName("Idle") || opponentState.IsName("Beat")))
opponentAnim.DoScaledAnimationAsync("Beat", 0.5f); opponentAnim.DoScaledAnimationAsync("Beat", 0.5f);
} }
@ -492,11 +544,15 @@ namespace HeavenStudio.Games
inPose = true; inPose = true;
} }
public void ChangeCameraAngle(Vector3 rotation, float camZoom, float length, Ease ease, RotateMode rotateMode) public void ChangeCameraAngle(double beat, float rotation, float camZoom, double length, Util.EasingFunction.Ease ease)
{ {
var len = length * Conductor.instance.secPerBeat; cameraRotateBeat = beat;
cameraPivot.DORotate(rotation, len, rotateMode).SetEase(ease); cameraRotateLength = length;
cameraPivot.DOScale(camZoom, len).SetEase(ease); cameraRotateEase = ease;
cameraRotateLast = cameraRotateNext;
cameraScaleLast = cameraScaleNext;
cameraRotateNext = rotation;
cameraScaleNext = camZoom;
} }
public void PrepareFastRally(double beat, RallySpeed speedChange, bool muteAudio = false) public void PrepareFastRally(double beat, RallySpeed speedChange, bool muteAudio = false)