Commit 47c2fcc4 authored by Mikko Lainio's avatar Mikko Lainio 🇺🇦
Browse files

new house. Agent follow. exit. game loop works!

parent 387b7755
......@@ -24,6 +24,6 @@ MonoBehaviour:
- {fileID: 3206762778314096309, guid: 2161fedcfbc849b4494944c192ffa5c5, type: 3}
- prefabs:
- {fileID: 9002888587860398046, guid: cc80abb403dd9ef4da06bc1fd164708a, type: 3}
SpawnTimeIntervalMin: 60
SpawnTimeIntervalMax: 120
SpawnTimeIntervalMin: 10
SpawnTimeIntervalMax: 20
FirstSpawnDelay: 3
......@@ -14,6 +14,8 @@ ModelImporter:
100016: LVL2_Floor
100018: LVL2_Floor.001
100020: LVL2_Wall
100022: LVL1_Ceiling
100024: LVL1_Floor_Side
400000: //RootNode
400002: LVL1_Floor
400004: LVL1_Floor_Structure
......@@ -25,6 +27,8 @@ ModelImporter:
400016: LVL2_Floor
400018: LVL2_Floor.001
400020: LVL2_Wall
400022: LVL1_Ceiling
400024: LVL1_Floor_Side
2100000: Floor_Kitchen
2100002: Floor_Garage
2100004: Floor_Utility
......@@ -52,6 +56,8 @@ ModelImporter:
2300014: LVL2_Floor
2300016: LVL2_Floor.001
2300018: LVL2_Wall
2300020: LVL1_Ceiling
2300022: LVL1_Floor_Side
3300000: LVL1_Floor
3300002: LVL1_Floor_Structure
3300004: LVL1_Wall
......@@ -62,6 +68,8 @@ ModelImporter:
3300014: LVL2_Floor
3300016: LVL2_Floor.001
3300018: LVL2_Wall
3300020: LVL1_Ceiling
3300022: LVL1_Floor_Side
4300000: LVL1_Floor
4300002: LVL1_Floor_Structure
4300004: LVL1_Wall
......@@ -72,6 +80,8 @@ ModelImporter:
4300014: LVL1_Foundation
4300016: LVL1_Stairs_Small
4300018: LVL1_Stairs_Porch
4300020: LVL1_Ceiling
4300022: LVL1_Floor_Side
externalObjects: {}
materials:
importMaterials: 1
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &3113178155931937421
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 462108023857111383}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 00eaeb25019592742bc1bddcc9c3925e, type: 3}
m_Name:
m_EditorClassIdentifier:
followTarget: {fileID: 11400000, guid: 80a153decfcb4604591cca5bc39ea627, type: 2}
--- !u!1001 &2715906221599793941
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -205,6 +218,12 @@ PrefabInstance:
m_RemovedComponents:
- {fileID: 9159155887931913307, guid: 2616bfe1b98391b4e9cd7dc6adfb3f9a, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 2616bfe1b98391b4e9cd7dc6adfb3f9a, type: 3}
--- !u!1 &462108023857111383 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 7457721927691512660, guid: 2616bfe1b98391b4e9cd7dc6adfb3f9a,
type: 3}
m_PrefabInstance: {fileID: 6995948774928271875}
m_PrefabAsset: {fileID: 0}
--- !u!195 &462108023857111380 stripped
NavMeshAgent:
m_CorrespondingSourceObject: {fileID: 7457721927691512663, guid: 2616bfe1b98391b4e9cd7dc6adfb3f9a,
......
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Agent))]
public class AgentFollow : MonoBehaviour
{
public AgentData followTarget;
private Agent m_target;
private bool m_finding;
// Start is called before the first frame update
void Start()
{
}
void Update()
{
if (m_target == null && !m_finding)
{
StartCoroutine(FindFollowTarget());
m_finding = true;
}
}
public IEnumerator FindFollowTarget()
{
while (m_target == null)
{
foreach (Agent agent in FindObjectsOfType<Agent>())
{
if (agent.data_ == followTarget)
{
m_target = agent;
}
}
yield return new WaitForSeconds(1f);
}
GetComponent<Agent>().SetFollow(m_target.transform);
m_finding = false;
}
}
fileFormatVersion: 2
guid: 00eaeb25019592742bc1bddcc9c3925e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Exit : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
Agent a = other.GetComponentInChildren<Agent>();
if (a != null)
{
GameManager.instance.OnAgentExit(a);
a.gameObject.SetActive(false);
}
}
}
fileFormatVersion: 2
guid: ffa44f0dc471b2840bf163b10fcb66da
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -14,6 +14,9 @@ public class GameManager : MonoBehaviour
// Dictionary with reference to roomtype and an array of all waypoints belonging to said roomtype
public Dictionary<Room, List<Waypoint>> waypoints = new Dictionary<Room, List<Waypoint>> { };
public float waitTime_;
public GameObject spawnPoint;
public Waypoint exitPoint;
[SerializeField] private LevelData m_levelData;
[SerializeField] private int MaxEnergy = 1000;
private int m_currentEnergy = 1000;
......@@ -48,6 +51,7 @@ public class GameManager : MonoBehaviour
// Start is called before the first frame update
void Start()
{
Debug.Log("Start spawning");
Wait(m_levelData.FirstSpawnDelay, SpawnNext);
}
......@@ -58,23 +62,34 @@ public class GameManager : MonoBehaviour
SpawnEvent spawn = m_levelData.agentSpawns[m_nextSpawnIndex++];
int pos = 0;
foreach (GameObject prefab in spawn.prefabs)
{
GameObject o = Instantiate<GameObject>(prefab);
o.transform.position = spawnPoint.transform.position;
o.transform.position += pos * Vector3.right * 2;
Agent agent = o.GetComponentInChildren<Agent>();
if (agent != null)
agent.AgentStart();
}
Wait(m_levelData.GetSpawnInterval(), SpawnNext);
}
public void Wait(float time, Action onDone)
{
StartCoroutine(doWait(time));
StartCoroutine(doWait(time, onDone));
}
private IEnumerator doWait(float t)
private IEnumerator doWait(float t, Action action)
{
yield return new WaitForSeconds(t);
action.Invoke();
}
public void OnAgentExitLevel(Agent agent)
public void OnAgentExit(Agent agent)
{
m_session.AddScore(new ScoreObject(agent.data_, agent.currentSatisfaction_, agent.currentHorror_));
}
......
......@@ -6,8 +6,9 @@ using UnityEditor;
public enum Room
{
NONE = 0000,
OFFSCREEN = 0001,
STARTPOINT = 0002,
OFFSCREEN = 0100,
STARTPOINT = 0200,
EXIT = 0300,
DRIVEWAY = 1000,
PORCH = 1001,
BACK_PORCH = 1002,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment