Moved all minigame initialization to Awake()

I just moved everything that was in start to awake. There are a few other changes I made, like using init functions rather than awake in scripts that depended on something that was initialized in another script's awake (to make sure things always happen in the right order), as well as some other stuff in some specific minigames
This commit is contained in:
Slaith 2022-03-25 19:08:46 -07:00
parent 31c91fa3bf
commit ebeea121ed
40 changed files with 50 additions and 100 deletions

View file

@ -33,10 +33,6 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
}
private void Update()
{
headAndBodyAnim.SetBool("ShouldOpenMouth", foodHolder.childCount != 0);
if (PlayerInput.GetAnyDirectionDown())

View file

@ -48,13 +48,8 @@ namespace HeavenStudio.Games
environmentMaterials = environmentRenderer.materials;
beltMaterial = Instantiate(environmentMaterials[8]);
environmentMaterials[8] = beltMaterial;
}
void Start()
{
renderQuadTrans.gameObject.SetActive(true);
var cam = GameCamera.instance.camera;
var camHeight = 2f * cam.orthographicSize;
var camWidth = camHeight * cam.aspect;

View file

@ -32,7 +32,7 @@ namespace HeavenStudio.Games
instance = this;
}
private void Start()
private void InitLions()
{
float startPos = -3.066667f;
float maxWidth = 12.266668f;
@ -53,6 +53,7 @@ namespace HeavenStudio.Games
if (i == lionCount - 1)
ClappyTrioPlayer = lion.AddComponent<ClappyTrioPlayer>();
}
}
private void Update()
@ -161,7 +162,7 @@ namespace HeavenStudio.Games
Lion.RemoveRange(1, lionCount - 1);
lionCount = lions;
SetFace(0, 0);
Start();
InitLions();
PlayAnimationAll("Idle");
}

View file

@ -18,7 +18,7 @@ namespace HeavenStudio.Games.Scripts_ClappyTrio
private GameObject clapEffect;
new int aceTimes = 0;
private void Start()
private void Awake()
{
clapEffect = transform.GetChild(4).GetChild(3).gameObject;
}

View file

@ -51,12 +51,8 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
}
private void Start()
{
// Finding grass sprite width for grass scrolling.
instance = this;// Finding grass sprite width for grass scrolling.
farmer.Init()
var grassSprite = grass.sprite;
var borderLeft = grassSprite.rect.xMin + grassSprite.border.x;
var borderRight = grassSprite.rect.xMax - grassSprite.border.z;
@ -295,7 +291,7 @@ namespace HeavenStudio.Games
var veggieX = (beat - startBeat) * -stepDistance / 2f;
newVeggie.transform.localPosition = new Vector3(veggieX, 0f, 0f);
newVeggie.Init();
newVeggie.gameObject.SetActive(true);
}

View file

@ -12,7 +12,7 @@ namespace HeavenStudio.Games.Scripts_CropStomp
private CropStomp game;
private void Start()
public void Init()
{
game = CropStomp.instance;
}

View file

@ -33,7 +33,7 @@ namespace HeavenStudio.Games.Scripts_CropStomp
private CropStomp game;
private void Start()
public void Init()
{
game = CropStomp.instance;

View file

@ -32,11 +32,8 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
}
private void Start()
{
djYellowAnim = djYellow.GetComponent<Animator>();
student.Init();
}
private void Update()

View file

@ -31,7 +31,7 @@ namespace HeavenStudio.Games.Scripts_DJSchool
private DJSchool game;
private void Start()
public void Init()
{
game = DJSchool.instance;
anim = GetComponent<Animator>();

View file

@ -14,7 +14,7 @@ namespace HeavenStudio.Games.Scripts_DrummingPractice
private bool hasHit = false;
// Start is called before the first frame update
void Start()
void Awake()
{
PlayerActionInit(gameObject, startBeat);
}

View file

@ -43,10 +43,10 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
SetMiis();
}
// TODO: Move this to OnGameSwitch() when functional?
private void Start()
public void OnGameSwitch()
{
SetMiis();
}

View file

