First Contact - slight change on Mission Control

This commit is contained in:
Mytiaoga 2022-07-11 15:21:17 +08:00 committed by GitHub
parent 45da7c6d54
commit 111fbaf159
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 367 additions and 369 deletions

View file

@ -1,358 +1,356 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using HeavenStudio.Util; using HeavenStudio.Util;
namespace HeavenStudio.Games.Loaders namespace HeavenStudio.Games.Loaders
{ {
using static Minigames; using static Minigames;
public static class CtrFirstContact public static class CtrFirstContact
{ {
public static Minigame AddGame(EventCaller eventCaller) public static Minigame AddGame(EventCaller eventCaller)
{ {
return new Minigame("firstContact", "First Contact", "008c97", false, false, new List<GameAction>() return new Minigame("firstContact", "First Contact", "008c97", false, false, new List<GameAction>()
{ {
new GameAction("beat intervals", delegate { FirstContact.instance.SetIntervalStart(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 4f, true), new GameAction("beat intervals", delegate { FirstContact.instance.SetIntervalStart(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 4f, true),
new GameAction("alien speak", delegate { FirstContact.instance.alienSpeak(eventCaller.currentEntity.beat, eventCaller.currentEntity.valA); }, 0.5f, false, new List<Param>() new GameAction("alien speak", delegate { FirstContact.instance.alienSpeak(eventCaller.currentEntity.beat, eventCaller.currentEntity.valA); }, 0.5f, false, new List<Param>()
{ {
new Param("valA", new EntityTypes.Float(.8f, 1.5f, 1f), "Pitch") new Param("valA", new EntityTypes.Float(.8f, 1.5f, 1f), "Pitch")
}), }),
new GameAction("alien turnover", delegate { FirstContact.instance.alienTurnOver(eventCaller.currentEntity.beat); }, 0.5f, false), new GameAction("alien turnover", delegate { FirstContact.instance.alienTurnOver(eventCaller.currentEntity.beat); }, 0.5f, false),
new GameAction("alien success", delegate { FirstContact.instance.alienSuccess(eventCaller.currentEntity.beat); }, 1f, false), new GameAction("alien success", delegate { FirstContact.instance.alienSuccess(eventCaller.currentEntity.beat); }, 1f, false),
new GameAction("mission control", delegate { FirstContact.instance.missionControlDisplay(eventCaller.currentEntity.beat, eventCaller.currentEntity.toggle, eventCaller.currentEntity.length); }, 1f, true, new List<Param> new GameAction("mission control", delegate { FirstContact.instance.missionControlDisplay(eventCaller.currentEntity.beat, eventCaller.currentEntity.toggle, eventCaller.currentEntity.length); }, 1f, true, new List<Param>
{ {
new Param("toggle", false, "Stay", "If it's the end of the remix/song") new Param("toggle", false, "Stay", "If it's the end of the remix/song")
}), }),
new GameAction("look at", delegate { FirstContact.instance.lookAtDirection(eventCaller.currentEntity.type, eventCaller.currentEntity.type2); }, .5f, false, new List<Param>() new GameAction("look at", delegate { FirstContact.instance.lookAtDirection(eventCaller.currentEntity.type, eventCaller.currentEntity.type2); }, .5f, false, new List<Param>()
{ {
new Param("type", FirstContact.alienLookAt.lookAtTranslator, "alien look at what", "[Alien] will look at what"), new Param("type", FirstContact.alienLookAt.lookAtTranslator, "alien look at what", "[Alien] will look at what"),
new Param("type", FirstContact.translatorLookAt.lookAtAlien, "translator look at what", "[Translator] will look at what"), new Param("type", FirstContact.translatorLookAt.lookAtAlien, "translator look at what", "[Translator] will look at what"),
}), }),
//new GameAction("Version of First Contact", delegate { FirstContact.instance.versionOfFirstContact(eventCaller.currentEntity.type); }, .5f, false, new List<Param> //new GameAction("Version of First Contact", delegate { FirstContact.instance.versionOfFirstContact(eventCaller.currentEntity.type); }, .5f, false, new List<Param>
//{ //{
// new Param("type", FirstContact.VersionOfContact.FirstContact, "Version", "Version of First Contact to play"), // new Param("type", FirstContact.VersionOfContact.FirstContact, "Version", "Version of First Contact to play"),
//}), //}),
}); });
} }
} }
} }
namespace HeavenStudio.Games namespace HeavenStudio.Games
{ {
//using Scripts_FirstContact; //using Scripts_FirstContact;
public class FirstContact : Minigame public class FirstContact : Minigame
{ {
public static FirstContact instance { get; private set; } public static FirstContact instance { get; private set; }
[Header("Properties")] [Header("Properties")]
public int alienSpeakCount; public int alienSpeakCount;
public int translatorSpeakCount; public int translatorSpeakCount;
public bool hasMissed; public bool hasMissed;
private float lastReportedBeat = 0; private float lastReportedBeat = 0;
[Header("Components")] [Header("Components")]
[SerializeField] GameObject alien; [SerializeField] GameObject alien;
[SerializeField] GameObject translator; [SerializeField] GameObject translator;
//[SerializeField] GameObject alienSpeech; //[SerializeField] GameObject alienSpeech;
[SerializeField] GameObject dummyHolder; [SerializeField] GameObject dummyHolder;
[SerializeField] GameObject missionControl; [SerializeField] GameObject missionControl;
[SerializeField] GameObject liveBar; [SerializeField] GameObject liveBar;
[Header("Variables")] [Header("Variables")]
public bool intervalStarted; public bool intervalStarted;
//float intervalStartBeat; //float intervalStartBeat;
public float beatInterval = 4f; public float beatInterval = 4f;
public bool isCorrect, noHitOnce, isSpeaking; public bool isCorrect, noHitOnce, isSpeaking;
//public int version; //public int version;
public float lookAtLength = 1f; public float lookAtLength = 1f;
//public enum VersionOfContact //public enum VersionOfContact
//{ //{
// FirstContact, // FirstContact,
// CitrusRemix, // CitrusRemix,
// SecondContact // SecondContact
//} //}
public enum alienLookAt public enum alienLookAt
{ {
lookAtTranslator, lookAtTranslator,
idle idle
} }
public enum translatorLookAt public enum translatorLookAt
{ {
lookAtAlien, lookAtAlien,
idle idle
} }
private void Awake() private void Awake()
{ {
instance = this; instance = this;
} }
public void SetIntervalStart(float beat, float interval = 4f) public void SetIntervalStart(float beat, float interval = 4f)
{ {
if (!intervalStarted) if (!intervalStarted)
{ {
//alienSpeakCount = 0; //alienSpeakCount = 0;
//translatorSpeakCount = 0; //translatorSpeakCount = 0;
intervalStarted = true; intervalStarted = true;
} }
//intervalStartBeat = beat; //intervalStartBeat = beat;
beatInterval = interval; beatInterval = interval;
} }
private void Update() private void Update()
{ {
//This is taken from the conductor script //This is taken from the conductor script
if (Conductor.instance.ReportBeat(ref lastReportedBeat)) if (Conductor.instance.ReportBeat(ref lastReportedBeat))
{ {
liveBar.GetComponent<Animator>().Play("liveBar", 0, 0); liveBar.GetComponent<Animator>().Play("liveBar", 0, 0);
} }
else if(Conductor.instance.songPositionInBeats < lastReportedBeat) else if(Conductor.instance.songPositionInBeats < lastReportedBeat)
{ {
lastReportedBeat = Mathf.Round(Conductor.instance.songPositionInBeats); lastReportedBeat = Mathf.Round(Conductor.instance.songPositionInBeats);
} }
if (PlayerInput.Pressed() && !IsExpectingInputNow() && !noHitOnce && !isSpeaking) if (PlayerInput.Pressed() && !IsExpectingInputNow() && !noHitOnce && !isSpeaking)
{ {
Jukebox.PlayOneShotGame("firstContact/" + randomizerLines()); Jukebox.PlayOneShotGame("firstContact/" + randomizerLines());
BeatAction.New(this.gameObject, new List<BeatAction.Action>() BeatAction.New(this.gameObject, new List<BeatAction.Action>()
{ {
new BeatAction.Action(.5f, delegate { translator.GetComponent<Animator>().Play("translator_speak", 0, 0);}), new BeatAction.Action(.5f, delegate { translator.GetComponent<Animator>().Play("translator_speak", 0, 0);}),
}); });
} }
if ((PlayerInput.Pressed() && !IsExpectingInputNow() && isSpeaking)) if ((PlayerInput.Pressed() && !IsExpectingInputNow() && isSpeaking))
{ {
hasMissed = true; hasMissed = true;
} }
} }
//public void versionOfFirstContact(int type) //public void versionOfFirstContact(int type)
//{ //{
// version = type; // version = type;
//} //}
public void lookAtDirection(int alienLookAt, int translatorLookAt) public void lookAtDirection(int alienLookAt, int translatorLookAt)
{ {
switch (alienLookAt) switch (alienLookAt)
{ {
case 0: case 0:
alien.GetComponent<Animator>().Play("alien_lookAt", 0, 0); alien.GetComponent<Animator>().Play("alien_lookAt", 0, 0);
break; break;
case 1: case 1:
alien.GetComponent<Animator>().Play("alien_idle", 0, 0); alien.GetComponent<Animator>().Play("alien_idle", 0, 0);
break; break;
} }
switch (translatorLookAt) switch (translatorLookAt)
{ {
case 0: case 0:
translator.GetComponent<Animator>().Play("translator_lookAtAlien", 0, 0); translator.GetComponent<Animator>().Play("translator_lookAtAlien", 0, 0);
break; break;
case 1: case 1:
translator.GetComponent<Animator>().Play("translator_idle", 0, 0); translator.GetComponent<Animator>().Play("translator_idle", 0, 0);
break; break;
} }
} }
public void alienSpeak(float beat, float pitch) public void alienSpeak(float beat, float pitch)
{ {
Jukebox.PlayOneShotGame("firstContact/alien", beat, pitch); Jukebox.PlayOneShotGame("firstContact/alien", beat, pitch);
++alienSpeakCount; ++alienSpeakCount;
var random = Random.Range(0, 2); var random = Random.Range(0, 2);
string textToPut = ""; string textToPut = "";
if(random == 0) if(random == 0)
{ {
textToPut = "translator_lookAtAlien"; textToPut = "translator_lookAtAlien";
} }
else else
{ {
textToPut = "translator_lookAtAlien_nod"; textToPut = "translator_lookAtAlien_nod";
} }
ScheduleInput(beat, beatInterval, InputType.STANDARD_DOWN, alienTapping, alienOnMiss, AlienEmpty); ScheduleInput(beat, beatInterval, InputType.STANDARD_DOWN, alienTapping, alienOnMiss, AlienEmpty);
BeatAction.New(alien, new List<BeatAction.Action>() BeatAction.New(alien, new List<BeatAction.Action>()
{ {
new BeatAction.Action(beat, delegate { alien.GetComponent<Animator>().Play("alien_talk", 0, 0); }), new BeatAction.Action(beat, delegate { alien.GetComponent<Animator>().Play("alien_talk", 0, 0); }),
new BeatAction.Action(beat, delegate new BeatAction.Action(beat, delegate
{ {
if (!isSpeaking) if (!isSpeaking)
{ {
translator.GetComponent<Animator>().Play(textToPut, 0, 0); translator.GetComponent<Animator>().Play(textToPut, 0, 0);
} }
}), }),
}); });
} }
public void alienTurnOver(float beat) public void alienTurnOver(float beat)
{ {
if (!intervalStarted) if (!intervalStarted)
{ {
SetIntervalStart(beat, beatInterval); SetIntervalStart(beat, beatInterval);
} }
if (intervalStarted) if (intervalStarted)
{ {
SetIntervalStart(beat, beatInterval); SetIntervalStart(beat, beatInterval);
} }
Jukebox.PlayOneShotGame("firstContact/turnover"); Jukebox.PlayOneShotGame("firstContact/turnover");
BeatAction.New(alien, new List<BeatAction.Action>() BeatAction.New(alien, new List<BeatAction.Action>()
{ {
new BeatAction.Action(beat, delegate { alien.GetComponent<Animator>().Play("alien_point", 0, 0); }), new BeatAction.Action(beat, delegate { alien.GetComponent<Animator>().Play("alien_point", 0, 0); }),
new BeatAction.Action(beat + .5f, delegate { alien.GetComponent<Animator>().Play("alien_idle", 0, 0); }), new BeatAction.Action(beat + .5f, delegate { alien.GetComponent<Animator>().Play("alien_idle", 0, 0); }),
new BeatAction.Action(beat + .5f, new BeatAction.Action(beat + .5f,
delegate delegate
{ {
if (!isSpeaking) if (!isSpeaking)
{ {
translator.GetComponent<Animator>().Play("translator_idle", 0, 0); translator.GetComponent<Animator>().Play("translator_idle", 0, 0);
} }
}) })
}); });
isSpeaking = true; isSpeaking = true;
} }
public void alienSuccess(float beat) public void alienSuccess(float beat)
{ {
string[] sfxStrings = { "", "" }; string[] sfxStrings = { "", "" };
string animString = ""; string animString = "";
if (alienSpeakCount == translatorSpeakCount) if (alienSpeakCount == translatorSpeakCount)
{ {
sfxStrings[0] = "firstContact/success_1"; sfxStrings[0] = "firstContact/success_1";
sfxStrings[1] = "firstContact/success_2"; sfxStrings[1] = "firstContact/success_2";
animString = "alien_success"; animString = "alien_success";
Debug.Log("success"); }
} else if (alienSpeakCount != translatorSpeakCount)
else if (alienSpeakCount != translatorSpeakCount) {
{ sfxStrings[0] = "firstContact/failAlien_1";
sfxStrings[0] = "firstContact/failAlien_1"; sfxStrings[1] = "firstContact/failAlien_2";
sfxStrings[1] = "firstContact/failAlien_2"; animString = "alien_fail";
animString = "alien_fail"; }
Debug.Log("fail");
} string[] sounds = new string[] { sfxStrings[0], sfxStrings[0] };
var sound = new MultiSound.Sound[]
string[] sounds = new string[] { sfxStrings[0], sfxStrings[0] }; {
var sound = new MultiSound.Sound[] new MultiSound.Sound(sounds[0], beat),
{ new MultiSound.Sound(sounds[1], beat + .5f)
new MultiSound.Sound(sounds[0], beat), };
new MultiSound.Sound(sounds[1], beat + .5f)
}; MultiSound.Play(sound);
MultiSound.Play(sound); BeatAction.New(alien, new List<BeatAction.Action>()
{
BeatAction.New(alien, new List<BeatAction.Action>() new BeatAction.Action(beat, delegate { alien.GetComponent<Animator>().Play(animString, 0, 0); }),
{ new BeatAction.Action(beat + .5f, delegate { alien.GetComponent<Animator>().Play(animString, 0, 0); })
new BeatAction.Action(beat, delegate { alien.GetComponent<Animator>().Play(animString, 0, 0); }), });
new BeatAction.Action(beat + .5f, delegate { alien.GetComponent<Animator>().Play(animString, 0, 0); })
}); BeatAction.New(translator.gameObject, new List<BeatAction.Action>()
{
BeatAction.New(translator.gameObject, new List<BeatAction.Action>() new BeatAction.Action(beat, delegate { translator.GetComponent<Animator>().Play("translator_idle", 0, 0); }),
{ });
new BeatAction.Action(beat, delegate { translator.GetComponent<Animator>().Play("translator_idle", 0, 0); }),
});
alienSpeakCount = 0;
translatorSpeakCount = 0;
alienSpeakCount = 0; isSpeaking = false;
translatorSpeakCount = 0; hasMissed = false;
isSpeaking = false; noHitOnce = false;
hasMissed = false; }
noHitOnce = false;
} public void missionControlDisplay(float beat, bool stay, float length)
{
public void missionControlDisplay(float beat, bool stay, float length) missionControl.SetActive(true);
{ string textToPut = "";
missionControl.SetActive(true);
string textToPut = ""; if (alienSpeakCount == translatorSpeakCount)
{
if (alienSpeakCount == translatorSpeakCount) textToPut = "missionControl_success";
{ }
textToPut = "missionControl_success"; else
} {
else textToPut = "missionControl_fail";
{ }
textToPut = "missionControl_fail";
} BeatAction.New(missionControl, new List<BeatAction.Action>()
{
BeatAction.New(missionControl, new List<BeatAction.Action>() new BeatAction.Action(length, delegate { missionControl.GetComponentInParent<Animator>().Play(textToPut, 0, 0); }),
{ new BeatAction.Action(length, delegate { alien.GetComponentInParent<Animator>().Play("alien_idle", 0, 0); }),
new BeatAction.Action(length, delegate { missionControl.GetComponentInParent<Animator>().Play(textToPut, 0, 0); }), new BeatAction.Action(length, delegate { translator.GetComponent<Animator>().Play("translator_idle", 0, 0); }),
new BeatAction.Action(length, delegate { alien.GetComponentInParent<Animator>().Play("alien_idle", 0, 0); }),
new BeatAction.Action(length, delegate { translator.GetComponent<Animator>().Play("translator_idle", 0, 0); }), });
}); if (!stay)
{
if (!stay) BeatAction.New(missionControl, new List<BeatAction.Action>()
{ {
BeatAction.New(missionControl, new List<BeatAction.Action>() new BeatAction.Action(length, delegate { missionControl.SetActive(false); }),
{ });
new BeatAction.Action(length + 1f, delegate { missionControl.SetActive(false); }), }
}); else
} {
else missionControl.SetActive(true);
{ }
missionControl.SetActive(true);
} alienSpeakCount = 0;
translatorSpeakCount = 0;
alienSpeakCount = 0; isSpeaking = false;
translatorSpeakCount = 0; }
isSpeaking = false;
} public void alienTapping(PlayerActionEvent caller, float beat) //OnHit
{
public void alienTapping(PlayerActionEvent caller, float beat) //OnHit if (!noHitOnce)
{ {
if (!noHitOnce) ++translatorSpeakCount;
{ Jukebox.PlayOneShotGame("firstContact/" + randomizerLines());
++translatorSpeakCount; isCorrect = true;
Jukebox.PlayOneShotGame("firstContact/" + randomizerLines());
isCorrect = true; BeatAction.New(this.gameObject, new List<BeatAction.Action>()
{
BeatAction.New(this.gameObject, new List<BeatAction.Action>() new BeatAction.Action(.5f, delegate { translator.GetComponent<Animator>().Play("translator_speak", 0, 0);}),
{ });
new BeatAction.Action(.5f, delegate { translator.GetComponent<Animator>().Play("translator_speak", 0, 0);}), }
}); else if (noHitOnce)
} {
else if (noHitOnce) Jukebox.PlayOneShotGame("firstContact/slightlyFail");
{ BeatAction.New(this.gameObject, new List<BeatAction.Action>()
Jukebox.PlayOneShotGame("firstContact/slightlyFail"); {
BeatAction.New(this.gameObject, new List<BeatAction.Action>() new BeatAction.Action(.5f, delegate { translator.GetComponent<Animator>().Play("translator_eh", 0, 0);}),
{ });
new BeatAction.Action(.5f, delegate { translator.GetComponent<Animator>().Play("translator_eh", 0, 0);}), }
}); }
}
} public void alienOnMiss(PlayerActionEvent caller) //OnMiss
{
public void alienOnMiss(PlayerActionEvent caller) //OnMiss if (!noHitOnce)
{ {
if (!noHitOnce) Jukebox.PlayOneShotGame("firstContact/alienNoHit");
{ noHitOnce = true;
Jukebox.PlayOneShotGame("firstContact/alienNoHit"); }
noHitOnce = true;
} BeatAction.New(alien, new List<BeatAction.Action>()
{
BeatAction.New(alien, new List<BeatAction.Action>() new BeatAction.Action(.5f, delegate { alien.GetComponent<Animator>().Play("alien_noHit", 0, 0); }),
{ });
new BeatAction.Action(.5f, delegate { alien.GetComponent<Animator>().Play("alien_noHit", 0, 0); }), }
});
} public void AlienEmpty(PlayerActionEvent caller) //OnEmpty
{
public void AlienEmpty(PlayerActionEvent caller) //OnEmpty //empty
{ }
//empty
} public int randomizerLines()
{
public int randomizerLines() return Random.Range(1, 11);
{ }
return Random.Range(1, 11); }
} }
}
}

View file

@ -1,11 +1,11 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 3f2575369f43af4419d4d92d0de9e23b guid: 3f2575369f43af4419d4d92d0de9e23b
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant: