Blocks are all acting correctly, bomb is acting correctly
This commit is contained in:
Generated
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60b898dd509fa664d986aed43f17b8ba
|
||||
folderAsset: yes
|
||||
timeCreated: 1524282772
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BlockBush : MonoBehaviour {
|
||||
GameObject burnt;
|
||||
|
||||
void Awake() {
|
||||
burnt = transform.GetChild (0).gameObject;
|
||||
}
|
||||
|
||||
void OnTriggerEnter2D(Collider2D collider) {
|
||||
//TODO: use durability class?
|
||||
FireDamager fire = collider.gameObject.GetComponent<FireDamager> ();
|
||||
if (fire != null) {
|
||||
burnt.SetActive (true);
|
||||
transform.DetachChildren ();
|
||||
Destroy (gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b0265e5d9f1a804aaa77a77754f51e0
|
||||
timeCreated: 1524281573
|
||||
guid: 3637ac4ce14452c4cada0ccc2d5d8e75
|
||||
timeCreated: 1524282472
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BlockIce : MonoBehaviour {
|
||||
public float bombTimer = -1;
|
||||
|
||||
public GameObject bombPrefab;
|
||||
|
||||
void OnTriggerEnter2D(Collider2D collider) {
|
||||
//TODO: use durability class?
|
||||
FireDamager fire = collider.gameObject.GetComponent<FireDamager> ();
|
||||
if (fire != null) {
|
||||
if (bombTimer >= 0) {
|
||||
GameObject bomb = Instantiate (bombPrefab);
|
||||
bomb.transform.position = transform.position;
|
||||
bomb.GetComponent<Bomb> ().timer = bombTimer;
|
||||
}
|
||||
Destroy (gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb19c1709331b3d44b5ddc164ca9dbbe
|
||||
timeCreated: 1524283289
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+22
-1
@@ -6,11 +6,32 @@ public class Bomb : MonoBehaviour {
|
||||
public float timer;
|
||||
|
||||
GameObject explosion;
|
||||
public GameObject iceBlockPrefab;
|
||||
|
||||
void Awake() {
|
||||
float birthTime;
|
||||
|
||||
void Start() {
|
||||
StartCoroutine (ExplodeAfter (timer));
|
||||
|
||||
explosion = transform.GetChild (0).gameObject;
|
||||
|
||||
birthTime = Time.time;
|
||||
}
|
||||
|
||||
void OnTriggerEnter2D(Collider2D collider) {
|
||||
FireDamager fire = collider.gameObject.GetComponent<FireDamager> ();
|
||||
if (fire != null) {
|
||||
//explode immediately
|
||||
StartCoroutine(ExplodeAfter(0));
|
||||
}
|
||||
|
||||
IceDamager ice = collider.gameObject.GetComponent<IceDamager> ();
|
||||
if (ice != null) {
|
||||
GameObject iceBlock = Instantiate (iceBlockPrefab);
|
||||
iceBlock.transform.position = transform.position;
|
||||
iceBlock.GetComponent<BlockIce> ().bombTimer = timer - (Time.time - birthTime);
|
||||
Destroy (gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator ExplodeAfter(float delay) {
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DamagerBase : MonoBehaviour {
|
||||
public int value = 1;
|
||||
|
||||
void Awake() {
|
||||
StartCoroutine (DestroySelfAfter (30));
|
||||
}
|
||||
|
||||
IEnumerator DestroySelfAfter(float delay) {
|
||||
yield return new WaitForSeconds (delay);
|
||||
Destroy (gameObject);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
//shootable
|
||||
public class IceDamager : DamagerBase {
|
||||
void OnTriggerEnter2D(Collider2D collider) {
|
||||
if (collider.gameObject.GetComponent<IceDamager> () == null) { //pass through other instances of self
|
||||
Destroy (gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,8 @@ using UnityEngine;
|
||||
|
||||
public class Player : MonoBehaviour {
|
||||
public enum Mode {
|
||||
FIRE, ICE, WIND
|
||||
FIRE, ICE, WIND,
|
||||
LAST
|
||||
};
|
||||
|
||||
Animator animator;
|
||||
@@ -55,6 +56,9 @@ public class Player : MonoBehaviour {
|
||||
|
||||
if (Input.GetButtonDown("Switch")) {
|
||||
mode += 1;
|
||||
if (mode == Mode.LAST) {
|
||||
mode = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user