Commit f8b21b5e authored by Danny Huang's avatar Danny Huang
Browse files

store auto-detects Hero's camera. Add instant death hazard prefab

parent 062ea0b1
......@@ -31,7 +31,6 @@ public class EnemyDeathCtrl : DeathCtrl
{
GameObject loot = (GameObject) Instantiate (this.rndItemPrefab, this.transform.position,
Quaternion.identity, null);
}
}
}
......@@ -52,6 +52,8 @@ public class HeroDeathCtrl : DeathCtrl
this.rb.isKinematic = true;
this.heroInventory.DropAllItems();
this.heroHealthCtrl.numLives--;
}
public void Revive()
......@@ -67,5 +69,7 @@ public class HeroDeathCtrl : DeathCtrl
this.spriteRend.enabled = true;
this.rb.isKinematic = false;
this.transform.position = GameObject.FindGameObjectWithTag ("PlayerSpawn").transform.position;
}
}
......@@ -6,6 +6,8 @@ public class HeroHealthCtrl : HealthCtrl
{
public Text healthTextUI;
public int numLives;
protected Rigidbody2D rb;
protected HeroInventory heroInventory;
......
fileFormatVersion: 2
guid: 25fb176143bf3cc42bda2beb49125291
folderAsset: yes
timeCreated: 1480214660
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9defcd17ec8f9d442ab81465d1594d42
timeCreated: 1480214664
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
......@@ -36,6 +36,8 @@ public class StoreInventoryCtrl : MonoBehaviour
/* Valid if Hero is nearby. */
protected HeroInventory heroInv;
public Canvas canvas;
void Awake()
{
......@@ -43,6 +45,9 @@ public class StoreInventoryCtrl : MonoBehaviour
void Start ()
{
this.canvas.renderMode = RenderMode.ScreenSpaceCamera;
this.canvas.worldCamera = Camera.main;
this.itemGenCtrl = GameObject.FindGameObjectWithTag("ItemGenerator").GetComponent<ItemGeneratorCtrl>();
this.isHeroReached = false;
......
using UnityEngine;
using System.Collections;
public class Hazard : MonoBehaviour {
public class Hazard : MonoBehaviour
{
public bool isInstantDeathZone = false;
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("Player"))
{
other.gameObject.SendMessage("TakeEnvironmentDamage", -5);
}
if (other.gameObject.CompareTag ("Player")) {
if (this.isInstantDeathZone)
other.gameObject.SendMessage ("ModifyCurrentHealth", -9999);
else
other.gameObject.SendMessage ("TakeEnvironmentDamage", -5);
} else {
Destroy (other.gameObject);
}
}
}
\ No newline at end of file
Supports Markdown
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