Browse Source

first playable of ouija

master
Josh 1 year ago
parent
commit
7f7153ec14
  1. 126
      namedropper/Assets/Ouija.cs
  2. 18
      namedropper/Assets/Planchette.cs
  3. 17
      namedropper/Assets/Scenes/Ouija.unity
  4. 8
      namedropper/Assets/Scripts/Player.cs
  5. 3
      namedropper/Assets/Scripts/TrackballInputManager.cs
  6. 6
      namedropper/Assets/Spinner.cs

126
namedropper/Assets/Ouija.cs

@ -4,14 +4,140 @@ using UnityEngine;
public class Ouija : Level
{
public class Divination
{
public string Question;
public List<string> Answers = new List<string>();
};
public List<Divination> _divinations = new List<Divination>();
int _greenLettersCorrect = 0;
int _redLettersCorrect = 0;
string _question;
string _greenAnswer;
string _redAnswer;
int _divinationNumber = -1;
[SerializeField] UnityEngine.UI.Text _greenAnswerText;
[SerializeField] UnityEngine.UI.Text _redAnswerText;
[SerializeField] UnityEngine.UI.Text _questionText;
// Start is called before the first frame update
void Start()
{
InitDivinations();
for (int i = 0; i < 3; ++i)
{
_players[i].GetComponent<Player>().BecomeInvisible();
_players[i].GetComponent<Player>().PassInputOnto = _players[3].GetComponent<Player>();
}
PickNewDivination();
RefreshText();
}
void PickNewDivination()
{
_redLettersCorrect = 0;
_greenLettersCorrect = 0;
_divinationNumber++;
if (_divinationNumber >= _divinations.Count)
_divinationNumber = 0;
Divination div = _divinations[_divinationNumber];
_question = div.Question;
_redAnswer = div.Answers[Random.Range(0, div.Answers.Count)];
div.Answers.Remove(_redAnswer);
_greenAnswer = div.Answers[Random.Range(0, div.Answers.Count)];
_redAnswer = _redAnswer.ToUpper();
_greenAnswer = _greenAnswer.ToUpper();
}
public void AddLetter(char letter)
{
if (_redAnswer[_redLettersCorrect] == letter)
{
_redLettersCorrect++;
AddScore(10, 3);
if (_redLettersCorrect == _redAnswer.Length)
{
AddScore(30, 3);
PickNewDivination();
}
}
if (_greenAnswer[_greenLettersCorrect] == letter)
{
_greenLettersCorrect++;
AddScore(10, 1);
if (_greenLettersCorrect == _greenAnswer.Length)
{
AddScore(30, 1);
PickNewDivination();
}
}
RefreshText();
}
void RefreshText()
{
_questionText.text = _question;
_redAnswerText.text = "";
for (int i =0; i< _redAnswer.Length; ++i)
{
if (i < _redLettersCorrect)
{
_redAnswerText.text += _redAnswer[i];
}
else
{
_redAnswerText.text += "_";
}
}
_greenAnswerText.text = "";
for (int i = 0; i < _greenAnswer.Length; ++i)
{
if (i < _greenLettersCorrect)
{
_greenAnswerText.text += _greenAnswer[i];
}
else
{
_greenAnswerText.text += "_";
}
}
}
void InitDivinations()
{
Divination div = new Divination();
div.Question = "How will we die?";
div.Answers.Add("Trainwreck");
div.Answers.Add("Decapitation");
div.Answers.Add("Poisoning");
div.Answers.Add("Asphyxiation");
//div.Answers.Add("Senescence");
div.Answers.Add("Overeating");
_divinations.Add(div);
div = new Divination();
div.Question = "How animal we will be in our next life?";
div.Answers.Add("Unicorn");
div.Answers.Add("Wombat");
div.Answers.Add("Anteater");
div.Answers.Add("Goldfinch");
div.Answers.Add("Alpaca");
div.Answers.Add("Dachshund");
div.Answers.Add("Meerkat");
div.Answers.Add("Capybara");
_divinations.Add(div);
}
// Update is called once per frame

18
namedropper/Assets/Planchette.cs

@ -5,9 +5,10 @@ using UnityEngine;
public class Planchette : MonoBehaviour
{
// Start is called before the first frame update
Ouija _ouija;
void Start()
{
_ouija = FindObjectOfType<Ouija>();
}
// Update is called once per frame
@ -18,9 +19,20 @@ public class Planchette : MonoBehaviour
private void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("Letter"))
CHeck(other.gameObject);
}
private void CHeck(GameObject other)
{
if (other.CompareTag("Letter"))
{
Debug.Log(other.gameObject.name);
Debug.Log(other.name);
_ouija.AddLetter(other.name[0]);
}
}
private void OnTriggerStay2D(Collider other)
{
CHeck(other.gameObject);
}
}

