Merge pull request #63 from Slaith12/main

Prevented out of order initialization
This commit is contained in:
Jenny Crowe 2022-03-25 21:48:51 -07:00 committed by GitHub
commit abf86b4258
40 changed files with 50 additions and 100 deletions

View file

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

View file

@ -48,11 +48,6 @@ namespace HeavenStudio.Games
environmentMaterials = environmentRenderer.materials; environmentMaterials = environmentRenderer.materials;
beltMaterial = Instantiate(environmentMaterials[8]); beltMaterial = Instantiate(environmentMaterials[8]);
environmentMaterials[8] = beltMaterial; environmentMaterials[8] = beltMaterial;
}
void Start()
{
renderQuadTrans.gameObject.SetActive(true); renderQuadTrans.gameObject.SetActive(true);
var cam = GameCamera.instance.camera; var cam = GameCamera.instance.camera;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -9,7 +9,7 @@ namespace HeavenStudio.Games
public class Fireworks : Minigame public class Fireworks : Minigame
{ {
// Start is called before the first frame update // 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; public bool isSparkler;
// Start is called before the first frame update // 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() private void Awake()
{ {
instance = this; instance = this;
}
private void Start()
{
anim = GetComponent<Animator>(); anim = GetComponent<Animator>();
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -55,11 +55,7 @@ namespace HeavenStudio.Games
private void Awake() private void Awake()
{ {
instance = this; instance = this;
} paddlers.Init();
void Start()
{
renderQuadTrans.gameObject.SetActive(true); renderQuadTrans.gameObject.SetActive(true);
var cam = GameCamera.instance.camera; var cam = GameCamera.instance.camera;

View file

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

View file

@ -168,6 +168,11 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer
{ {
switch (state) //handle animations 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: case State.Dispensing:
{ {
float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(startBeat, 2.35f); float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(startBeat, 2.35f);

View file

@ -20,22 +20,10 @@ namespace HeavenStudio.Games.Scripts_SpaceSoccer
[Header("Components")] [Header("Components")]
private Animator anim; private Animator anim;
public Ball ball; public Ball ball;
public Transform rightLeg;
public Transform leftLeg;
private void Start() private void Awake()
{ {
anim = GetComponent<Animator>(); 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() public override void OnAce()

View file

@ -24,10 +24,6 @@ namespace HeavenStudio.Games
private void Awake() private void Awake()
{ {
instance = this; instance = this;
}
private void Start()
{
/*for (int x = 0; x < Random.Range(9, 12); x++) /*for (int x = 0; x < Random.Range(9, 12); x++)
{ {
for (int y = 0; y < Random.Range(6, 9); y++) 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 float showBeat = 0;
private bool isShowing = false; private bool isShowing = false;
private void Start() private void Awake()
{ {
anim = GetComponent<Animator>(); anim = GetComponent<Animator>();
anim.Play("AlienIdle", 0, 0); anim.Play("AlienIdle", 0, 0);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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