ball wip
This commit is contained in:
parent
366216c576
commit
d15b5ac6c5
File diff suppressed because it is too large
Load diff
91
Assets/Scripts/Games/HoleInOne/Ball.cs
Normal file
91
Assets/Scripts/Games/HoleInOne/Ball.cs
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using NaughtyBezierCurves;
|
||||||
|
|
||||||
|
namespace HeavenStudio.Games.Scripts_HoleInOne
|
||||||
|
{
|
||||||
|
using HeavenStudio.Util;
|
||||||
|
public class Ball : MonoBehaviour
|
||||||
|
{
|
||||||
|
[System.NonSerialized] public double startBeat;
|
||||||
|
private double currentBeat;
|
||||||
|
|
||||||
|
public BezierCurve3D[] curve;
|
||||||
|
private BezierCurve3D currentCurve;
|
||||||
|
|
||||||
|
private HoleInOne game;
|
||||||
|
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
game = HoleInOne.instance;
|
||||||
|
currentCurve = curve[0];
|
||||||
|
currentBeat = startBeat + 1;
|
||||||
|
game.ScheduleInput(startBeat, 2f, HoleInOne.InputAction_FlickPress, MonkeySuccess, MonkeyMiss, Empty);
|
||||||
|
}
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
var cond = Conductor.instance;
|
||||||
|
|
||||||
|
if (currentCurve is not null)
|
||||||
|
{
|
||||||
|
if (currentCurve == curve[0])
|
||||||
|
{
|
||||||
|
float curveProg = cond.GetPositionFromBeat(currentBeat, 3);
|
||||||
|
if (curveProg > 0.55f) curveProg = (curveProg - 0.55f)/4 + 0.55f;
|
||||||
|
transform.position = currentCurve.GetPoint(curveProg);
|
||||||
|
}
|
||||||
|
else if (currentCurve == curve[1])
|
||||||
|
{
|
||||||
|
float curveProg = cond.GetPositionFromBeat(currentBeat, 2);
|
||||||
|
transform.position = currentCurve.GetPoint(curveProg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MonkeySuccess(PlayerActionEvent caller, float state)
|
||||||
|
{
|
||||||
|
if (state >= 1f || state <= -1f)
|
||||||
|
{
|
||||||
|
double beat = caller.startBeat + caller.timer;
|
||||||
|
|
||||||
|
SoundByte.PlayOneShotGame("holeInOne/mandrill1"); // temp should be barely
|
||||||
|
SoundByte.PlayOneShotGame("holeInOne/hole2", beat + 1f); // temp should be splash
|
||||||
|
|
||||||
|
game.MonkeyHeadAnim.DoScaledAnimationAsync("MonkeyMissHead", 1f);
|
||||||
|
game.GolferAnim.Play("GolferWhiff", 0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double beat = caller.startBeat + caller.timer;
|
||||||
|
int randomSuccess = UnityEngine.Random.Range(1,4);
|
||||||
|
|
||||||
|
currentCurve = curve[1];
|
||||||
|
currentBeat = beat;
|
||||||
|
|
||||||
|
MultiSound.Play(new MultiSound.Sound[] {
|
||||||
|
new MultiSound.Sound("holeInOne/monkey3", beat),
|
||||||
|
new MultiSound.Sound((game.isWhale) ? "holeInOne/whale" : ("holeInOne/hole" + randomSuccess), beat + 2f)
|
||||||
|
});
|
||||||
|
|
||||||
|
BeatAction.New(game, new List<BeatAction.Action>()
|
||||||
|
{
|
||||||
|
new BeatAction.Action(beat, delegate { game.MonkeyHeadAnim.DoScaledAnimationAsync("MonkeyJustHead", 1f);}),
|
||||||
|
new BeatAction.Action(beat, delegate { game.GolferAnim.Play("GolferJust", 0, 0);}),
|
||||||
|
new BeatAction.Action(beat + 1.5f, delegate { game.Hole.SetActive(true);}),
|
||||||
|
new BeatAction.Action(beat + 2f, delegate {
|
||||||
|
game.HoleAnim.DoScaledAnimationAsync("ZoomSmall" + randomSuccess, 1f);
|
||||||
|
Destroy(gameObject);
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MonkeyMiss(PlayerActionEvent caller)
|
||||||
|
{
|
||||||
|
SoundByte.PlayOneShotGame("holeInOne/whale");
|
||||||
|
game.MonkeyHeadAnim.DoScaledAnimationAsync("MonkeySadHead", 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Empty(PlayerActionEvent caller) {}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/Games/HoleInOne/Ball.cs.meta
Normal file
11
Assets/Scripts/Games/HoleInOne/Ball.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ae79da0792289be4d8e1d58a85b7534f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -60,8 +60,11 @@ namespace HeavenStudio.Games.Loaders
|
||||||
|
|
||||||
namespace HeavenStudio.Games
|
namespace HeavenStudio.Games
|
||||||
{
|
{
|
||||||
|
using Scripts_HoleInOne;
|
||||||
public class HoleInOne : Minigame
|
public class HoleInOne : Minigame
|
||||||
{
|
{
|
||||||
|
[SerializeField] GameObject baseBall;
|
||||||
|
|
||||||
public Animator MonkeyAnim;
|
public Animator MonkeyAnim;
|
||||||
public Animator MonkeyHeadAnim;
|
public Animator MonkeyHeadAnim;
|
||||||
public Animator MandrillAnim;
|
public Animator MandrillAnim;
|
||||||
|
@ -74,7 +77,7 @@ namespace HeavenStudio.Games
|
||||||
double whaleStartBeat;
|
double whaleStartBeat;
|
||||||
float whaleLength;
|
float whaleLength;
|
||||||
Util.EasingFunction.Ease lastEase;
|
Util.EasingFunction.Ease lastEase;
|
||||||
bool isWhale;
|
public bool isWhale { get; private set; }
|
||||||
|
|
||||||
public static HoleInOne instance;
|
public static HoleInOne instance;
|
||||||
|
|
||||||
|
@ -151,7 +154,7 @@ namespace HeavenStudio.Games
|
||||||
public void DoMonkey(double beat)
|
public void DoMonkey(double beat)
|
||||||
{
|
{
|
||||||
//Monkey Multisound
|
//Monkey Multisound
|
||||||
ScheduleInput(beat, 2f, InputAction_FlickPress, MonkeySuccess, MonkeyMiss, Empty);
|
// ScheduleInput(beat, 2f, InputAction_FlickPress, MonkeySuccess, MonkeyMiss, Empty);
|
||||||
MultiSound.Play(new MultiSound.Sound[] {
|
MultiSound.Play(new MultiSound.Sound[] {
|
||||||
new MultiSound.Sound("holeInOne/monkey1", beat),
|
new MultiSound.Sound("holeInOne/monkey1", beat),
|
||||||
new MultiSound.Sound("holeInOne/monkey2", beat + 1f)
|
new MultiSound.Sound("holeInOne/monkey2", beat + 1f)
|
||||||
|
@ -170,7 +173,7 @@ namespace HeavenStudio.Games
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
SpawnBall(beat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoMandrill(double beat)
|
public void DoMandrill(double beat)
|
||||||
|
@ -203,6 +206,20 @@ namespace HeavenStudio.Games
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SpawnBall(double beat)
|
||||||
|
{
|
||||||
|
var newBall = Instantiate(baseBall, transform).GetComponent<Ball>();
|
||||||
|
newBall.startBeat = beat;
|
||||||
|
|
||||||
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
||||||
|
{
|
||||||
|
new BeatAction.Action(beat + 1f, delegate {
|
||||||
|
newBall.gameObject.SetActive(true);
|
||||||
|
newBall.Init();
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void MonkeySuccess(PlayerActionEvent caller, float state)
|
public void MonkeySuccess(PlayerActionEvent caller, float state)
|
||||||
{
|
{
|
||||||
if (state >= 1f || state <= -1f)
|
if (state >= 1f || state <= -1f)
|
||||||
|
|
Loading…
Reference in a new issue