17
namedropper/Assets/Scenes/Ouija.unity

@ -758,7 +758,7 @@ GameObject:
- component: {fileID: 131803652}
- component: {fileID: 131803651}
m_Layer: 5
m_Name: Left answer
m_Name: Green answer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -797,7 +797,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Color: {r: 0.13412571, g: 1, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
@ -838,7 +838,7 @@ GameObject:
- component: {fileID: 191278170}
- component: {fileID: 191278169}
m_Layer: 5
m_Name: Right answer
m_Name: Red answer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -877,7 +877,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
@ -1968,7 +1968,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 9049015333349338422, guid: 56b5ab1b6ee02794ab9664e282d1930a, type: 3}
propertyPath: m_Radius
value: 23.37
value: 79.31
objectReference: {fileID: 0}
- target: {fileID: 9049015333349338422, guid: 56b5ab1b6ee02794ab9664e282d1930a, type: 3}
propertyPath: m_Offset.x
@ -5149,6 +5149,9 @@ MonoBehaviour:
Timer: {fileID: 1225785573}
RoundNumber: {fileID: 924483020}
Topic: {fileID: 0}
_greenAnswerText: {fileID: 131803651}
_redAnswerText: {fileID: 191278169}
_questionText: {fileID: 1668933397}
--- !u!1 &1666960087
GameObject:
m_ObjectHideFlags: 0
@ -5268,7 +5271,7 @@ GameObject:
- component: {fileID: 1668933398}
- component: {fileID: 1668933397}
m_Layer: 5
m_Name: Left question
m_Name: question
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -5307,7 +5310,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1

8
namedropper/Assets/Scripts/Player.cs

@ -66,6 +66,8 @@ public class Player : MonoBehaviour
private RaceGame _raceGame;
private GoldMiner _goldMinerGame;
private RedLightGreenLight _redlightGreenlightGame;
private Ouija _ouijaGame;
public bool IsPlanchette = false;
private void Awake()
@ -90,9 +92,15 @@ public class Player : MonoBehaviour
_raceGame = FindObjectOfType<RaceGame>();
_goldMinerGame = FindObjectOfType<GoldMiner>();
_redlightGreenlightGame = FindObjectOfType<RedLightGreenLight>();
_ouijaGame = FindObjectOfType<Ouija>();
if (_redlightGreenlightGame != null)
_curSpeed *= 5f;
if (_ouijaGame != null)
_curSpeed *= 2f;
_originalPosition = transform.position;
/*

3
namedropper/Assets/Scripts/TrackballInputManager.cs

@ -113,6 +113,9 @@ public class TrackballInputManager : MonoBehaviour
_ignoredDevices.Add(1512667);
_ignoredDevices.Add(104598561);
_ignoredDevices.Add(296553843);
_ignoredDevices.Add(58794739);
_ignoredDevices.Add(33629149);
_ignoredDevices.Add(44966641);

6
namedropper/Assets/Spinner.cs

@ -27,10 +27,12 @@ public class Spinner : MonoBehaviour
{
InitAudioSources();
_gameList.Add("Ouija"); //u
_gameList.Add("Redlight Greenlight"); //r
//_gameList.Add("Popstar Pursuit"); //n
_gameList.Add("Bumper Budz 500"); //z
_gameList.Add("Ontology: The Game"); //o
_gameList.Add("Divination"); //o
_gameList.Add("TV Party"); //n
_gameList.Add("Gold Digger"); //g
_gameList.Add("Squid Game"); //r
@ -248,6 +250,10 @@ public class Spinner : MonoBehaviour
{
sceneName = "RedLight";
}
else if (gameName.Contains("Ouija") || gameName.Contains("Divination"))
{
sceneName = "Ouija";
}
else
{
Debug.LogError("unknown game name: " + gameName);

Loading…
Cancel
Save