mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-15 22:25:07 +00:00
a653194e07
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
53 lines
No EOL
1.5 KiB
C#
53 lines
No EOL
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
using DG.Tweening;
|
|
|
|
namespace HeavenStudio.Games.Scripts_KarateMan
|
|
{
|
|
// Physics in Rhythm Heaven Mania? nah im just fuckin lazy
|
|
public class CookingPotDestroyEffect : MonoBehaviour
|
|
{
|
|
public SpriteRenderer SpriteRenderer;
|
|
public int spriteIndex;
|
|
public int index;
|
|
|
|
private float rotationSpeed;
|
|
|
|
public GameObject pot;
|
|
|
|
private void Awake()
|
|
{
|
|
SpriteRenderer sr = gameObject.AddComponent<SpriteRenderer>();
|
|
sr.sprite = KarateMan.instance.CookingPotSprites[1];
|
|
|
|
Rigidbody2D rb2d = gameObject.AddComponent<Rigidbody2D>();
|
|
rb2d.gravityScale = 5;
|
|
rb2d.collisionDetectionMode = CollisionDetectionMode2D.Continuous;
|
|
|
|
rb2d.AddForce(Vector3.up * Random.Range(875, 925));
|
|
|
|
rotationSpeed = Random.Range(100, 200);
|
|
|
|
PhysicsMaterial2D mat = new PhysicsMaterial2D();
|
|
mat.bounciness = 0;
|
|
|
|
StartCoroutine(FadeOut());
|
|
|
|
gameObject.name = "cookingpot_lid";
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
transform.eulerAngles -= new Vector3(0, 0, rotationSpeed * Time.deltaTime);
|
|
transform.position = new Vector3(pot.transform.position.x, transform.position.y, transform.position.z);
|
|
}
|
|
|
|
private IEnumerator FadeOut()
|
|
{
|
|
yield return new WaitForSeconds(Conductor.instance.secPerBeat * 3);
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
} |