Resource Optimization (#812)

* right foot creep

* look around stay low

* optimize the fan club prefab

use anim layers for the monkeys

* dansa med oss

* klappa era hander

* cossack sandvich

* soldier of dance

add speed halving / doubling functionality to choreographies

* fix selection of starting dance

* asset re-organization

* organize the last of the 1.0 games

* Wall

* floating windows can no longer become larger than the actual screen
This commit is contained in:
minenice55
2024-03-29 22:52:14 -04:00
committed by GitHub
parent eb9cd7f9fa
commit 1c6eae8005
7323 changed files with 153398 additions and 57789 deletions

View File

@ -1,8 +1,8 @@
using System;
public static class AppInfo {
public const string Version = "1.0.8";
public static readonly DateTime Date = new DateTime(2024, 03, 11, 23, 05, 18, 869, DateTimeKind.Utc);
public const string Version = "1.0.9";
public static readonly DateTime Date = new DateTime(2024, 03, 29, 20, 52, 02, 483, DateTimeKind.Utc);
}

View File

@ -1191,6 +1191,7 @@ namespace HeavenStudio
var gameInfo = GetGameInfo(name);
if (gameInfo != null)
{
GameObject prefab;
if (gameInfo.inferred)
{
return Resources.Load<GameObject>($"Games/noGame");
@ -1226,10 +1227,28 @@ namespace HeavenStudio
catch (Exception e)
{
Debug.LogWarning($"Failed to load assetbundle for game {name}, using sync loading: {e.Message}");
return Resources.Load<GameObject>($"Games/{name}");
prefab = Resources.Load<GameObject>($"Games/{name}");
if (prefab != null)
{
return prefab;
}
else
{
Debug.LogWarning($"Game {name} not found, using noGame");
return Resources.Load<GameObject>($"Games/noGame");
}
}
}
return Resources.Load<GameObject>($"Games/{name}");
prefab = Resources.Load<GameObject>($"Games/{name}");
if (prefab != null)
{
return prefab;
}
else
{
Debug.LogWarning($"Game {name} not found, using noGame");
return Resources.Load<GameObject>($"Games/noGame");
}
}
else
{

View File

@ -258,6 +258,7 @@ namespace HeavenStudio.Games
//spawn 12, the 4th is our player (idx 3)
Vector3 origin = spectatorAnchor.transform.localPosition;
int sortOrigin = spectatorAnchor.GetComponent<SortingGroup>().sortingOrder;
int row = 1;
Vector3 spawnPos = new Vector3(origin.x, origin.y, origin.z);
spawnPos.x -= RADIUS * 2 * 3;
for (int i = 0; i < FAN_COUNT; i++)
@ -265,7 +266,8 @@ namespace HeavenStudio.Games
GameObject mobj = Instantiate(spectator, spectatorAnchor.transform.parent);
NtrIdolFan fan = mobj.GetComponent<NtrIdolFan>();
mobj.transform.localPosition = new Vector3(spawnPos.x, spawnPos.y, spawnPos.z);
mobj.GetComponent<SortingGroup>().sortingOrder = i + sortOrigin;
fan.SetRow(row, sortOrigin);
// mobj.GetComponent<SortingGroup>().sortingOrder = i + sortOrigin;
if (i == 3)
{
Player = fan;
@ -284,7 +286,7 @@ namespace HeavenStudio.Games
spawnPos = new Vector3(origin.x, origin.y, origin.z);
spawnPos.x -= RADIUS * 2 * 4 - RADIUS;
spawnPos.y -= RADIUS;
// spawnPos.z -= RADIUS/4;
row++;
}
}

View File

@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering; //don't ask
using System;
using NaughtyBezierCurves;
@ -15,8 +16,8 @@ namespace HeavenStudio.Games.Scripts_FanClub
[Header("References")]
[SerializeField] private GameObject motionRoot;
[SerializeField] private GameObject headRoot;
[SerializeField] private SortingGroup sortingGroup;
public Animator animator;
public Animator headAnimator;
public ParticleSystem fanClapEffect;
public GameObject shadow;
@ -273,11 +274,19 @@ namespace HeavenStudio.Games.Scripts_FanClub
public void MakeAngry(bool flip = false)
{
headAnimator.Play("FanFaceAngry", -1, 0);
if (flip)
{
headRoot.transform.localScale = new Vector3(-1f, 1f, 1f);
animator.Play("Head.FanFaceAngryFlip", -1, 0);
}
else
{
animator.Play("Head.FanFaceAngry", -1, 0);
}
}
public void SetRow(int row, int origin = 0)
{
sortingGroup.sortingOrder = origin + row;
}
}
}

View File

@ -20,5 +20,7 @@ namespace HeavenStudio.StudioDance
public List<ChoreographyStep> choreographySteps;
public string poseStateOdd;
public string poseStateEven;
public double halfSpeedBpm;
public double doubleSpeedBpm;
}
}

