mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-08 18:55:07 +00:00
Air Rally Fixes (#252)
* fix clouds * add hit effects fix jank with shuttle movement * make near miss effect snap to player hit position * add easing to forthington movement * try different shuttle rotation method * Revert "try different shuttle rotation method" This reverts commit 96c0d56fd6f3fe57be2aeabdd24e85c728da3097. * try other rotation method
This commit is contained in:
parent
0f7c413fbd
commit
81d2e3af68
8 changed files with 7161 additions and 2399 deletions
File diff suppressed because it is too large
Load diff
|
@ -83,6 +83,12 @@ TextureImporter:
|
|||
- first:
|
||||
213: -1969074579828895637
|
||||
second: Fort_Left_Arm
|
||||
- first:
|
||||
213: 8759155364766697816
|
||||
second: AirRally_1_27
|
||||
- first:
|
||||
213: 4088167666801983468
|
||||
second: AirRally_1_28
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
|
@ -537,7 +543,7 @@ TextureImporter:
|
|||
width: 404
|
||||
height: 404
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
|
@ -558,7 +564,7 @@ TextureImporter:
|
|||
width: 404
|
||||
height: 404
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
|
@ -579,7 +585,7 @@ TextureImporter:
|
|||
width: 340
|
||||
height: 596
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
|
@ -600,7 +606,7 @@ TextureImporter:
|
|||
width: 276
|
||||
height: 308
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
|
@ -621,7 +627,7 @@ TextureImporter:
|
|||
width: 340
|
||||
height: 340
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
|
@ -642,7 +648,7 @@ TextureImporter:
|
|||
width: 340
|
||||
height: 340
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
|
@ -663,7 +669,7 @@ TextureImporter:
|
|||
width: 404
|
||||
height: 340
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
|
@ -684,7 +690,7 @@ TextureImporter:
|
|||
width: 276
|
||||
height: 276
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
|
@ -705,7 +711,7 @@ TextureImporter:
|
|||
width: 276
|
||||
height: 308
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
|
@ -726,7 +732,7 @@ TextureImporter:
|
|||
width: 276
|
||||
height: 276
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
|
@ -738,6 +744,48 @@ TextureImporter:
|
|||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
- serializedVersion: 2
|
||||
name: AirRally_1_27
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 743
|
||||
y: 7
|
||||
width: 722
|
||||
height: 754
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: 0
|
||||
bones: []
|
||||
spriteID: 85940617565ce8970800000000000000
|
||||
internalID: 8759155364766697816
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
- serializedVersion: 2
|
||||
name: AirRally_1_28
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 3239
|
||||
y: 3751
|
||||
width: 338
|
||||
height: 338
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: 0
|
||||
bones: []
|
||||
spriteID: cef38f935d61cb830800000000000000
|
||||
internalID: 4088167666801983468
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace HeavenStudio.Games.Loaders
|
|||
},
|
||||
new GameAction("ba bum bum bum", "Ba Bum Bum Bum")
|
||||
{
|
||||
function = delegate { AirRally.instance.SetDistance(e.currentEntity["type"]); AirRally.instance.BaBumBumBum(e.currentEntity.beat, e.currentEntity["toggle"], e.currentEntity["type"]); },
|
||||
function = delegate { AirRally.instance.BaBumBumBum(e.currentEntity.beat, e.currentEntity["toggle"], e.currentEntity["type"]); },
|
||||
defaultLength = 7f,
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
|
@ -93,13 +93,6 @@ namespace HeavenStudio.Games
|
|||
[Header("Waypoint")]
|
||||
public float wayPointZForForth;
|
||||
|
||||
[Header("Curves")]
|
||||
public BezierCurve3D closeRallyCurve;
|
||||
public BezierCurve3D farRallyCurve;
|
||||
public BezierCurve3D fartherRallyCurve;
|
||||
public BezierCurve3D farthestRallyCurve;
|
||||
public BezierCurve3D closeRallyReturnCurve;
|
||||
|
||||
[Header("Debug")]
|
||||
public float beatShown;
|
||||
public float lengthHolder;
|
||||
|
@ -143,12 +136,8 @@ namespace HeavenStudio.Games
|
|||
if(lengthHolder != lengthShown)
|
||||
{
|
||||
started = true;
|
||||
//convert to 2 decimal places
|
||||
var f = currentBeat;
|
||||
//f = Mathf.Round(f * 10.0f) * 0.1f;
|
||||
Rally(serveBeat + (int)f, wantSilent, lengthHolder);
|
||||
//Debug.Log("Beat Loop: " + serveBeat + f);
|
||||
//Debug.Log("Serve Beat: " + serveBeat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,6 +174,8 @@ namespace HeavenStudio.Games
|
|||
shuttleScript.flyType = type;
|
||||
|
||||
shuttleActive = true;
|
||||
|
||||
Forthington.GetComponent<Animator>().Play("Hit");
|
||||
}
|
||||
|
||||
public void ReturnObject(float beat, float targetBeat, bool type)
|
||||
|
@ -307,7 +298,7 @@ namespace HeavenStudio.Games
|
|||
}
|
||||
else
|
||||
{
|
||||
tweenForForth = Forthington.gameObject.transform.DOMoveZ(wayPointZForForth, .15f);
|
||||
tweenForForth = Forthington.gameObject.transform.DOMoveZ(wayPointZForForth, .15f).SetEase(Ease.InOutCubic);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,8 +321,6 @@ namespace HeavenStudio.Games
|
|||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
//new BeatAction.Action(beat, delegate { Forthington.GetComponent<Animator>().Play("Ready");} ),
|
||||
new BeatAction.Action(beat, delegate { Forthington.GetComponent<Animator>().Play("Hit");} ),
|
||||
new BeatAction.Action(beat, delegate { ServeObject(beat, beat + 1, false); } ),
|
||||
});
|
||||
|
||||
|
@ -476,13 +465,13 @@ namespace HeavenStudio.Games
|
|||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 0.5f, delegate { SetDistance(type, false); }),
|
||||
new BeatAction.Action(beat + 1.5f, delegate { Forthington.GetComponent<Animator>().Play("Ready"); }),
|
||||
new BeatAction.Action(beat + 2.5f, delegate { if(babum) { Forthington.GetComponent<Animator>().Play("Hit"); } }),
|
||||
new BeatAction.Action(beat + 2.5f, delegate { ServeObject(beat + 2.5f, beat + 4.5f, true); } ),
|
||||
new BeatAction.Action(beat + 3.5f, delegate { Forthington.GetComponent<Animator>().Play("TalkShort"); }),
|
||||
new BeatAction.Action(beat + 4f, delegate { if(!count) Forthington.GetComponent<Animator>().Play("TalkShort"); }),
|
||||
new BeatAction.Action(beat + 4.5f, delegate { Forthington.GetComponent<Animator>().Play("Ready"); }),
|
||||
new BeatAction.Action(beat + 7f, delegate { if(babum) { babum = false; } }),
|
||||
new BeatAction.Action(beat + 5.5f, delegate { if(babum) { babum = false; } }),
|
||||
});
|
||||
|
||||
MultiSound.Play(new MultiSound.Sound[] {
|
||||
|
@ -527,6 +516,7 @@ namespace HeavenStudio.Games
|
|||
{
|
||||
ReturnObject(Conductor.instance.songPositionInBeats, caller.startBeat + caller.timer + 1f, false);
|
||||
hasMissed = false;
|
||||
ActiveShuttle.GetComponent<Shuttlecock>().DoHit(e_BaBumState);
|
||||
|
||||
if (e_BaBumState == DistanceSound.close)
|
||||
{
|
||||
|
@ -562,6 +552,7 @@ namespace HeavenStudio.Games
|
|||
{
|
||||
ReturnObject(Conductor.instance.songPositionInBeats, caller.startBeat + caller.timer + 2f, true);
|
||||
hasMissed = false;
|
||||
ActiveShuttle.GetComponent<Shuttlecock>().DoHit(e_BaBumState);
|
||||
|
||||
if (e_BaBumState == DistanceSound.close)
|
||||
{
|
||||
|
|
71
Assets/Scripts/Games/AirRally/Cloud.cs
Normal file
71
Assets/Scripts/Games/AirRally/Cloud.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_AirRally
|
||||
{
|
||||
public class Cloud : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Sprite[] sprites;
|
||||
[SerializeField] Vector3 spawnRange;
|
||||
[SerializeField] float baseSpeed = 1f;
|
||||
[SerializeField] float fadeDist = 10f;
|
||||
[SerializeField] float lifeTime = 6f;
|
||||
[SerializeField] float fadeInTime = 0.25f;
|
||||
|
||||
Camera cam;
|
||||
SpriteRenderer spriteRenderer;
|
||||
float time = 0f;
|
||||
|
||||
public bool isWorking = false;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
cam = GameCamera.GetCamera();
|
||||
spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
spriteRenderer.color = new Color(1, 1, 1, 0);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
transform.position += Vector3.forward * -baseSpeed * Time.deltaTime;
|
||||
|
||||
// get distance to camera
|
||||
float dist = Vector3.Distance(cam.transform.position, transform.position);
|
||||
if (dist <= fadeDist)
|
||||
{
|
||||
spriteRenderer.color = new Color(1, 1, 1, Mathf.Clamp01(dist / fadeDist));
|
||||
}
|
||||
else if (time < fadeInTime)
|
||||
{
|
||||
spriteRenderer.color = new Color(1, 1, 1, Mathf.Clamp01(time/fadeInTime));
|
||||
}
|
||||
|
||||
if (time > lifeTime)
|
||||
{
|
||||
isWorking = false;
|
||||
gameObject.SetActive(false);
|
||||
spriteRenderer.color = new Color(1, 1, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void StartCloud(Vector3 origin, bool prebake)
|
||||
{
|
||||
isWorking = true;
|
||||
time = 0f;
|
||||
gameObject.SetActive(true);
|
||||
spriteRenderer.sprite = sprites[Random.Range(0, sprites.Length)];
|
||||
transform.position = origin;
|
||||
transform.position += new Vector3(Random.Range(-spawnRange.x, spawnRange.x), Random.Range(-spawnRange.y, spawnRange.y), Random.Range(-spawnRange.z, spawnRange.z));
|
||||
if (prebake)
|
||||
{
|
||||
time = Random.Range(0, lifeTime);
|
||||
transform.position += Vector3.forward * -baseSpeed * time;
|
||||
float dist = Vector3.Distance(cam.transform.position, transform.position);
|
||||
spriteRenderer.color = new Color(1, 1, 1, Mathf.Clamp01(dist / fadeDist));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/AirRally/Cloud.cs.meta
Normal file
11
Assets/Scripts/Games/AirRally/Cloud.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 891c0b37d3276da4fa7ea5ba3332dc13
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
65
Assets/Scripts/Games/AirRally/CloudsManager.cs
Normal file
65
Assets/Scripts/Games/AirRally/CloudsManager.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_AirRally
|
||||
{
|
||||
public class CloudsManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Transform cloudRoot;
|
||||
[SerializeField] GameObject cloudPrefab;
|
||||
[SerializeField] int maxCloudAmt = 32;
|
||||
[SerializeField] int cloudsToPreBake = 10;
|
||||
[SerializeField] float cloudRepeatRate = 0.1f;
|
||||
|
||||
|
||||
Cloud[] pool;
|
||||
float time = 0f;
|
||||
float lastTime = 0f;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
pool = new Cloud[maxCloudAmt];
|
||||
for (int i = 0; i < maxCloudAmt; i++)
|
||||
{
|
||||
GameObject cloudObj = Instantiate(cloudPrefab, cloudRoot);
|
||||
cloudObj.SetActive(false);
|
||||
pool[i] = cloudObj.GetComponent<Cloud>();
|
||||
pool[i].Init();
|
||||
}
|
||||
|
||||
for (int i = 0; i < cloudsToPreBake; i++)
|
||||
{
|
||||
Cloud cloud = GetAvailableCloud();
|
||||
if (cloud != null)
|
||||
{
|
||||
cloud.StartCloud(cloudRoot.position, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cloud GetAvailableCloud()
|
||||
{
|
||||
foreach (Cloud cloud in pool)
|
||||
{
|
||||
if (!cloud.isWorking)
|
||||
{
|
||||
return cloud;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
if (time - lastTime > cloudRepeatRate)
|
||||
{
|
||||
lastTime = time;
|
||||
GetAvailableCloud()?.StartCloud(cloudRoot.position, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/AirRally/CloudsManager.cs.meta
Normal file
11
Assets/Scripts/Games/AirRally/CloudsManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f9a1426575a6edb4b8f43668daac9f21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -13,6 +13,7 @@ namespace HeavenStudio.Games.Scripts_AirRally
|
|||
[SerializeField] Transform OtherTarget;
|
||||
[SerializeField] float TargetHeight;
|
||||
[SerializeField] float TargetHeightLong;
|
||||
[SerializeField] ParticleSystem hitEffect;
|
||||
|
||||
public float startBeat;
|
||||
public float flyBeats;
|
||||
|
@ -30,7 +31,7 @@ namespace HeavenStudio.Games.Scripts_AirRally
|
|||
|
||||
void Start()
|
||||
{
|
||||
|
||||
transform.position = OtherTarget.position;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
@ -38,13 +39,12 @@ namespace HeavenStudio.Games.Scripts_AirRally
|
|||
{
|
||||
var cond = Conductor.instance;
|
||||
|
||||
Vector3 startPos = isReturning ? PlayerTarget.position : OtherTarget.position;
|
||||
Vector3 endPos = isReturning ? OtherTarget.position : PlayerTarget.position;
|
||||
Vector3 lastPos = transform.position;
|
||||
if (!GetComponent<Rigidbody2D>().simulated)
|
||||
{
|
||||
float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
|
||||
|
||||
Vector3 startPos = isReturning ? PlayerTarget.position : OtherTarget.position;
|
||||
Vector3 endPos = isReturning ? OtherTarget.position : PlayerTarget.position;
|
||||
flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
|
||||
|
||||
transform.position = Vector3.LerpUnclamped(startPos, endPos, flyPos);
|
||||
|
||||
|
@ -53,11 +53,26 @@ namespace HeavenStudio.Games.Scripts_AirRally
|
|||
transform.position += Vector3.up * yWeight * (flyType ? TargetHeightLong : TargetHeight);
|
||||
}
|
||||
|
||||
// calculates next position
|
||||
{
|
||||
float rotation;
|
||||
if (flyPos > 0.5)
|
||||
{
|
||||
Vector3 midPos = Vector3.LerpUnclamped(startPos, endPos, 0.5f);
|
||||
midPos += Vector3.up * (flyType ? TargetHeightLong : TargetHeight);
|
||||
Vector3 direction = (transform.position - midPos).normalized;
|
||||
rotation = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 direction = (transform.position - lastPos).normalized;
|
||||
float rotation = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
|
||||
this.transform.eulerAngles = new Vector3(0, 0, rotation - 90f);
|
||||
rotation = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
|
||||
}
|
||||
|
||||
if (miss && flyPos > 2f)
|
||||
this.transform.eulerAngles = new Vector3(0, 0, rotation - 90f);
|
||||
}
|
||||
|
||||
if (miss && flyPos > 4f)
|
||||
{
|
||||
if (cond.GetPositionFromBeat(startBeat, flyBeats + 1f) >= 1f)
|
||||
{
|
||||
|
@ -67,16 +82,38 @@ namespace HeavenStudio.Games.Scripts_AirRally
|
|||
}
|
||||
}
|
||||
|
||||
public void DoHit(AirRally.DistanceSound distance)
|
||||
{
|
||||
ParticleSystem.MainModule main = hitEffect.main;
|
||||
switch (distance)
|
||||
{
|
||||
case AirRally.DistanceSound.close:
|
||||
main.startSize = 2f;
|
||||
break;
|
||||
case AirRally.DistanceSound.far:
|
||||
main.startSize = 3f;
|
||||
break;
|
||||
case AirRally.DistanceSound.farther:
|
||||
main.startSize = 4f;
|
||||
break;
|
||||
case AirRally.DistanceSound.farthest:
|
||||
main.startSize = 6f;
|
||||
break;
|
||||
}
|
||||
hitEffect.Play();
|
||||
}
|
||||
|
||||
public void DoNearMiss()
|
||||
{
|
||||
miss = true;
|
||||
Jukebox.PlayOneShot("miss");
|
||||
transform.position = PlayerTarget.position;
|
||||
Rigidbody2D rb = GetComponent<Rigidbody2D>();
|
||||
rb.simulated = true;
|
||||
rb.WakeUp();
|
||||
rb.velocity = Vector3.zero;
|
||||
rb.gravityScale = 10f;
|
||||
rb.AddForce(Vector2.up * 10, ForceMode2D.Impulse);
|
||||
rb.AddForce(Vector2.up * 20, ForceMode2D.Impulse);
|
||||
rb.AddForce(Vector2.right * -10, ForceMode2D.Impulse);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue