Skip to content

Commit

Permalink
party mode switch (fixes #23)
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-ninja committed Mar 21, 2018
1 parent c5b8a03 commit 3d00fc8
Show file tree
Hide file tree
Showing 5 changed files with 859 additions and 42 deletions.
13 changes: 9 additions & 4 deletions Assets/Fishtank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class Fishtank : MonoBehaviour
public GameObject confettiPS;

public AudioSource fishtankAudioSource;

public PartyModeSwitch partyModeSwitch;

public GameObject solventH;
public GameObject solventOH;
Expand Down Expand Up @@ -498,9 +500,12 @@ void PushTogether()
if (totalDist < 0.01f)
{
var ring = Instantiate(ringPrefab, go.transform.position, go.transform.rotation, transform);

var ringVfx = Instantiate(ringPS, go.transform.position, Quaternion.identity);
Destroy(ringVfx, 4.0f);

if (partyModeSwitch.partying)
{
var ringVfx = Instantiate(ringPS, go.transform.position, Quaternion.identity);
Destroy(ringVfx, 4.0f);
}

ring.name = "ring [ " + go.name + "]";
//Debug.Log(ring.name);
Expand Down Expand Up @@ -908,7 +913,7 @@ void UpdateTimer()
timer.text = timeD.ToString() + "s";
timer2.text = timeD.ToString();
}
if (hasWon && !confettiDone)
if (hasWon && !confettiDone && partyModeSwitch.partying)
{
fishtankAudioSource.Play();
Vector3 confettiOffset = new Vector3(0f, 2.5f, 0f);
Expand Down
29 changes: 29 additions & 0 deletions Assets/PartyModeSwitch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Valve.VR.InteractionSystem;

public class PartyModeSwitch : MonoBehaviour {

public LinearMapping linearMapping;
public Text text;
public bool partying = true;
public GameObject scoreboard;

// Update is called once per frame
void Update () {
if (linearMapping.value < .5)
{
text.text = "Party mode!";
partying = true;
scoreboard.SetActive(true);
}
else
{
text.text = "Serious mode.";
partying = false;
scoreboard.SetActive(false);
}
}
}
12 changes: 12 additions & 0 deletions Assets/PartyModeSwitch.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 18 additions & 7 deletions Assets/ShowDonut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ public class ShowDonut : MonoBehaviour {
public AudioClip donutSpawnSound;
public AudioClip rustyDonutSpawnSound;

private PartyModeSwitch partyModeSwitch;

private void Awake()
{
partyModeSwitch = FindObjectOfType<PartyModeSwitch>();
small = donut.transform.localScale * .9f;
medium = donut.transform.localScale;
big = donut.transform.localScale * 1.1f;
Expand All @@ -30,7 +33,7 @@ private void DonutOff()

private void OnTriggerEnter(Collider other)
{
if ((other.gameObject.tag == "monomer" || other.gameObject.tag == "dimer" )&& !donut.activeInHierarchy)
if ((other.gameObject.tag == "monomer" || other.gameObject.tag == "dimer" )&& !donut.activeInHierarchy && partyModeSwitch.partying)
{
donut.SetActive(true);
startTime = Time.time;
Expand All @@ -45,7 +48,7 @@ private void OnTriggerEnter(Collider other)

private void OnTriggerStay(Collider other)
{
if (other.name == "ringCenter" && !rustyDonut.activeInHierarchy)
if (other.name == "ringCenter" && !rustyDonut.activeInHierarchy && partyModeSwitch.partying)
{
rustyDonut.SetActive(true);
ringAudioSource.PlayOneShot(rustyDonutSpawnSound);
Expand All @@ -62,10 +65,18 @@ private void OnTriggerExit(Collider other)

private void Update()
{
var s = Time.time - startTime;
var newSmall = Vector3.Lerp(small, medium, s);
var newBig = Vector3.Lerp(big, medium, s);
float f = Mathf.PingPong(s * 10, 1);
donut.transform.localScale = Vector3.Lerp(newSmall, newBig, f);
if (partyModeSwitch.partying)
{
var s = Time.time - startTime;
var newSmall = Vector3.Lerp(small, medium, s);
var newBig = Vector3.Lerp(big, medium, s);
float f = Mathf.PingPong(s * 10, 1);
donut.transform.localScale = Vector3.Lerp(newSmall, newBig, f);
}
else
{
donut.SetActive(false);
rustyDonut.SetActive(false);
}
}
}
Loading

0 comments on commit 3d00fc8

Please sign in to comment.