This repository has been archived on 2026-04-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ludumdare41/Assets/Scripts/Blocks/BlockIce.cs
T
2018-04-21 15:03:13 +10:00

34 lines
865 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BlockIce : MonoBehaviour {
Rigidbody2D rigidBody;
public float bombTimer = -1;
public GameObject bombPrefab;
void Awake() {
rigidBody = GetComponent<Rigidbody2D> ();
}
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);
}
WindDamager wind = collider.gameObject.GetComponent<WindDamager> ();
if (wind != null) {
rigidBody.AddForce (collider.gameObject.GetComponent<Rigidbody2D> ().velocity * 20, ForceMode2D.Impulse);
}
}
}