Polishing the sprites
This commit is contained in:
@@ -39,7 +39,9 @@ public class BlockIce : MonoBehaviour {
|
||||
bomb.GetComponent<Bomb> ().timer = bombTimer;
|
||||
bomb.GetComponent<Bomb> ().respawner = respawner;
|
||||
}
|
||||
respawner.enabled = true;
|
||||
if (respawner != null) {
|
||||
respawner.enabled = true;
|
||||
}
|
||||
Destroy (gameObject);
|
||||
}
|
||||
|
||||
|
||||
+11
-1
@@ -3,19 +3,27 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Bomb : MonoBehaviour {
|
||||
Animator animator;
|
||||
Rigidbody2D rigidBody;
|
||||
|
||||
public float timer;
|
||||
|
||||
GameObject explosion;
|
||||
public GameObject iceBlockPrefab;
|
||||
public Sprite deadBomb;
|
||||
|
||||
public Respawner respawner; //this can be respawned
|
||||
|
||||
float birthTime;
|
||||
|
||||
void Awake() {
|
||||
animator = GetComponent<Animator> ();
|
||||
rigidBody = GetComponent<Rigidbody2D> ();
|
||||
|
||||
if (timer < 0) {
|
||||
animator.enabled = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Start() {
|
||||
@@ -53,7 +61,9 @@ public class Bomb : MonoBehaviour {
|
||||
yield return new WaitForSeconds (delay);
|
||||
explosion.SetActive (true);
|
||||
transform.DetachChildren ();
|
||||
respawner.enabled = true;
|
||||
if (respawner != null) {
|
||||
respawner.enabled = true;
|
||||
}
|
||||
Destroy (gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Cannon : MonoBehaviour {
|
||||
SpriteRenderer spriteRenderer;
|
||||
public enum Direction {
|
||||
NORTH, EAST, SOUTH, WEST
|
||||
};
|
||||
|
||||
public Direction direction;
|
||||
public GameObject pelletPrefab;
|
||||
public float delay;
|
||||
float speed = 3f;
|
||||
|
||||
public Sprite sprite; //TMP, hopefully
|
||||
|
||||
void Awake() {
|
||||
spriteRenderer = GetComponent<SpriteRenderer> ();
|
||||
spriteRenderer.sprite = sprite;
|
||||
|
||||
StartCoroutine (FireOnTimer (delay));
|
||||
}
|
||||
|
||||
IEnumerator FireOnTimer(float seconds) {
|
||||
while(true) {
|
||||
yield return new WaitForSeconds (seconds);
|
||||
GameObject go = Instantiate (pelletPrefab);
|
||||
go.transform.position = transform.position;
|
||||
|
||||
switch (direction) {
|
||||
case Direction.NORTH:
|
||||
go.GetComponent<Rigidbody2D> ().AddForce (new Vector2 (0, speed), ForceMode2D.Impulse);
|
||||
break;
|
||||
case Direction.EAST:
|
||||
go.GetComponent<Rigidbody2D> ().AddForce (new Vector2 (speed, 0), ForceMode2D.Impulse);
|
||||
break;
|
||||
case Direction.SOUTH:
|
||||
go.GetComponent<Rigidbody2D> ().AddForce (new Vector2 (0, -speed), ForceMode2D.Impulse);
|
||||
break;
|
||||
case Direction.WEST:
|
||||
go.GetComponent<Rigidbody2D> ().AddForce (new Vector2 (-speed, 0), ForceMode2D.Impulse);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2156f7523fec09c4da77aaf24c77aabd
|
||||
timeCreated: 1524401895
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user