mirror of
https://github.com/frizbee19/FebGameJam.git
synced 2026-10-11 18:19:11 +00:00
worked on interactions
This commit is contained in:
1 parent
e4bb5027a5
commit
8b5c99ae8d
9 files changed
+259
-11
No files matched your search
@@ -12,7 +12,7 @@ public class Dialogue : MonoBehaviour
|
||||
public List<string> pages = new List<string>();
|
||||
public List<int> emotes = new List<int>();
|
||||
int curPage = 0;
|
||||
public bool isOpen = true;
|
||||
public bool isOpen = false;
|
||||
//used to activate/deactivate test object
|
||||
//activate through outside means probably
|
||||
public GameObject textTest;
|
||||
@@ -29,7 +29,6 @@ public class Dialogue : MonoBehaviour
|
||||
{
|
||||
if (pages.Count > 0)
|
||||
{
|
||||
textbox.text = pages[0];
|
||||
arrow.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TextTrigger : Trigger
|
||||
{
|
||||
public Dialogue TextBox;
|
||||
public override void Action()
|
||||
{
|
||||
TextBox.gameObject.SetActive(true);
|
||||
TextBox.GetComponent<Dialogue>().isOpen = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58ad46602c4301d47a7b6f71726a1cd9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -607,8 +607,10 @@ MonoBehaviour:
|
||||
arrow: {fileID: 7395190149993767727}
|
||||
audioManager: {fileID: 0}
|
||||
pages: []
|
||||
emotes:
|
||||
isOpen: 0
|
||||
textTest: {fileID: 7059772332581294260}
|
||||
isTalking: 0
|
||||
--- !u!1 &7059772333148747624
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -808,7 +810,7 @@ GameObject:
|
||||
- component: {fileID: -2532599903388458229}
|
||||
m_Layer: 0
|
||||
m_Name: Textbox
|
||||
m_TagString: Untagged
|
||||
m_TagString: Event
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
//to implement inheritance
|
||||
public abstract class Trigger : MonoBehaviour
|
||||
{
|
||||
//tags for the trigger
|
||||
public bool forceInteract;
|
||||
public bool repeatable;
|
||||
bool isActive;
|
||||
//only worry about this if it is not repeatable
|
||||
bool hasOccurred;
|
||||
public int value;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
hasOccurred = false;
|
||||
}
|
||||
|
||||
//checks if player is in range of the trigger
|
||||
private void OnTriggerEnter2D(Collider2D other) {
|
||||
if(other.CompareTag("Player")) {
|
||||
isActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D other) {
|
||||
if(other.CompareTag("Player")) {
|
||||
isActive = false;
|
||||
}
|
||||
if(forceInteract && repeatable) {
|
||||
hasOccurred = false;
|
||||
}
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//checks if conditions are right
|
||||
if(isActive && !hasOccurred)
|
||||
{
|
||||
//executes action upon entering
|
||||
if(forceInteract)
|
||||
{
|
||||
Action();
|
||||
hasOccurred = true;
|
||||
isActive = false;
|
||||
}
|
||||
//only executes action if input is pressed
|
||||
else
|
||||
{
|
||||
if(Input.GetKeyDown(KeyCode.E)) {
|
||||
Action();
|
||||
if(!repeatable)
|
||||
{
|
||||
hasOccurred = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void Action();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c5bd9ef9eec88943a606227bd1cc04a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user