Skip to content

Commit

Permalink
Flares reset when player dies. Helicopter position resets if player d…
Browse files Browse the repository at this point in the history
…ies after heli is called. Added audio when zombies start running.
  • Loading branch information
Kevin Semple authored and Kevin Semple committed Jan 4, 2018
1 parent bd9b85e commit 24bfe55
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 8 deletions.
Binary file added Assets/Audio/runForYourLife.wav
Binary file not shown.
23 changes: 23 additions & 0 deletions Assets/Audio/runForYourLife.wav.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Assets/Prefabs/Flare.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ GameObject:
- component: {fileID: 199859360644480976}
- component: {fileID: 54361894026798142}
- component: {fileID: 135525318005314464}
- component: {fileID: 114273709474149678}
m_Layer: 0
m_Name: Flare
m_TagString: flare
Expand Down Expand Up @@ -120,6 +121,17 @@ Rigidbody:
m_Interpolate: 0
m_Constraints: 122
m_CollisionDetection: 0
--- !u!114 &114273709474149678
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1480811817562742}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8e7f31408a0b643fcba8a714bb57a41d, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!135 &135525318005314464
SphereCollider:
m_ObjectHideFlags: 1
Expand Down
13 changes: 10 additions & 3 deletions Assets/Scripts/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class GameController : MonoBehaviour {
//public enum blockColour{red,blue,yellow,noColour};
public static int difficulty = 1;
public static int difficulty = 3;
public blockColour[] mysterySequence;
public blockColour[] tempArray;
public GameObject redBlock;
Expand All @@ -19,7 +19,6 @@ public class GameController : MonoBehaviour {
public Radio radio;
public Battery battery;


public static GameController instance;
public bool isGameWon;
public blockColour[] guessedSequence;
Expand Down Expand Up @@ -97,6 +96,9 @@ void initializeGame(){
player = GameObject.FindGameObjectWithTag ("Player");
SetPlayerPosition ();
player.GetComponent<PlayerController> ().isAlive = true;
player.GetComponent<PlayerController> ().ResetFlareCount ();

//Initialize Zombies
SetZombiePosition ();

//game starts with a mystery sequence that the player must guess
Expand Down Expand Up @@ -208,7 +210,7 @@ void updateUI(){
}else{
WinText.gameObject.SetActive (false);
bullseyeText.text = "BULLSEYES: " + bullseyes;
nearMissText.text = "NICE TRY: " + nearMisses;
//nearMissText.text = "NICE TRY: " + nearMisses;
}

}
Expand All @@ -229,6 +231,7 @@ void GenerateMysterySequence(){
void resetGame(){
DropZone[] dropZones = GameObject.FindObjectsOfType<DropZone>();
Pickup[] blocksList = GameObject.FindObjectsOfType<Pickup> ();
PlayerFlare[] playerFlareList = GameObject.FindObjectsOfType<PlayerFlare> ();

//Destroy all Dropzones
foreach(DropZone dz in dropZones){
Expand All @@ -238,6 +241,10 @@ void resetGame(){
foreach(Pickup block in blocksList){
Destroy (block.gameObject);
}
//Destroy all flares
foreach(PlayerFlare pf in playerFlareList){
Destroy (pf.gameObject);
}

DropZone.resetDropZoneID();
}
Expand Down
11 changes: 10 additions & 1 deletion Assets/Scripts/Helicopter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ public class Helicopter : MonoBehaviour {

public float speed = 50f;
public float rotationSpeed = 0.5f;
public float delay = 5f;

public Transform target;
public Transform finalDestination;
public float delay = 5f;

private Vector3 initialPosition;
private float elapsedTime;
private Rigidbody rgbd;
private GameController gameController;
Expand All @@ -23,6 +25,8 @@ void Start () {
elapsedTime = Time.deltaTime;
heliCam = gameObject.GetComponentInChildren<Camera> ();
heliCam.enabled = false;
resetPosition ();

}

// Update is called once per frame
Expand Down Expand Up @@ -75,4 +79,9 @@ void OnTriggerEnter(Collider other){
}
}

public void resetPosition(){
initialPosition = new Vector3 (0, 100f, 0);
transform.position = initialPosition;
}

}
12 changes: 11 additions & 1 deletion Assets/Scripts/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void Start () {
hasBattery = false;
hasRadio = false;
isAlive = true;
inventoryText.text = "Flares -"+ flareCount+"-";
UpdateUI ();
}

// Update is called once per frame
Expand Down Expand Up @@ -137,6 +137,10 @@ void DeathSequence(float speed){
audioSource2.clip = scream;
audioSource2.Play ();
gameController.playerDied (speed);

//reset helicopter
helicopter.resetPosition ();
helicopter.gameObject.SetActive (false);
}

void UpdateUI(){
Expand All @@ -148,6 +152,12 @@ void UpdateUI(){
inventoryText.text += "\n(R)adio";
}
}

public void ResetFlareCount(){
flareCount = 3;
UpdateUI ();
flareReady = true;
}
/*
* No longer being used
*
Expand Down
16 changes: 16 additions & 0 deletions Assets/Scripts/PlayerFlare.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerFlare : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}
}
10 changes: 7 additions & 3 deletions Assets/_Scenes/main.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1879,8 +1879,8 @@ Transform:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 579209423}
m_LocalRotation: {x: 0.14815848, y: 0.094785, z: 0.014267155, w: -0.9843076}
m_LocalPosition: {x: 21.4246, y: -39.91497, z: -82.99336}
m_LocalRotation: {x: 0, y: 1, z: 0, w: -0.00000004371139}
m_LocalPosition: {x: 15.96, y: -19.78, z: -3.8000011}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
Expand Down Expand Up @@ -4251,6 +4251,10 @@ Prefab:
propertyPath: target
value:
objectReference: {fileID: 1396929938}
- target: {fileID: 1192355883297124, guid: da983e8196b6e4ce6a0d47f496bf4cfa, type: 2}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: da983e8196b6e4ce6a0d47f496bf4cfa, type: 2}
m_IsPrefabParent: 0
Expand Down Expand Up @@ -5475,7 +5479,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: NICE TRY
m_Text:
--- !u!222 &2134822418
CanvasRenderer:
m_ObjectHideFlags: 0
Expand Down

0 comments on commit 24bfe55

Please sign in to comment.