Skip to content

Commit dfa7187

Browse files
authored
MMM Files
0 parents  commit dfa7187

9 files changed

+346
-0
lines changed

AnimationAudioHelper.cs

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEngine.UI;
5+
using UnityEngine.EventSystems;
6+
using UnityEngine.Events;
7+
8+
public class AnimationAudioHelper : MonoBehaviour
9+
{
10+
[System.Serializable]
11+
public class MyEvent:UnityEvent<int> {}
12+
13+
public MyEvent onClick;
14+
public GameObject[] gameObjectsToFlip;
15+
public Selectable[] selectables;
16+
17+
public void PlayClip(AudioClip clip)
18+
{
19+
GameManager.GM.PlayClip(clip, .5f);
20+
//AudioSource.PlayClipAtPoint(clip, GameManager.GM.ears.transform.position, 0.5f);
21+
22+
}
23+
24+
public void DisableGO(int which)
25+
{
26+
27+
gameObjectsToFlip[which].SetActive(false);
28+
}
29+
public void EnableGO(int which)
30+
{
31+
32+
gameObjectsToFlip[which].SetActive(true);
33+
}
34+
35+
public void SelectThis(int which)
36+
{
37+
EventSystem.current.SetSelectedGameObject(selectables[which].gameObject);
38+
selectables[which].OnSelect(null);
39+
40+
}
41+
42+
public void ChangeGameState(int i){
43+
GameManager.GM.SetGameState(i);
44+
}
45+
46+
//using this at the end of an animation, after interactable is turned back on.
47+
//allows me to set the selected button from another button.
48+
public void UpdateSelected()
49+
{
50+
EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>().OnSelect(null);
51+
}
52+
public void zOnClick()
53+
{
54+
onClick.Invoke(1);
55+
}
56+
57+
}

BlinkRandomInterval.cs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class BlinkRandomInterval : MonoBehaviour
6+
{
7+
public GameObject eyesOrWhatever;
8+
public float minInt, maxInt, offFor;
9+
10+
// Start is called before the first frame update
11+
void OnEnable()
12+
{
13+
StartCoroutine(Blink());
14+
15+
}
16+
17+
public IEnumerator Blink()
18+
{
19+
eyesOrWhatever.SetActive(true);
20+
yield return new WaitForSeconds(GetDelay());
21+
eyesOrWhatever.SetActive(false);
22+
yield return new WaitForSeconds(offFor);
23+
eyesOrWhatever.SetActive(true);
24+
StartCoroutine(Blink());
25+
}
26+
27+
public float GetDelay()
28+
{
29+
float del = Random.Range(minInt, maxInt);
30+
return del;
31+
}
32+
}

FillTextOnSelect.cs

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEngine.EventSystems;
5+
using UnityEngine.UI;
6+
7+
public class FillTextOnSelect : MonoBehaviour, ISelectHandler
8+
{
9+
public Text[] textBoxes;
10+
[TextArea(8,8)]
11+
public string[] fillThis;
12+
13+
//optional just to help save time for me:
14+
public Enemy eStats;
15+
// Start is called before the first frame update
16+
void Start()
17+
{
18+
if(fillThis.Length!=textBoxes.Length)
19+
{
20+
Debug.Log("Number of texts not equal to number of strings!");
21+
}
22+
}
23+
24+
// Update is called once per frame
25+
void Update()
26+
{
27+
28+
}
29+
public void OnSelect(BaseEventData eventData)
30+
{
31+
for (int i = 0; i < textBoxes.Length; i++)
32+
{
33+
textBoxes[i].text = fillThis[i];
34+
}
35+
if (eStats)
36+
{
37+
38+
39+
textBoxes[2].text =
40+
//"Stats: \n" +
41+
"Health: " + eStats.health + "\n" +
42+
"Damage: " + eStats.dmgToGive + "\n" +
43+
"Attack Delay: " + eStats.attackDelay + "\n" +
44+
"Range: " + eStats.maxAttackDist + "\n" +
45+
"Speed: " + eStats.moveSpeed + "\n" +
46+
"Research Rate: " + eStats.researchSpeed + "\n" +
47+
"Buffed By: " + eStats.buffedBy;
48+
}
49+
}
50+
}

FloatyMovement.cs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
4+
public class FloatyMovement : MonoBehaviour {
5+
public float period, rangeY, rangeX, rangeZ;
6+
private Vector3 originalPos;
7+
8+
9+
// Use this for initialization
10+
void Start () {
11+
originalPos = transform.localPosition;
12+
13+
}
14+
15+
// Update is called once per frame
16+
void Update () {
17+
18+
Vector3 offset = Vector3.zero;
19+
20+
offset.x = Mathf.Sin(Time.time * period) * rangeX;
21+
offset.y = Mathf.Sin(Time.time * period) * rangeY;
22+
offset.z = Mathf.Sin(Time.time * period) * rangeZ;
23+
24+
transform.localPosition = originalPos + offset;
25+
26+
}
27+
}

