@@ -3,9 +3,27 @@

public class FacadeMover : MonoBehaviour {

public float speed;
public float speed,
timeToWaitAtStops;

float stopTime;

void Update () {
transform.position += Vector3.back * speed * Time.deltaTime;

if(stopTime <= 0) {
transform.position += Vector3.back * speed * Time.deltaTime;
} else {
stopTime -= Time.deltaTime;
}
}

public void stop() {

stopTime = timeToWaitAtStops;
}

public void reset() {

transform.position = Vector3.zero;
}
}
@@ -0,0 +1,59 @@
using UnityEngine;
using System.Collections;

public class Npc : MonoBehaviour {

public string characterName;

// responses
public string[] options, explains;
public string dialogueIntro,
dialogueOutro,
weAlreadyTalkedBro,
isGivenItem,
alreadyHasItem,
ifYes,
ifNo;

public bool canGiveItem,
hasTalked = false,
introIsQuestion,
giveItemAfterIntro,
exitAfterIntro;

public int onStop,
offStop;

public bool[] daysToTriggerOn;

MeshRenderer r;
BoxCollider box;

void Start() {
try {
r = GetComponentInChildren<MeshRenderer>();
} catch {
//Debug.Log("Couldn't find MeshRenderer in " + characterName);
}

box = GetComponent<BoxCollider>();
}

public void enter() {
try {
r.enabled = true;
box.enabled = true;
} catch {
//Debug.Log("Couldn't find MeshRenderer in " + characterName);
}
}

public void leave() {
try {
r.enabled = false;
box.enabled = false;
} catch {
//Debug.Log("Couldn't find MeshRenderer in " + characterName);
}
}
}
File renamed without changes.

This file was deleted.

@@ -1,40 +1,119 @@
using UnityEngine;
using System.Collections;
using UnityEditor.SceneManagement;
using System.Collections.Generic;

public class gameController : MonoBehaviour {
public class GameController : MonoBehaviour {

public dialogueScript dialoguescript;
public Dialogue dialoguescript;
public FacadeMover facade;

public int day = 0;
public int busFare,
day = 0,
stop = 0;

public float timeToStop;
public float[] timeBetweenStops;

public bool dayStarted = false;
float timeToNextStop;
int nextStop;
List<Npc>[] allNpcs;

void Awake() {
DontDestroyOnLoad(this.gameObject);
}
// items
public bool hasWallet,
hasResume,
hasPalmReading,
hasSketchbook,
hasSketches;

void Start() {
dialoguescript = GameObject.FindGameObjectWithTag("Player").GetComponent<dialogueScript>();

// initialize
nextStop = 0;
timeToNextStop = 0;
hasWallet = false;
hasResume = false;
hasPalmReading = false;
hasSketchbook = false;
hasSketches = false;

// keep gameController persistent
DontDestroyOnLoad(this.gameObject);

// oh jeez
allNpcs = new List<Npc>[7];
for(int i = 0; i < allNpcs.Length; i++) allNpcs[i] = new List<Npc>();

// find all NPCS and sort scripts by day
foreach(GameObject o in GameObject.FindGameObjectsWithTag("NPC")) { // all GameObjects that have Npc scripts
foreach(Npc script in o.GetComponents<Npc>()) { // all Npc scripts
for(int i = 0; i < script.daysToTriggerOn.Length; i++) { // 7 times for 7 days
if(script.daysToTriggerOn[i]) { // if script is set to trigger on this day
allNpcs[i].Add(script);
}
}
}
}

// start with no NPCs on the bus
clearAllNpcs();
}

void Update() {

if(dayStarted == false) {
day = day + 1;
dayStarted = true;
} else if(dayStarted == true) {
timeToStop -= Time.deltaTime;
// count down until we arrive at the next stop
timeToNextStop -= Time.deltaTime;

if(timeToNextStop <= 0) {

// stop animation
facade.stop();

// check who should or shouldn't be on the bus
checkNpcs();

// assign next stop
nextStop++;

// if we have done all the stops, on to next day
if(nextStop > timeBetweenStops.Length) {
// TODO: add day transition
nextStop = 0;
clearAllNpcs();
checkNpcs();
facade.reset();
day++;
Debug.Log("It is now day " + day);
}

// reset timer
timeToNextStop += timeBetweenStops[nextStop];

// debug
Debug.Log("We just arrived at " + (nextStop - 1) + ". The next stop is " + nextStop + ".\nTime to next stop: " + timeToNextStop);
}

if(timeToStop <= 0) {
Invoke("endDay", 0);
if(Input.GetButtonDown("Skip")) {
Debug.Log("SKIP");
timeToNextStop = 0;
}
}

void checkNpcs() {
foreach(Npc o in allNpcs[day]) {
if(o.onStop == nextStop) {
Debug.Log(o.characterName + " entered.");
o.enter();
}
if(o.offStop == nextStop) {
Debug.Log(o.characterName + " left.");
o.leave();
}
}
}

void endDay() {

void clearAllNpcs() {
for(int i = 0; i < 7; i++) {
foreach(Npc o in allNpcs[i]) o.leave();
}
}
}

This file was deleted.

BIN +64 Bytes (100%) ProjectSettings/InputManager.asset
Binary file not shown.