View File

@ -8,6 +8,8 @@ namespace HeavenStudio.StudioDance
{
[SerializeField] ChoreographyInfo debugChoreography;
[SerializeField] ChoreographyInfo[] choreographies;
Conductor cond;
GameManager gm;
private Animator animator;
private double currentBeat = 0f;
@ -40,17 +42,18 @@ namespace HeavenStudio.StudioDance
totalChoreographyLength += step.beatLength;
}
if (!Conductor.instance.isPlaying)
if (cond is not null && animator is not null && !cond.isPlaying)
{
animator.Play(currentChoreography.introState);
animator.Play(currentChoreography.introState, -1, 0f);
}
}
private void Start()
{
animator = GetComponent<Animator>();
cond = Conductor.instance;
gm = GameManager.instance;
var gm = GameManager.instance;
if (gm != null)
{
gm.onBeatPulse += OnBeatPulse;
@ -61,7 +64,19 @@ namespace HeavenStudio.StudioDance
SetChoreography(debugChoreography);
}
animator.Play(currentChoreography.introState);
animator.Play(currentChoreography.introState, -1, 0f);
}
public void SetStartChoreography()
{
if (debugChoreography != null)
{
SetChoreography(debugChoreography);
}
else
{
SetChoreography(0);
}
}
private void OnBeatPulse(double beat)
@ -71,43 +86,55 @@ namespace HeavenStudio.StudioDance
private void Update()
{
var cond = Conductor.instance;
if (currentChoreography == null || cond == null) return;
if (!cond.isPlaying)
{
if (!isDance) return;
if (currentBeat % 2 != 0)
{
animator.Play(currentChoreography.poseStateOdd);
animator.Play(currentChoreography.poseStateOdd, -1, 0f);
}
else
{
animator.Play(currentChoreography.poseStateEven);
animator.Play(currentChoreography.poseStateEven, -1, 0f);
}
isDance = false;
return;
}
isDance = true;
double choreoBeat = cond.songPositionInBeatsAsDouble % totalChoreographyLength;
double cycleStartBeat = Math.Floor(cond.songPositionInBeatsAsDouble / totalChoreographyLength) * totalChoreographyLength;
float speed = 1f;
if (currentChoreography.halfSpeedBpm != currentChoreography.doubleSpeedBpm)
{
if (cond.songBpm < currentChoreography.halfSpeedBpm)
{
speed = 0.5f;
}
else if (cond.songBpm > currentChoreography.doubleSpeedBpm)
{
speed = 2f;
}
}
double choreoBeat = cond.songPositionInBeatsAsDouble % (totalChoreographyLength * speed);
double cycleStartBeat = Math.Floor(cond.songPositionInBeatsAsDouble / (totalChoreographyLength * speed)) * (totalChoreographyLength * speed);
double beatSum = 0.0;
double stepLength = 0.0;
string stepState = "";
foreach (ChoreographyInfo.ChoreographyStep s in currentChoreography.choreographySteps)
{
if (choreoBeat > beatSum && choreoBeat < beatSum + s.beatLength)
if (choreoBeat > beatSum && choreoBeat < beatSum + (s.beatLength * speed))
{
stepLength = s.beatLength;
stepLength = s.beatLength * speed;
stepState = s.stateName;
break;
}
beatSum += s.beatLength;
beatSum += s.beatLength * speed;
}
if (stepState is not null or "")
{
animator.DoScaledAnimation(stepState, cycleStartBeat + beatSum, stepLength);
animator.DoScaledAnimation(stepState, cycleStartBeat + beatSum, stepLength, animLayer: -1, clamp: true);
}
}
}

View File

@ -18,18 +18,20 @@ namespace HeavenStudio.StudioDance
{
windowBase.SetActive(true);
content.SetActive(true);
dancer.SetStartChoreography();
dropdown.ClearOptions();
int startIdx = 0;
int i = 0;
foreach (ChoreographyInfo choreography in dancer.ChoreographyInfos)
{
dropdown.options.Add(new TMP_Dropdown.OptionData(choreography.choreographyName));
if (choreography == dancer.CurrentChoreography)
{
dropdown.value = startIdx;
dropdown.value = i;
}
startIdx++;
i++;
}
dropdown.RefreshShownValue();
}
public void CloseDanceWindow()

View File

@ -132,16 +132,6 @@ namespace HeavenStudio
{
Debug.LogWarning("Game loader RvlBookLoader failed!");
}
game = NtrFreezeFrameLoader.AddGame(eventCaller);
if (game != null)
{
eventCaller.minigames.Add(game.name, game);
}
else
{
Debug.LogWarning("Game loader NtrCameraManLoader failed!");
}
game = AgbClapLoader.AddGame(eventCaller);
if (game != null)