@ -62,12 +62,7 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
}
const int FAN_COUNT = 12;
const float RADIUS = 1.3f;
private void Start()
{
Spectators = new List<GameObject>();
idolAnimator = Arisa.GetComponent<Animator>();
@ -86,14 +81,16 @@ namespace HeavenStudio.Games
for (int i = 0; i < FAN_COUNT; i++)
{
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;
if (i == 3)
{
Player = mobj.GetComponent<NtrIdolFan>();
Player = fan;
Player.player = true;
}
Spectators.Add(mobj);
fan.Init();
//prepare spawn point of next spectator
spawnPos.x += RADIUS * 2;
@ -111,6 +108,9 @@ namespace HeavenStudio.Games
}
}
const int FAN_COUNT = 12;
const float RADIUS = 1.3f;
public override void OnGameSwitch(float beat)
{
if (wantHais != Single.MinValue)

View file

@ -36,7 +36,7 @@ namespace HeavenStudio.Games.Scripts_FanClub
private bool inputHit = false;
private bool hasHit = false;
public void Start()
public void Init()
{
if (player)
upcomingHits = new Queue<KeyValuePair<float, int>>(); // beat, type

View file

@ -9,7 +9,7 @@ namespace HeavenStudio.Games
public class Fireworks : Minigame
{
// Start is called before the first frame update
void Start()
void Awake()
{
}

View file

@ -11,7 +11,7 @@ namespace HeavenStudio.Games.Scripts_Fireworks
public bool isSparkler;
// Start is called before the first frame update
void Start()
void Awake()
{
}

View file

@ -45,10 +45,6 @@ namespace HeavenStudio.Games.Scripts_ForkLifter
private void Awake()
{
instance = this;
}
private void Start()
{
anim = GetComponent<Animator>();
}

View file

@ -16,7 +16,7 @@ namespace HeavenStudio.Games.Scripts_ForkLifter
public int type;
private void Start()
private void Awake()
{
anim = GetComponent<Animator>();

View file

@ -24,7 +24,7 @@ namespace HeavenStudio.Games.Global
private List<Beatmap.Entity> allFadeEvents = new List<Beatmap.Entity>();
private void Start()
private void Awake()
{
this.gameObject.transform.SetParent(GameManager.instance.gameObject.transform);
gameObject.layer = LayerMask.NameToLayer("Flash");

View file

@ -20,7 +20,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
public GameObject shadow;
private void Start()
private void Awake()
{
SpriteRenderer = this.gameObject.GetComponent<SpriteRenderer>();
SpriteRenderer.sprite = KarateMan.instance.BarrelSprites[spriteIndex];

View file

@ -29,7 +29,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
[SerializeField] private AnimationCurve outCurve;
[SerializeField] private AnimationCurve shadowHitCurve;
private void Start()
private void Awake()
{
anim = GetComponent<Animator>();

View file

@ -17,7 +17,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
public GameObject pot;
private void Start()
private void Awake()
{
SpriteRenderer sr = gameObject.AddComponent<SpriteRenderer>();
sr.sprite = KarateMan.instance.CookingPotSprites[1];

View file

@ -56,7 +56,7 @@ namespace HeavenStudio.Games.Scripts_KarateMan
private int missTimes = 0;
private void Start()
private void Awake()
{
anim = GetComponent<Animator>();
spriteComp = Sprite.GetComponent<SpriteRenderer>();

View file

@ -30,10 +30,6 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
}
private void Start()
{
canGo = false;
man.stepTimes = 0;
SetInterval(0);

View file

@ -14,7 +14,7 @@ namespace HeavenStudio.Games.Scripts_MrUpbeat
private bool passedFirst = false;
public float beatOffset = 0;
private void Start()
private void Awake()
{
PlayerActionInit(gameObject, startBeat);
}

View file

@ -15,7 +15,7 @@ namespace HeavenStudio.Games.Scripts_RhythmRally
private Animator opponentAnim;
private Conductor cond;
void Awake()
public void Init()
{
game = RhythmRally.instance;
playerAnim = game.playerAnim;

View file

@ -55,13 +55,9 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
}
void Start()
{
paddlers.Init();
renderQuadTrans.gameObject.SetActive(true);
var cam = GameCamera.instance.camera;
var camHeight = 2f * cam.orthographicSize;
var camWidth = camHeight * cam.aspect;

View file

@ -18,7 +18,7 @@ namespace HeavenStudio.Games.Scripts_RhythmTweezers
public SpriteRenderer heldHairSprite;
public Transform tweezerSpriteTrans;
private void Start()
private void Awake()
{
anim = GetComponent<Animator>();
vegetableAnim = RhythmTweezers.instance.VegetableAnimator;

View file

@ -168,6 +168,11 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer
{
switch (state) //handle animations
{
case State.None: //the only time any ball should ever have this state is if it's the unused offscreen ball (which is the only reason this state exists)
{
gameObject.SetActive(false);
break;
}
case State.Dispensing:
{
float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(startBeat, 2.35f);

View file

@ -20,22 +20,10 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer
[Header("Components")]
private Animator anim;
public Ball ball;
public Transform rightLeg;
public Transform leftLeg;
private void Start()
private void Awake()
{
anim = GetComponent<Animator>();
GameObject rightLeg = new GameObject();
rightLeg.transform.SetParent(this.transform);
rightLeg.transform.position = new Vector3(-0.67f, -1.48f);
GameObject leftLeg = new GameObject("leftLeg");
leftLeg.transform.SetParent(this.transform);
leftLeg.transform.position = new Vector3(0f, -1.48f);
this.rightLeg = rightLeg.transform;
this.leftLeg = leftLeg.transform;
}
public override void OnAce()

View file

@ -24,10 +24,6 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
}
private void Start()
{
/*for (int x = 0; x < Random.Range(9, 12); x++)
{
for (int y = 0; y < Random.Range(6, 9); y++)

View file

@ -11,7 +11,7 @@ namespace HeavenStudio.Games.Scripts_Spaceball
private float showBeat = 0;
private bool isShowing = false;
private void Start()
private void Awake()
{
anim = GetComponent<Animator>();
anim.Play("AlienIdle", 0, 0);

View file

@ -57,10 +57,6 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
}
private void Start()
{
var camEvents = EventCaller.GetAllInGameManagerList("spaceball", new string[] { "camera" });
List<Beatmap.Entity> tempEvents = new List<Beatmap.Entity>();
for (int i = 0; i < camEvents.Count; i++)

View file

@ -26,7 +26,7 @@ namespace HeavenStudio.Games.Scripts_Spaceball
public float hitRot;
public float randomEndPosX;
private void Start()
private void Awake()
{
anim = GetComponent<Animator>();

View file

@ -29,10 +29,6 @@ namespace HeavenStudio.Games.Scripts_Spaceball
private void Awake()
{
instance = this;
}
private void Start()
{
anim = GetComponent<Animator>();
}

View file

@ -11,9 +11,8 @@ namespace HeavenStudio.Games.Scripts_TapTrial
public float startBeat;
public int type;
// Start is called before the first frame update
void Start()
void Awake()
{
PlayerActionInit(this.gameObject, startBeat);
}

View file

@ -12,7 +12,7 @@ namespace HeavenStudio.Games.Scripts_TapTrial
public float nextBeat;
public int tripleOffset = 0;
private void Start()
private void Awake()
{
anim = GetComponent<Animator>();
}

View file

@ -12,7 +12,7 @@ namespace HeavenStudio.Games.Scripts_WizardsWaltz
public SpriteRenderer spriteRenderer;
public GameObject shimmer;
public void Start()
public void Awake()
{
int order = (int)Math.Round((transform.position.z - 2) * 1000);
spriteRenderer.sortingOrder = order;

View file

@ -20,10 +20,6 @@ namespace HeavenStudio.Games.Scripts_WizardsWaltz
private void Awake()
{
game = WizardsWaltz.instance;
}
private void Start()
{
spriteRenderer.sortingOrder = order;
animator.Play("Appear", 0, 0);
}

View file

@ -16,7 +16,7 @@ namespace HeavenStudio.Games.Scripts_WizardsWaltz
private WizardsWaltz game;
private float songPos;
private void Awake()
public void Init()
{
game = WizardsWaltz.instance;
}

View file

@ -34,6 +34,7 @@ namespace HeavenStudio.Games
private void Awake()
{
instance = this;
wizard.Init();
}
private void Start()