Browse Source

Kill zone and win and lose states

master
NickFowler 4 years ago
parent
commit
60d9ce6eef
5 changed files with 92 additions and 4 deletions
  1. +32
    -2
      Assets/Scenes/SampleScene.unity
  2. +28
    -0
      Assets/Scripts/Gameplay/KillZone.cs
  3. +11
    -0
      Assets/Scripts/Gameplay/KillZone.cs.meta
  4. +20
    -2
      Assets/Scripts/Gameplay/Objective.cs
  5. +1
    -0
      Assets/Scripts/Input/HerdController.cs

+ 32
- 2
Assets/Scenes/SampleScene.unity View File

@ -430,6 +430,36 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &383701014
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 383701015}
m_Layer: 0
m_Name: Spawn
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &383701015
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 383701014}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.5, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &705507993 --- !u!1 &705507993
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -911,11 +941,11 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
Prefab: {fileID: 7371939184051845554, guid: f5c2c9744b6f46e4e95ca41ab1d8d560, type: 3} Prefab: {fileID: 7371939184051845554, guid: f5c2c9744b6f46e4e95ca41ab1d8d560, type: 3}
HerdCount: 20
HerdCount: 100
SpawnPoint: {fileID: 0} SpawnPoint: {fileID: 0}
WaitTime: 0.2 WaitTime: 0.2
Centre: {fileID: 338695193} Centre: {fileID: 338695193}
GameState: {fileID: 0}
GameState: {fileID: 1065404630}
--- !u!4 &1457452761 --- !u!4 &1457452761
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

+ 28
- 0
Assets/Scripts/Gameplay/KillZone.cs View File

@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class KillZone : MonoBehaviour
{
public HerdController herd;
// Start is called before the first frame update
void Start()
{
herd = FindObjectOfType<HerdController>();
}
private void OnTriggerEnter(Collider other)
{
Debug.Log("Hit");
PlayerController horse = other.GetComponent<PlayerController>();
if (horse != null)
herd.RemoveHorse(horse);
}
// Update is called once per frame
void Update()
{
}
}

+ 11
- 0
Assets/Scripts/Gameplay/KillZone.cs.meta View File

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

+ 20
- 2
Assets/Scripts/Gameplay/Objective.cs View File

@ -4,15 +4,33 @@ using UnityEngine;
public class Objective : MonoBehaviour public class Objective : MonoBehaviour
{ {
private List<PlayerController> onObjective = new List<PlayerController>();
private GameStateController GameState;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
GameState = FindObjectOfType<GameStateController>();
}
private void OnTriggerEnter(Collider other)
{
PlayerController horse = other.GetComponent<PlayerController>();
if (horse != null)
onObjective.Add(horse);
}
private void OnTriggerExit(Collider other)
{
PlayerController horse = other.GetComponent<PlayerController>();
if (horse != null)
onObjective.Remove(horse);
} }
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if(onObjective.Count >= 10)
GameState.WinState();
} }
} }

+ 1
- 0
Assets/Scripts/Input/HerdController.cs View File

@ -31,6 +31,7 @@ public class HerdController : MonoBehaviour
void Start() void Start()
{ {
GameState = FindObjectOfType<GameStateController>();
SpawnHerd(); SpawnHerd();
} }

Loading…
Cancel
Save