GoToParent.cs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class GoToParent : MonoBehaviour
6+
{
7+
public float moveSpeed;
8+
public bool bigAndSmall, dontdie;
9+
public float growAmount;
10+
float min, max;
11+
// Start is called before the first frame update
12+
void Start()
13+
{
14+
min = transform.localScale.x - growAmount;
15+
max = transform.localScale.x + growAmount;
16+
}
17+
18+
// Update is called once per frame
19+
void Update()
20+
{
21+
transform.localPosition = Vector3.MoveTowards(transform.localPosition, Vector3.zero, moveSpeed);
22+
if(bigAndSmall)
23+
{
24+
float mod = Mathf.Lerp(min, max, Mathf.PingPong(Time.time, 1));
25+
transform.localScale = new Vector3(mod, mod, mod);
26+
}
27+
if(Vector3.Distance(transform.localPosition, Vector3.zero) < .1f && !dontdie)
28+
{
29+
Destroy(gameObject);
30+
}
31+
}
32+
}

LightPulse.cs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
[RequireComponent(typeof(Light))]
6+
public class LightPulse : MonoBehaviour
7+
{
8+
Light l;
9+
[Header("Intensity")]
10+
public bool pulseIntensity = true;
11+
public float minIt;
12+
public float maxIt;
13+
public float itSpeed;
14+
15+
[Header("Range")]
16+
public bool pulseRange = true;
17+
18+
public float minRange;
19+
public float maxRange;
20+
public float rangeSpeed;
21+
// Start is called before the first frame update
22+
void Start()
23+
{
24+
l = GetComponent<Light>();
25+
}
26+
27+
// Update is called once per frame
28+
void Update()
29+
{
30+
float t = Time.time;
31+
if(pulseIntensity)
32+
l.intensity = Mathf.PingPong(t*itSpeed, maxIt - minIt) + minIt;
33+
34+
if (pulseRange)
35+
l.range = Mathf.PingPong(t*rangeSpeed, maxRange - minRange) + minRange;
36+
}
37+
}

LoadingScreenTips.cs

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEngine.UI;
5+
6+
7+
[RequireComponent(typeof(Text))]
8+
public class LoadingScreenTips : MonoBehaviour
9+
{
10+
Text textBox;
11+
[Range(0, 100)]
12+
public int jokeChance;
13+
[Tooltip("Set this false to not show a joke")]
14+
public bool showJoke;
15+
[TextArea(1, 2)]
16+
public string[] loadingTipsSerious;
17+
[TextArea(1, 2)]
18+
public string[] loadingTipsJoke;
19+
20+
public float delay;
21+
// Start is called before the first frame update
22+
void OnEnable()
23+
{
24+
textBox = GetComponent<Text>();
25+
PickTip();
26+
}
27+
28+
public string RandomTip()
29+
{
30+
string s = loadingTipsSerious[Random.Range(0, loadingTipsSerious.Length)];
31+
return s;
32+
}
33+
34+
public string RandomJoke()
35+
{
36+
string s = loadingTipsJoke[Random.Range(0, loadingTipsJoke.Length)];
37+
return s;
38+
}
39+
40+
public void PickTip()
41+
{
42+
int roll = Random.Range(0, 100);
43+
if (roll <= jokeChance && showJoke)
44+
{
45+
StartCoroutine(ShowTip(RandomJoke(),delay));
46+
}else{
47+
StartCoroutine(ShowTip(RandomTip(), delay));
48+
}
49+
50+
}
51+
52+
public IEnumerator ShowTip(string tip,float del)
53+
{
54+
textBox.text = tip;
55+
if(del==0)
56+
{
57+
yield break;
58+
}
59+
yield return new WaitForSecondsRealtime(delay); //using Realtime in case the user pauses timeScale.
60+
PickTip();
61+
}
62+
}

SimpleMove.cs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class SimpleMove : MonoBehaviour {
6+
public float minX, maxX, xVel, yVel;
7+
public float dieAfter;
8+
public bool startLarge;
9+
10+
[Header("Shrink vars")]
11+
public float size;
12+
public float bigSize, shrinkSpeed;
13+
14+
private void Start()
15+
{
16+
Destroy(gameObject, dieAfter);
17+
xVel = Random.Range(minX, maxX);
18+
size = transform.localScale.x;
19+
if (startLarge)
20+
{
21+
transform.localScale += Vector3.one * bigSize;
22+
}
23+
}
24+
25+
// Update is called once per frame
26+
void Update () {
27+
transform.Translate(new Vector3(xVel * Time.deltaTime, yVel * Time.deltaTime));
28+
29+
if (startLarge)
30+
{
31+
GetComponent<RectTransform>().localScale = Vector3.MoveTowards(transform.localScale, Vector3.zero, shrinkSpeed * Time.deltaTime);
32+
}
33+
}
34+
}

ToggleCheckPP.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEngine.UI;
5+
6+
7+
//this is a helper class to get playerprefs that are stored by other scripts
8+
[RequireComponent(typeof(Toggle))]
9+
public class ToggleCheckPP : MonoBehaviour
10+
{
11+
private void OnEnable()
12+
{
13+
GetComponent<Toggle>().isOn = PlayerPrefsX.GetBool(gameObject.name);
14+
}
15+
}

0 commit comments

Comments
 (0)